vskill 0.5.104 → 0.5.106

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.
Files changed (86) hide show
  1. package/README.md +123 -2
  2. package/agents.json +1 -1
  3. package/dist/agents/agents-registry.d.ts +0 -1
  4. package/dist/agents/agents-registry.js +10 -30
  5. package/dist/agents/agents-registry.js.map +1 -1
  6. package/dist/api/client.d.ts +21 -0
  7. package/dist/api/client.js +39 -5
  8. package/dist/api/client.js.map +1 -1
  9. package/dist/commands/diff.d.ts +2 -5
  10. package/dist/commands/diff.js +82 -117
  11. package/dist/commands/diff.js.map +1 -1
  12. package/dist/commands/eval/serve.js +4 -0
  13. package/dist/commands/eval/serve.js.map +1 -1
  14. package/dist/commands/keys.d.ts +14 -0
  15. package/dist/commands/keys.js +166 -0
  16. package/dist/commands/keys.js.map +1 -0
  17. package/dist/commands/masked-stdin.d.ts +14 -0
  18. package/dist/commands/masked-stdin.js +79 -0
  19. package/dist/commands/masked-stdin.js.map +1 -0
  20. package/dist/commands/skill.d.ts +3 -29
  21. package/dist/commands/skill.js +6 -32
  22. package/dist/commands/skill.js.map +1 -1
  23. package/dist/eval/anthropic-catalog.d.ts +49 -0
  24. package/dist/eval/anthropic-catalog.js +238 -0
  25. package/dist/eval/anthropic-catalog.js.map +1 -0
  26. package/dist/eval/llm.d.ts +1 -1
  27. package/dist/eval/llm.js +68 -10
  28. package/dist/eval/llm.js.map +1 -1
  29. package/dist/eval/mcp-detector.js +24 -3
  30. package/dist/eval/mcp-detector.js.map +1 -1
  31. package/dist/eval/model-resolver.d.ts +39 -0
  32. package/dist/eval/model-resolver.js +94 -0
  33. package/dist/eval/model-resolver.js.map +1 -0
  34. package/dist/eval/pricing.js +42 -16
  35. package/dist/eval/pricing.js.map +1 -1
  36. package/dist/eval-server/api-routes.d.ts +9 -0
  37. package/dist/eval-server/api-routes.js +241 -73
  38. package/dist/eval-server/api-routes.js.map +1 -1
  39. package/dist/eval-server/authoring-routes.js +21 -1
  40. package/dist/eval-server/authoring-routes.js.map +1 -1
  41. package/dist/eval-server/boot-preflight.js +8 -10
  42. package/dist/eval-server/boot-preflight.js.map +1 -1
  43. package/dist/eval-server/darwin-migrator.d.ts +57 -0
  44. package/dist/eval-server/darwin-migrator.js +169 -0
  45. package/dist/eval-server/darwin-migrator.js.map +1 -0
  46. package/dist/eval-server/eval-server.d.ts +1 -0
  47. package/dist/eval-server/eval-server.js +21 -0
  48. package/dist/eval-server/eval-server.js.map +1 -1
  49. package/dist/eval-server/integration-routes.js +7 -0
  50. package/dist/eval-server/integration-routes.js.map +1 -1
  51. package/dist/eval-server/platform-proxy.d.ts +18 -0
  52. package/dist/eval-server/platform-proxy.js +153 -0
  53. package/dist/eval-server/platform-proxy.js.map +1 -0
  54. package/dist/eval-server/providers.d.ts +7 -12
  55. package/dist/eval-server/providers.js +13 -15
  56. package/dist/eval-server/providers.js.map +1 -1
  57. package/dist/eval-server/settings-store.d.ts +31 -26
  58. package/dist/eval-server/settings-store.js +246 -143
  59. package/dist/eval-server/settings-store.js.map +1 -1
  60. package/dist/eval-server/skill-create-routes.js +18 -0
  61. package/dist/eval-server/skill-create-routes.js.map +1 -1
  62. package/dist/eval-server/skill-name-resolver.d.ts +35 -0
  63. package/dist/eval-server/skill-name-resolver.js +146 -0
  64. package/dist/eval-server/skill-name-resolver.js.map +1 -0
  65. package/dist/eval-ui/assets/{CommandPalette-DiPALzlG.js → CommandPalette-COqdrmRl.js} +1 -1
  66. package/dist/eval-ui/assets/CreateSkillPage-C3IjO8es.js +12 -0
  67. package/dist/eval-ui/assets/UpdateDropdown-DnKKMBBN.js +1 -0
  68. package/dist/eval-ui/assets/index-Dmja1p3A.css +1 -0
  69. package/dist/eval-ui/assets/index-KIcQ5e5a.js +102 -0
  70. package/dist/eval-ui/index.html +2 -2
  71. package/dist/first-run-onboarding.d.ts +19 -0
  72. package/dist/first-run-onboarding.js +104 -0
  73. package/dist/first-run-onboarding.js.map +1 -0
  74. package/dist/index.js +18 -0
  75. package/dist/index.js.map +1 -1
  76. package/dist/installer/canonical.js +12 -13
  77. package/dist/installer/canonical.js.map +1 -1
  78. package/dist/utils/resolve-binary.js +7 -8
  79. package/dist/utils/resolve-binary.js.map +1 -1
  80. package/package.json +5 -2
  81. package/dist/eval-ui/assets/CreateSkillPage-BMrFELep.js +0 -12
  82. package/dist/eval-ui/assets/UpdateDropdown-Bj8kZzuR.js +0 -1
  83. package/dist/eval-ui/assets/_shimNode-D3bBqrAh.js +0 -1
  84. package/dist/eval-ui/assets/index-BSPDkfZG.js +0 -102
  85. package/dist/eval-ui/assets/index-C0Gc_4KC.css +0 -1
  86. package/dist/eval-ui/assets/resolve-binary-DIxhrZ6O.js +0 -2
@@ -0,0 +1,102 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-DnKKMBBN.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-COqdrmRl.js","assets/CreateSkillPage-C3IjO8es.js"])))=>i.map(i=>d[i]);
2
+ /* empty css */(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const f of u.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&o(f)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function ev(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var sd={exports:{}},ws={};/**
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 Sx;function X1(){if(Sx)return ws;Sx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(o,c,u){var f=null;if(u!==void 0&&(f=""+u),c.key!==void 0&&(f=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:f,ref:c!==void 0?c:null,props:u}}return ws.Fragment=r,ws.jsx=s,ws.jsxs=s,ws}var kx;function Q1(){return kx||(kx=1,sd.exports=X1()),sd.exports}var a=Q1(),id={exports:{}},Oe={};/**
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 Z1(){if(wx)return Oe;wx=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),f=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),j=Symbol.iterator;function S(z){return z===null||typeof z!="object"?null:(z=j&&z[j]||z["@@iterator"],typeof z=="function"?z:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,w={};function N(z,P,te){this.props=z,this.context=P,this.refs=w,this.updater=te||k}N.prototype.isReactComponent={},N.prototype.setState=function(z,P){if(typeof z!="object"&&typeof z!="function"&&z!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,z,P,"setState")},N.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function A(){}A.prototype=N.prototype;function D(z,P,te){this.props=z,this.context=P,this.refs=w,this.updater=te||k}var U=D.prototype=new A;U.constructor=D,E(U,N.prototype),U.isPureReactComponent=!0;var L=Array.isArray;function F(){}var C={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function T(z,P,te){var le=te.ref;return{$$typeof:t,type:z,key:P,ref:le!==void 0?le:null,props:te}}function _(z,P){return T(z.type,P,z.props)}function I(z){return typeof z=="object"&&z!==null&&z.$$typeof===t}function K(z){var P={"=":"=0",":":"=2"};return"$"+z.replace(/[=:]/g,function(te){return P[te]})}var Q=/\/+/g;function q(z,P){return typeof z=="object"&&z!==null&&z.key!=null?K(""+z.key):P.toString(36)}function H(z){switch(z.status){case"fulfilled":return z.value;case"rejected":throw z.reason;default:switch(typeof z.status=="string"?z.then(F,F):(z.status="pending",z.then(function(P){z.status==="pending"&&(z.status="fulfilled",z.value=P)},function(P){z.status==="pending"&&(z.status="rejected",z.reason=P)})),z.status){case"fulfilled":return z.value;case"rejected":throw z.reason}}throw z}function M(z,P,te,le,xe){var ce=typeof z;(ce==="undefined"||ce==="boolean")&&(z=null);var ve=!1;if(z===null)ve=!0;else switch(ce){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(z.$$typeof){case t:case r:ve=!0;break;case y:return ve=z._init,M(ve(z._payload),P,te,le,xe)}}if(ve)return xe=xe(z),ve=le===""?"."+q(z,0):le,L(xe)?(te="",ve!=null&&(te=ve.replace(Q,"$&/")+"/"),M(xe,P,te,"",function(Ne){return Ne})):xe!=null&&(I(xe)&&(xe=_(xe,te+(xe.key==null||z&&z.key===xe.key?"":(""+xe.key).replace(Q,"$&/")+"/")+ve)),P.push(xe)),1;ve=0;var ue=le===""?".":le+":";if(L(z))for(var ye=0;ye<z.length;ye++)le=z[ye],ce=ue+q(le,ye),ve+=M(le,P,te,ce,xe);else if(ye=S(z),typeof ye=="function")for(z=ye.call(z),ye=0;!(le=z.next()).done;)le=le.value,ce=ue+q(le,ye++),ve+=M(le,P,te,ce,xe);else if(ce==="object"){if(typeof z.then=="function")return M(H(z),P,te,le,xe);throw P=String(z),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(z).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return ve}function B(z,P,te){if(z==null)return z;var le=[],xe=0;return M(z,le,"","",function(ce){return P.call(te,ce,xe++)}),le}function V(z){if(z._status===-1){var P=z._result;P=P(),P.then(function(te){(z._status===0||z._status===-1)&&(z._status=1,z._result=te)},function(te){(z._status===0||z._status===-1)&&(z._status=2,z._result=te)}),z._status===-1&&(z._status=0,z._result=P)}if(z._status===1)return z._result.default;throw z._result}var W=typeof reportError=="function"?reportError:function(z){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof z=="object"&&z!==null&&typeof z.message=="string"?String(z.message):String(z),error:z});if(!window.dispatchEvent(P))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",z);return}console.error(z)},de={map:B,forEach:function(z,P,te){B(z,function(){P.apply(this,arguments)},te)},count:function(z){var P=0;return B(z,function(){P++}),P},toArray:function(z){return B(z,function(P){return P})||[]},only:function(z){if(!I(z))throw Error("React.Children.only expected to receive a single React element child.");return z}};return Oe.Activity=v,Oe.Children=de,Oe.Component=N,Oe.Fragment=s,Oe.Profiler=c,Oe.PureComponent=D,Oe.StrictMode=o,Oe.Suspense=g,Oe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,Oe.__COMPILER_RUNTIME={__proto__:null,c:function(z){return C.H.useMemoCache(z)}},Oe.cache=function(z){return function(){return z.apply(null,arguments)}},Oe.cacheSignal=function(){return null},Oe.cloneElement=function(z,P,te){if(z==null)throw Error("The argument must be a React element, but you passed "+z+".");var le=E({},z.props),xe=z.key;if(P!=null)for(ce in P.key!==void 0&&(xe=""+P.key),P)!O.call(P,ce)||ce==="key"||ce==="__self"||ce==="__source"||ce==="ref"&&P.ref===void 0||(le[ce]=P[ce]);var ce=arguments.length-2;if(ce===1)le.children=te;else if(1<ce){for(var ve=Array(ce),ue=0;ue<ce;ue++)ve[ue]=arguments[ue+2];le.children=ve}return T(z.type,xe,le)},Oe.createContext=function(z){return z={$$typeof:f,_currentValue:z,_currentValue2:z,_threadCount:0,Provider:null,Consumer:null},z.Provider=z,z.Consumer={$$typeof:u,_context:z},z},Oe.createElement=function(z,P,te){var le,xe={},ce=null;if(P!=null)for(le in P.key!==void 0&&(ce=""+P.key),P)O.call(P,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(xe[le]=P[le]);var ve=arguments.length-2;if(ve===1)xe.children=te;else if(1<ve){for(var ue=Array(ve),ye=0;ye<ve;ye++)ue[ye]=arguments[ye+2];xe.children=ue}if(z&&z.defaultProps)for(le in ve=z.defaultProps,ve)xe[le]===void 0&&(xe[le]=ve[le]);return T(z,ce,xe)},Oe.createRef=function(){return{current:null}},Oe.forwardRef=function(z){return{$$typeof:h,render:z}},Oe.isValidElement=I,Oe.lazy=function(z){return{$$typeof:y,_payload:{_status:-1,_result:z},_init:V}},Oe.memo=function(z,P){return{$$typeof:p,type:z,compare:P===void 0?null:P}},Oe.startTransition=function(z){var P=C.T,te={};C.T=te;try{var le=z(),xe=C.S;xe!==null&&xe(te,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(F,W)}catch(ce){W(ce)}finally{P!==null&&te.types!==null&&(P.types=te.types),C.T=P}},Oe.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},Oe.use=function(z){return C.H.use(z)},Oe.useActionState=function(z,P,te){return C.H.useActionState(z,P,te)},Oe.useCallback=function(z,P){return C.H.useCallback(z,P)},Oe.useContext=function(z){return C.H.useContext(z)},Oe.useDebugValue=function(){},Oe.useDeferredValue=function(z,P){return C.H.useDeferredValue(z,P)},Oe.useEffect=function(z,P){return C.H.useEffect(z,P)},Oe.useEffectEvent=function(z){return C.H.useEffectEvent(z)},Oe.useId=function(){return C.H.useId()},Oe.useImperativeHandle=function(z,P,te){return C.H.useImperativeHandle(z,P,te)},Oe.useInsertionEffect=function(z,P){return C.H.useInsertionEffect(z,P)},Oe.useLayoutEffect=function(z,P){return C.H.useLayoutEffect(z,P)},Oe.useMemo=function(z,P){return C.H.useMemo(z,P)},Oe.useOptimistic=function(z,P){return C.H.useOptimistic(z,P)},Oe.useReducer=function(z,P,te){return C.H.useReducer(z,P,te)},Oe.useRef=function(z){return C.H.useRef(z)},Oe.useState=function(z){return C.H.useState(z)},Oe.useSyncExternalStore=function(z,P,te){return C.H.useSyncExternalStore(z,P,te)},Oe.useTransition=function(){return C.H.useTransition()},Oe.version="19.2.4",Oe}var Ex;function sf(){return Ex||(Ex=1,id.exports=Z1()),id.exports}var x=sf();const we=ev(x);var od={exports:{}},Es={},cd={exports:{}},ud={};/**
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 Cx;function J1(){return Cx||(Cx=1,(function(t){function r(M,B){var V=M.length;M.push(B);e:for(;0<V;){var W=V-1>>>1,de=M[W];if(0<c(de,B))M[W]=B,M[V]=de,V=W;else break e}}function s(M){return M.length===0?null:M[0]}function o(M){if(M.length===0)return null;var B=M[0],V=M.pop();if(V!==B){M[0]=V;e:for(var W=0,de=M.length,z=de>>>1;W<z;){var P=2*(W+1)-1,te=M[P],le=P+1,xe=M[le];if(0>c(te,V))le<de&&0>c(xe,te)?(M[W]=xe,M[le]=V,W=le):(M[W]=te,M[P]=V,W=P);else if(le<de&&0>c(xe,V))M[W]=xe,M[le]=V,W=le;else break e}}return B}function c(M,B){var V=M.sortIndex-B.sortIndex;return V!==0?V:M.id-B.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var f=Date,h=f.now();t.unstable_now=function(){return f.now()-h}}var g=[],p=[],y=1,v=null,j=3,S=!1,k=!1,E=!1,w=!1,N=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function U(M){for(var B=s(p);B!==null;){if(B.callback===null)o(p);else if(B.startTime<=M)o(p),B.sortIndex=B.expirationTime,r(g,B);else break;B=s(p)}}function L(M){if(E=!1,U(M),!k)if(s(g)!==null)k=!0,F||(F=!0,K());else{var B=s(p);B!==null&&H(L,B.startTime-M)}}var F=!1,C=-1,O=5,T=-1;function _(){return w?!0:!(t.unstable_now()-T<O)}function I(){if(w=!1,F){var M=t.unstable_now();T=M;var B=!0;try{e:{k=!1,E&&(E=!1,A(C),C=-1),S=!0;var V=j;try{t:{for(U(M),v=s(g);v!==null&&!(v.expirationTime>M&&_());){var W=v.callback;if(typeof W=="function"){v.callback=null,j=v.priorityLevel;var de=W(v.expirationTime<=M);if(M=t.unstable_now(),typeof de=="function"){v.callback=de,U(M),B=!0;break t}v===s(g)&&o(g),U(M)}else o(g);v=s(g)}if(v!==null)B=!0;else{var z=s(p);z!==null&&H(L,z.startTime-M),B=!1}}break e}finally{v=null,j=V,S=!1}B=void 0}}finally{B?K():F=!1}}}var K;if(typeof D=="function")K=function(){D(I)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,q=Q.port2;Q.port1.onmessage=I,K=function(){q.postMessage(null)}}else K=function(){N(I,0)};function H(M,B){C=N(function(){M(t.unstable_now())},B)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(M){M.callback=null},t.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<M?Math.floor(1e3/M):5},t.unstable_getCurrentPriorityLevel=function(){return j},t.unstable_next=function(M){switch(j){case 1:case 2:case 3:var B=3;break;default:B=j}var V=j;j=B;try{return M()}finally{j=V}},t.unstable_requestPaint=function(){w=!0},t.unstable_runWithPriority=function(M,B){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var V=j;j=M;try{return B()}finally{j=V}},t.unstable_scheduleCallback=function(M,B,V){var W=t.unstable_now();switch(typeof V=="object"&&V!==null?(V=V.delay,V=typeof V=="number"&&0<V?W+V:W):V=W,M){case 1:var de=-1;break;case 2:de=250;break;case 5:de=1073741823;break;case 4:de=1e4;break;default:de=5e3}return de=V+de,M={id:y++,callback:B,priorityLevel:M,startTime:V,expirationTime:de,sortIndex:-1},V>W?(M.sortIndex=V,r(p,M),s(g)===null&&M===s(p)&&(E?(A(C),C=-1):E=!0,H(L,V-W))):(M.sortIndex=de,r(g,M),k||S||(k=!0,F||(F=!0,K()))),M},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(M){var B=j;return function(){var V=j;j=B;try{return M.apply(this,arguments)}finally{j=V}}}})(ud)),ud}var Nx;function e0(){return Nx||(Nx=1,cd.exports=J1()),cd.exports}var dd={exports:{}},Xt={};/**
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 Tx;function t0(){if(Tx)return Xt;Tx=1;var t=sf();function r(g){var p="https://react.dev/errors/"+g;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)p+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,p,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:p,implementation:y}}var f=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,p){if(g==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return Xt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,Xt.createPortal=function(g,p){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(r(299));return u(g,p,null,y)},Xt.flushSync=function(g){var p=f.T,y=o.p;try{if(f.T=null,o.p=2,g)return g()}finally{f.T=p,o.p=y,o.d.f()}},Xt.preconnect=function(g,p){typeof g=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,o.d.C(g,p))},Xt.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},Xt.preinit=function(g,p){if(typeof g=="string"&&p&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin),j=typeof p.integrity=="string"?p.integrity:void 0,S=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;y==="style"?o.d.S(g,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:v,integrity:j,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:j,fetchPriority:S,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},Xt.preinitModule=function(g,p){if(typeof g=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var y=h(p.as,p.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&o.d.M(g)},Xt.preload=function(g,p){if(typeof g=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var y=p.as,v=h(y,p.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},Xt.preloadModule=function(g,p){if(typeof g=="string")if(p){var y=h(p.as,p.crossOrigin);o.d.m(g,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:y,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else o.d.m(g)},Xt.requestFormReset=function(g){o.d.r(g)},Xt.unstable_batchedUpdates=function(g,p){return g(p)},Xt.useFormState=function(g,p,y){return f.H.useFormState(g,p,y)},Xt.useFormStatus=function(){return f.H.useHostTransitionStatus()},Xt.version="19.2.4",Xt}var Rx;function tv(){if(Rx)return dd.exports;Rx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),dd.exports=t0(),dd.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 Ax;function n0(){if(Ax)return Es;Ax=1;var t=e0(),r=sf(),s=tv();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function f(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function p(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var d=l.return;if(d===null)break;var m=d.alternate;if(m===null){if(i=d.return,i!==null){l=i;continue}break}if(d.child===m.child){for(m=d.child;m;){if(m===l)return g(d),e;if(m===i)return g(d),n;m=m.sibling}throw Error(o(188))}if(l.return!==i.return)l=d,i=m;else{for(var b=!1,R=d.child;R;){if(R===l){b=!0,l=d,i=m;break}if(R===i){b=!0,i=d,l=m;break}R=R.sibling}if(!b){for(R=m.child;R;){if(R===l){b=!0,l=m,i=d;break}if(R===i){b=!0,i=m,l=d;break}R=R.sibling}if(!b)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,j=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),D=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),_=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function K(e){return e===null||typeof e!="object"?null:(e=I&&e[I]||e["@@iterator"],typeof e=="function"?e:null)}var Q=Symbol.for("react.client.reference");function q(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 E:return"Fragment";case N:return"Profiler";case w:return"StrictMode";case L:return"Suspense";case F:return"SuspenseList";case T:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case D:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case U:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case C:return n=e.displayName||null,n!==null?n:q(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return q(e(n))}catch{}}return null}var H=Array.isArray,M=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V={pending:!1,data:null,method:null,action:null},W=[],de=-1;function z(e){return{current:e}}function P(e){0>de||(e.current=W[de],W[de]=null,de--)}function te(e,n){de++,W[de]=e.current,e.current=n}var le=z(null),xe=z(null),ce=z(null),ve=z(null);function ue(e,n){switch(te(ce,n),te(xe,e),te(le,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Gh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Gh(n),e=Wh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}P(le),te(le,e)}function ye(){P(le),P(xe),P(ce)}function Ne(e){e.memoizedState!==null&&te(ve,e);var n=le.current,l=Wh(n,e.type);n!==l&&(te(xe,e),te(le,l))}function Me(e){xe.current===e&&(P(le),P(xe)),ve.current===e&&(P(ve),bs._currentValue=V)}var re,fe;function me(e){if(re===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);re=n&&n[1]||"",fe=-1<l.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+re+e+fe}var he=!1;function be(e,n){if(!e||he)return"";he=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var oe=function(){throw Error()};if(Object.defineProperty(oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(oe,[])}catch(ae){var ee=ae}Reflect.construct(e,[],oe)}else{try{oe.call()}catch(ae){ee=ae}e.call(oe.prototype)}}else{try{throw Error()}catch(ae){ee=ae}(oe=e())&&typeof oe.catch=="function"&&oe.catch(function(){})}}catch(ae){if(ae&&ee&&typeof ae.stack=="string")return[ae.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=i.DetermineComponentFrameRoot(),b=m[0],R=m[1];if(b&&R){var $=b.split(`
45
+ `),Z=R.split(`
46
+ `);for(d=i=0;i<$.length&&!$[i].includes("DetermineComponentFrameRoot");)i++;for(;d<Z.length&&!Z[d].includes("DetermineComponentFrameRoot");)d++;if(i===$.length||d===Z.length)for(i=$.length-1,d=Z.length-1;1<=i&&0<=d&&$[i]!==Z[d];)d--;for(;1<=i&&0<=d;i--,d--)if($[i]!==Z[d]){if(i!==1||d!==1)do if(i--,d--,0>d||$[i]!==Z[d]){var se=`
47
+ `+$[i].replace(" at new "," at ");return e.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",e.displayName)),se}while(1<=i&&0<=d);break}}}finally{he=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?me(l):""}function _e(e,n){switch(e.tag){case 26:case 27:case 5:return me(e.type);case 16:return me("Lazy");case 13:return e.child!==n&&n!==null?me("Suspense Fallback"):me("Suspense");case 19:return me("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return me("Activity");default:return""}}function De(e){try{var n="",l=null;do n+=_e(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
48
+ Error generating stack: `+i.message+`
49
+ `+i.stack}}var pt=Object.prototype.hasOwnProperty,_t=t.unstable_scheduleCallback,mt=t.unstable_cancelCallback,Jt=t.unstable_shouldYield,ht=t.unstable_requestPaint,Qe=t.unstable_now,xt=t.unstable_getCurrentPriorityLevel,J=t.unstable_ImmediatePriority,Te=t.unstable_UserBlockingPriority,Pe=t.unstable_NormalPriority,en=t.unstable_LowPriority,Xn=t.unstable_IdlePriority,qt=t.log,dr=t.unstable_setDisableYieldValue,Fe=null,nt=null;function wt(e){if(typeof qt=="function"&&dr(e),nt&&typeof nt.setStrictMode=="function")try{nt.setStrictMode(Fe,e)}catch{}}var dt=Math.clz32?Math.clz32:Aa,sa=Math.log,xn=Math.LN2;function Aa(e){return e>>>=0,e===0?32:31-(sa(e)/xn|0)|0}var Rt=256,Vt=262144,tn=4194304;function Tn(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ia(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var d=0,m=e.suspendedLanes,b=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~m,i!==0?d=Tn(i):(b&=R,b!==0?d=Tn(b):l||(l=R&~e,l!==0&&(d=Tn(l))))):(R=i&~m,R!==0?d=Tn(R):b!==0?d=Tn(b):l||(l=i&~e,l!==0&&(d=Tn(l)))),d===0?0:n!==0&&n!==d&&(n&m)===0&&(m=d&-d,l=n&-n,m>=l||m===32&&(l&4194048)!==0)?n:d}function Ma(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Ir(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function st(){var e=tn;return tn<<=1,(tn&62914560)===0&&(tn=4194304),e}function La(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function Rn(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qo(e,n,l,i,d,m){var b=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var R=e.entanglements,$=e.expirationTimes,Z=e.hiddenUpdates;for(l=b&~l;0<l;){var se=31-dt(l),oe=1<<se;R[se]=0,$[se]=-1;var ee=Z[se];if(ee!==null)for(Z[se]=null,se=0;se<ee.length;se++){var ae=ee[se];ae!==null&&(ae.lane&=-536870913)}l&=~oe}i!==0&&Kt(e,i,0),m!==0&&d===0&&e.tag!==0&&(e.suspendedLanes|=m&~(b&~n))}function Kt(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-dt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function Ko(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-dt(l),d=1<<i;d&n|e[i]&n&&(e[i]|=n),l&=~d}}function oa(e,n){var l=n&-n;return l=(l&42)!==0?1:Dl(l),(l&(e.suspendedLanes|n))!==0?0:l}function Dl(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 Xo(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Af(){var e=B.p;return e!==0?e:(e=window.event,e===void 0?32:hx(e.type))}function Mf(e,n){var l=B.p;try{return B.p=e,n()}finally{B.p=l}}var za=Math.random().toString(36).slice(2),Pt="__reactFiber$"+za,cn="__reactProps$"+za,Hr="__reactContainer$"+za,Qo="__reactEvents$"+za,Hy="__reactListeners$"+za,Uy="__reactHandles$"+za,Lf="__reactResources$"+za,_l="__reactMarker$"+za;function Zo(e){delete e[Pt],delete e[cn],delete e[Qo],delete e[Hy],delete e[Uy]}function Ur(e){var n=e[Pt];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Hr]||l[Pt]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=Jh(e);e!==null;){if(l=e[Pt])return l;e=Jh(e)}return n}e=l,l=e.parentNode}return null}function $r(e){if(e=e[Pt]||e[Hr]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Ol(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Vr(e){var n=e[Lf];return n||(n=e[Lf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Ut(e){e[_l]=!0}var zf=new Set,Df={};function fr(e,n){Pr(e,n),Pr(e+"Capture",n)}function Pr(e,n){for(Df[e]=n,e=0;e<n.length;e++)zf.add(n[e])}var $y=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]*$"),_f={},Of={};function Vy(e){return pt.call(Of,e)?!0:pt.call(_f,e)?!1:$y.test(e)?Of[e]=!0:(_f[e]=!0,!1)}function Qs(e,n,l){if(Vy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function Zs(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function ca(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function An(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Bf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Py(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,m=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(b){l=""+b,m.call(this,b)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(b){l=""+b},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Jo(e){if(!e._valueTracker){var n=Bf(e)?"checked":"value";e._valueTracker=Py(e,n,""+e[n])}}function If(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=Bf(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function Js(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 Fy=/[\n"\\]/g;function Mn(e){return e.replace(Fy,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function ec(e,n,l,i,d,m,b,R){e.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.type=b:e.removeAttribute("type"),n!=null?b==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+An(n)):e.value!==""+An(n)&&(e.value=""+An(n)):b!=="submit"&&b!=="reset"||e.removeAttribute("value"),n!=null?tc(e,b,An(n)):l!=null?tc(e,b,An(l)):i!=null&&e.removeAttribute("value"),d==null&&m!=null&&(e.defaultChecked=!!m),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+An(R):e.removeAttribute("name")}function Hf(e,n,l,i,d,m,b,R){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),n!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||n!=null)){Jo(e);return}l=l!=null?""+An(l):"",n=n!=null?""+An(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}i=i??d,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=R?e.checked:!!i,e.defaultChecked=!!i,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(e.name=b),Jo(e)}function tc(e,n,l){n==="number"&&Js(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Fr(e,n,l,i){if(e=e.options,n){n={};for(var d=0;d<l.length;d++)n["$"+l[d]]=!0;for(l=0;l<e.length;l++)d=n.hasOwnProperty("$"+e[l].value),e[l].selected!==d&&(e[l].selected=d),d&&i&&(e[l].defaultSelected=!0)}else{for(l=""+An(l),n=null,d=0;d<e.length;d++){if(e[d].value===l){e[d].selected=!0,i&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function Uf(e,n,l){if(n!=null&&(n=""+An(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+An(l):""}function $f(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if(H(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=An(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),Jo(e)}function Gr(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Gy=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 Vf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||Gy.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function Pf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var d in n)i=n[d],n.hasOwnProperty(d)&&l[d]!==i&&Vf(e,d,i)}else for(var m in n)n.hasOwnProperty(m)&&Vf(e,m,n[m])}function nc(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 Wy=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"]]),Yy=/^[\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 ei(e){return Yy.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ua(){}var ac=null;function rc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wr=null,Yr=null;function Ff(e){var n=$r(e);if(n&&(e=n.stateNode)){var l=e[cn]||null;e:switch(e=n.stateNode,n.type){case"input":if(ec(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Mn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var d=i[cn]||null;if(!d)throw Error(o(90));ec(i,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&If(i)}break e;case"textarea":Uf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Fr(e,!!l.multiple,n,!1)}}}var lc=!1;function Gf(e,n,l){if(lc)return e(n,l);lc=!0;try{var i=e(n);return i}finally{if(lc=!1,(Wr!==null||Yr!==null)&&($i(),Wr&&(n=Wr,e=Yr,Yr=Wr=null,Ff(n),e)))for(n=0;n<e.length;n++)Ff(e[n])}}function Bl(e,n){var l=e.stateNode;if(l===null)return null;var i=l[cn]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var da=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),sc=!1;if(da)try{var Il={};Object.defineProperty(Il,"passive",{get:function(){sc=!0}}),window.addEventListener("test",Il,Il),window.removeEventListener("test",Il,Il)}catch{sc=!1}var Da=null,ic=null,ti=null;function Wf(){if(ti)return ti;var e,n=ic,l=n.length,i,d="value"in Da?Da.value:Da.textContent,m=d.length;for(e=0;e<l&&n[e]===d[e];e++);var b=l-e;for(i=1;i<=b&&n[l-i]===d[m-i];i++);return ti=d.slice(e,1<i?1-i:void 0)}function ni(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function ai(){return!0}function Yf(){return!1}function un(e){function n(l,i,d,m,b){this._reactName=l,this._targetInst=d,this.type=i,this.nativeEvent=m,this.target=b,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(m):m[R]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?ai:Yf,this.isPropagationStopped=Yf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=ai)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=ai)},persist:function(){},isPersistent:ai}),n}var pr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ri=un(pr),Hl=v({},pr,{view:0,detail:0}),qy=un(Hl),oc,cc,Ul,li=v({},Hl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:dc,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!==Ul&&(Ul&&e.type==="mousemove"?(oc=e.screenX-Ul.screenX,cc=e.screenY-Ul.screenY):cc=oc=0,Ul=e),oc)},movementY:function(e){return"movementY"in e?e.movementY:cc}}),qf=un(li),Ky=v({},li,{dataTransfer:0}),Xy=un(Ky),Qy=v({},Hl,{relatedTarget:0}),uc=un(Qy),Zy=v({},pr,{animationName:0,elapsedTime:0,pseudoElement:0}),Jy=un(Zy),eb=v({},pr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),tb=un(eb),nb=v({},pr,{data:0}),Kf=un(nb),ab={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rb={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"},lb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=lb[e])?!!n[e]:!1}function dc(){return sb}var ib=v({},Hl,{key:function(e){if(e.key){var n=ab[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ni(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?rb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:dc,charCode:function(e){return e.type==="keypress"?ni(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ni(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),ob=un(ib),cb=v({},li,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Xf=un(cb),ub=v({},Hl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:dc}),db=un(ub),fb=v({},pr,{propertyName:0,elapsedTime:0,pseudoElement:0}),pb=un(fb),mb=v({},li,{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}),hb=un(mb),xb=v({},pr,{newState:0,oldState:0}),gb=un(xb),vb=[9,13,27,32],fc=da&&"CompositionEvent"in window,$l=null;da&&"documentMode"in document&&($l=document.documentMode);var yb=da&&"TextEvent"in window&&!$l,Qf=da&&(!fc||$l&&8<$l&&11>=$l),Zf=" ",Jf=!1;function ep(e,n){switch(e){case"keyup":return vb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function tp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var qr=!1;function bb(e,n){switch(e){case"compositionend":return tp(n);case"keypress":return n.which!==32?null:(Jf=!0,Zf);case"textInput":return e=n.data,e===Zf&&Jf?null:e;default:return null}}function jb(e,n){if(qr)return e==="compositionend"||!fc&&ep(e,n)?(e=Wf(),ti=ic=Da=null,qr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return Qf&&n.locale!=="ko"?null:n.data;default:return null}}var Sb={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 np(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Sb[e.type]:n==="textarea"}function ap(e,n,l,i){Wr?Yr?Yr.push(i):Yr=[i]:Wr=i,n=qi(n,"onChange"),0<n.length&&(l=new ri("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Vl=null,Pl=null;function kb(e){Hh(e,0)}function si(e){var n=Ol(e);if(If(n))return e}function rp(e,n){if(e==="change")return n}var lp=!1;if(da){var pc;if(da){var mc="oninput"in document;if(!mc){var sp=document.createElement("div");sp.setAttribute("oninput","return;"),mc=typeof sp.oninput=="function"}pc=mc}else pc=!1;lp=pc&&(!document.documentMode||9<document.documentMode)}function ip(){Vl&&(Vl.detachEvent("onpropertychange",op),Pl=Vl=null)}function op(e){if(e.propertyName==="value"&&si(Pl)){var n=[];ap(n,Pl,e,rc(e)),Gf(kb,n)}}function wb(e,n,l){e==="focusin"?(ip(),Vl=n,Pl=l,Vl.attachEvent("onpropertychange",op)):e==="focusout"&&ip()}function Eb(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return si(Pl)}function Cb(e,n){if(e==="click")return si(n)}function Nb(e,n){if(e==="input"||e==="change")return si(n)}function Tb(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var gn=typeof Object.is=="function"?Object.is:Tb;function Fl(e,n){if(gn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var d=l[i];if(!pt.call(n,d)||!gn(e[d],n[d]))return!1}return!0}function cp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function up(e,n){var l=cp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=cp(l)}}function dp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?dp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function fp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Js(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=Js(e.document)}return n}function hc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Rb=da&&"documentMode"in document&&11>=document.documentMode,Kr=null,xc=null,Gl=null,gc=!1;function pp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;gc||Kr==null||Kr!==Js(i)||(i=Kr,"selectionStart"in i&&hc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Gl&&Fl(Gl,i)||(Gl=i,i=qi(xc,"onSelect"),0<i.length&&(n=new ri("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=Kr)))}function mr(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var Xr={animationend:mr("Animation","AnimationEnd"),animationiteration:mr("Animation","AnimationIteration"),animationstart:mr("Animation","AnimationStart"),transitionrun:mr("Transition","TransitionRun"),transitionstart:mr("Transition","TransitionStart"),transitioncancel:mr("Transition","TransitionCancel"),transitionend:mr("Transition","TransitionEnd")},vc={},mp={};da&&(mp=document.createElement("div").style,"AnimationEvent"in window||(delete Xr.animationend.animation,delete Xr.animationiteration.animation,delete Xr.animationstart.animation),"TransitionEvent"in window||delete Xr.transitionend.transition);function hr(e){if(vc[e])return vc[e];if(!Xr[e])return e;var n=Xr[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in mp)return vc[e]=n[l];return e}var hp=hr("animationend"),xp=hr("animationiteration"),gp=hr("animationstart"),Ab=hr("transitionrun"),Mb=hr("transitionstart"),Lb=hr("transitioncancel"),vp=hr("transitionend"),yp=new Map,yc="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(" ");yc.push("scrollEnd");function Pn(e,n){yp.set(e,n),fr(n,[e])}var ii=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Ln=[],Qr=0,bc=0;function oi(){for(var e=Qr,n=bc=Qr=0;n<e;){var l=Ln[n];Ln[n++]=null;var i=Ln[n];Ln[n++]=null;var d=Ln[n];Ln[n++]=null;var m=Ln[n];if(Ln[n++]=null,i!==null&&d!==null){var b=i.pending;b===null?d.next=d:(d.next=b.next,b.next=d),i.pending=d}m!==0&&bp(l,d,m)}}function ci(e,n,l,i){Ln[Qr++]=e,Ln[Qr++]=n,Ln[Qr++]=l,Ln[Qr++]=i,bc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function jc(e,n,l,i){return ci(e,n,l,i),ui(e)}function xr(e,n){return ci(e,null,null,n),ui(e)}function bp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var d=!1,m=e.return;m!==null;)m.childLanes|=l,i=m.alternate,i!==null&&(i.childLanes|=l),m.tag===22&&(e=m.stateNode,e===null||e._visibility&1||(d=!0)),e=m,m=m.return;return e.tag===3?(m=e.stateNode,d&&n!==null&&(d=31-dt(l),e=m.hiddenUpdates,i=e[d],i===null?e[d]=[n]:i.push(n),n.lane=l|536870912),m):null}function ui(e){if(50<ps)throw ps=0,Au=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Zr={};function zb(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vn(e,n,l,i){return new zb(e,n,l,i)}function Sc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function fa(e,n){var l=e.alternate;return l===null?(l=vn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function jp(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function di(e,n,l,i,d,m){var b=0;if(i=e,typeof e=="function")Sc(e)&&(b=1);else if(typeof e=="string")b=I1(e,l,le.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case T:return e=vn(31,l,n,d),e.elementType=T,e.lanes=m,e;case E:return gr(l.children,d,m,n);case w:b=8,d|=24;break;case N:return e=vn(12,l,n,d|2),e.elementType=N,e.lanes=m,e;case L:return e=vn(13,l,n,d),e.elementType=L,e.lanes=m,e;case F:return e=vn(19,l,n,d),e.elementType=F,e.lanes=m,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case D:b=10;break e;case A:b=9;break e;case U:b=11;break e;case C:b=14;break e;case O:b=16,i=null;break e}b=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=vn(b,l,n,d),n.elementType=e,n.type=i,n.lanes=m,n}function gr(e,n,l,i){return e=vn(7,e,i,n),e.lanes=l,e}function kc(e,n,l){return e=vn(6,e,null,n),e.lanes=l,e}function Sp(e){var n=vn(18,null,null,0);return n.stateNode=e,n}function wc(e,n,l){return n=vn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var kp=new WeakMap;function zn(e,n){if(typeof e=="object"&&e!==null){var l=kp.get(e);return l!==void 0?l:(n={value:e,source:n,stack:De(n)},kp.set(e,n),n)}return{value:e,source:n,stack:De(n)}}var Jr=[],el=0,fi=null,Wl=0,Dn=[],_n=0,_a=null,Qn=1,Zn="";function pa(e,n){Jr[el++]=Wl,Jr[el++]=fi,fi=e,Wl=n}function wp(e,n,l){Dn[_n++]=Qn,Dn[_n++]=Zn,Dn[_n++]=_a,_a=e;var i=Qn;e=Zn;var d=32-dt(i)-1;i&=~(1<<d),l+=1;var m=32-dt(n)+d;if(30<m){var b=d-d%5;m=(i&(1<<b)-1).toString(32),i>>=b,d-=b,Qn=1<<32-dt(n)+d|l<<d|i,Zn=m+e}else Qn=1<<m|l<<d|i,Zn=e}function Ec(e){e.return!==null&&(pa(e,1),wp(e,1,0))}function Cc(e){for(;e===fi;)fi=Jr[--el],Jr[el]=null,Wl=Jr[--el],Jr[el]=null;for(;e===_a;)_a=Dn[--_n],Dn[_n]=null,Zn=Dn[--_n],Dn[_n]=null,Qn=Dn[--_n],Dn[_n]=null}function Ep(e,n){Dn[_n++]=Qn,Dn[_n++]=Zn,Dn[_n++]=_a,Qn=n.id,Zn=n.overflow,_a=e}var Ft=null,gt=null,Ke=!1,Oa=null,On=!1,Nc=Error(o(519));function Ba(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Yl(zn(n,e)),Nc}function Cp(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[Pt]=e,n[cn]=i,l){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(l=0;l<hs.length;l++)We(hs[l],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Hf(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),$f(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||Ph(n.textContent,l)?(i.popover!=null&&(We("beforetoggle",n),We("toggle",n)),i.onScroll!=null&&We("scroll",n),i.onScrollEnd!=null&&We("scrollend",n),i.onClick!=null&&(n.onclick=ua),n=!0):n=!1,n||Ba(e,!0)}function Np(e){for(Ft=e.return;Ft;)switch(Ft.tag){case 5:case 31:case 13:On=!1;return;case 27:case 3:On=!0;return;default:Ft=Ft.return}}function tl(e){if(e!==Ft)return!1;if(!Ke)return Np(e),Ke=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Gu(e.type,e.memoizedProps)),l=!l),l&&gt&&Ba(e),Np(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));gt=Zh(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));gt=Zh(e)}else n===27?(n=gt,Qa(e.type)?(e=Xu,Xu=null,gt=e):gt=n):gt=Ft?In(e.stateNode.nextSibling):null;return!0}function vr(){gt=Ft=null,Ke=!1}function Tc(){var e=Oa;return e!==null&&(mn===null?mn=e:mn.push.apply(mn,e),Oa=null),e}function Yl(e){Oa===null?Oa=[e]:Oa.push(e)}var Rc=z(null),yr=null,ma=null;function Ia(e,n,l){te(Rc,n._currentValue),n._currentValue=l}function ha(e){e._currentValue=Rc.current,P(Rc)}function Ac(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function Mc(e,n,l,i){var d=e.child;for(d!==null&&(d.return=e);d!==null;){var m=d.dependencies;if(m!==null){var b=d.child;m=m.firstContext;e:for(;m!==null;){var R=m;m=d;for(var $=0;$<n.length;$++)if(R.context===n[$]){m.lanes|=l,R=m.alternate,R!==null&&(R.lanes|=l),Ac(m.return,l,e),i||(b=null);break e}m=R.next}}else if(d.tag===18){if(b=d.return,b===null)throw Error(o(341));b.lanes|=l,m=b.alternate,m!==null&&(m.lanes|=l),Ac(b,l,e),b=null}else b=d.child;if(b!==null)b.return=d;else for(b=d;b!==null;){if(b===e){b=null;break}if(d=b.sibling,d!==null){d.return=b.return,b=d;break}b=b.return}d=b}}function nl(e,n,l,i){e=null;for(var d=n,m=!1;d!==null;){if(!m){if((d.flags&524288)!==0)m=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var b=d.alternate;if(b===null)throw Error(o(387));if(b=b.memoizedProps,b!==null){var R=d.type;gn(d.pendingProps.value,b.value)||(e!==null?e.push(R):e=[R])}}else if(d===ve.current){if(b=d.alternate,b===null)throw Error(o(387));b.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(e!==null?e.push(bs):e=[bs])}d=d.return}e!==null&&Mc(n,e,l,i),n.flags|=262144}function pi(e){for(e=e.firstContext;e!==null;){if(!gn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function br(e){yr=e,ma=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gt(e){return Tp(yr,e)}function mi(e,n){return yr===null&&br(e),Tp(e,n)}function Tp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},ma===null){if(e===null)throw Error(o(308));ma=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else ma=ma.next=n;return l}var Db=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},_b=t.unstable_scheduleCallback,Ob=t.unstable_NormalPriority,At={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Lc(){return{controller:new Db,data:new Map,refCount:0}}function ql(e){e.refCount--,e.refCount===0&&_b(Ob,function(){e.controller.abort()})}var Kl=null,zc=0,al=0,rl=null;function Bb(e,n){if(Kl===null){var l=Kl=[];zc=0,al=Ou(),rl={status:"pending",value:void 0,then:function(i){l.push(i)}}}return zc++,n.then(Rp,Rp),n}function Rp(){if(--zc===0&&Kl!==null){rl!==null&&(rl.status="fulfilled");var e=Kl;Kl=null,al=0,rl=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Ib(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(d){l.push(d)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var d=0;d<l.length;d++)(0,l[d])(n)},function(d){for(i.status="rejected",i.reason=d,d=0;d<l.length;d++)(0,l[d])(void 0)}),i}var Ap=M.S;M.S=function(e,n){ph=Qe(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Bb(e,n),Ap!==null&&Ap(e,n)};var jr=z(null);function Dc(){var e=jr.current;return e!==null?e:ft.pooledCache}function hi(e,n){n===null?te(jr,jr.current):te(jr,n.pool)}function Mp(){var e=Dc();return e===null?null:{parent:At._currentValue,pool:e}}var ll=Error(o(460)),_c=Error(o(474)),xi=Error(o(542)),gi={then:function(){}};function Lp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function zp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(ua,ua),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,_p(e),e;default:if(typeof n.status=="string")n.then(ua,ua);else{if(e=ft,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var d=n;d.status="fulfilled",d.value=i}},function(i){if(n.status==="pending"){var d=n;d.status="rejected",d.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,_p(e),e}throw kr=n,ll}}function Sr(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(kr=l,ll):l}}var kr=null;function Dp(){if(kr===null)throw Error(o(459));var e=kr;return kr=null,e}function _p(e){if(e===ll||e===xi)throw Error(o(483))}var sl=null,Xl=0;function vi(e){var n=Xl;return Xl+=1,sl===null&&(sl=[]),zp(sl,e,n)}function Ql(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function yi(e,n){throw n.$$typeof===j?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Op(e){function n(Y,G){if(e){var X=Y.deletions;X===null?(Y.deletions=[G],Y.flags|=16):X.push(G)}}function l(Y,G){if(!e)return null;for(;G!==null;)n(Y,G),G=G.sibling;return null}function i(Y){for(var G=new Map;Y!==null;)Y.key!==null?G.set(Y.key,Y):G.set(Y.index,Y),Y=Y.sibling;return G}function d(Y,G){return Y=fa(Y,G),Y.index=0,Y.sibling=null,Y}function m(Y,G,X){return Y.index=X,e?(X=Y.alternate,X!==null?(X=X.index,X<G?(Y.flags|=67108866,G):X):(Y.flags|=67108866,G)):(Y.flags|=1048576,G)}function b(Y){return e&&Y.alternate===null&&(Y.flags|=67108866),Y}function R(Y,G,X,ie){return G===null||G.tag!==6?(G=kc(X,Y.mode,ie),G.return=Y,G):(G=d(G,X),G.return=Y,G)}function $(Y,G,X,ie){var Re=X.type;return Re===E?se(Y,G,X.props.children,ie,X.key):G!==null&&(G.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===O&&Sr(Re)===G.type)?(G=d(G,X.props),Ql(G,X),G.return=Y,G):(G=di(X.type,X.key,X.props,null,Y.mode,ie),Ql(G,X),G.return=Y,G)}function Z(Y,G,X,ie){return G===null||G.tag!==4||G.stateNode.containerInfo!==X.containerInfo||G.stateNode.implementation!==X.implementation?(G=wc(X,Y.mode,ie),G.return=Y,G):(G=d(G,X.children||[]),G.return=Y,G)}function se(Y,G,X,ie,Re){return G===null||G.tag!==7?(G=gr(X,Y.mode,ie,Re),G.return=Y,G):(G=d(G,X),G.return=Y,G)}function oe(Y,G,X){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=kc(""+G,Y.mode,X),G.return=Y,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return X=di(G.type,G.key,G.props,null,Y.mode,X),Ql(X,G),X.return=Y,X;case k:return G=wc(G,Y.mode,X),G.return=Y,G;case O:return G=Sr(G),oe(Y,G,X)}if(H(G)||K(G))return G=gr(G,Y.mode,X,null),G.return=Y,G;if(typeof G.then=="function")return oe(Y,vi(G),X);if(G.$$typeof===D)return oe(Y,mi(Y,G),X);yi(Y,G)}return null}function ee(Y,G,X,ie){var Re=G!==null?G.key:null;if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return Re!==null?null:R(Y,G,""+X,ie);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case S:return X.key===Re?$(Y,G,X,ie):null;case k:return X.key===Re?Z(Y,G,X,ie):null;case O:return X=Sr(X),ee(Y,G,X,ie)}if(H(X)||K(X))return Re!==null?null:se(Y,G,X,ie,null);if(typeof X.then=="function")return ee(Y,G,vi(X),ie);if(X.$$typeof===D)return ee(Y,G,mi(Y,X),ie);yi(Y,X)}return null}function ae(Y,G,X,ie,Re){if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Y=Y.get(X)||null,R(G,Y,""+ie,Re);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case S:return Y=Y.get(ie.key===null?X:ie.key)||null,$(G,Y,ie,Re);case k:return Y=Y.get(ie.key===null?X:ie.key)||null,Z(G,Y,ie,Re);case O:return ie=Sr(ie),ae(Y,G,X,ie,Re)}if(H(ie)||K(ie))return Y=Y.get(X)||null,se(G,Y,ie,Re,null);if(typeof ie.then=="function")return ae(Y,G,X,vi(ie),Re);if(ie.$$typeof===D)return ae(Y,G,X,mi(G,ie),Re);yi(G,ie)}return null}function Se(Y,G,X,ie){for(var Re=null,Ze=null,ke=G,He=G=0,qe=null;ke!==null&&He<X.length;He++){ke.index>He?(qe=ke,ke=null):qe=ke.sibling;var Je=ee(Y,ke,X[He],ie);if(Je===null){ke===null&&(ke=qe);break}e&&ke&&Je.alternate===null&&n(Y,ke),G=m(Je,G,He),Ze===null?Re=Je:Ze.sibling=Je,Ze=Je,ke=qe}if(He===X.length)return l(Y,ke),Ke&&pa(Y,He),Re;if(ke===null){for(;He<X.length;He++)ke=oe(Y,X[He],ie),ke!==null&&(G=m(ke,G,He),Ze===null?Re=ke:Ze.sibling=ke,Ze=ke);return Ke&&pa(Y,He),Re}for(ke=i(ke);He<X.length;He++)qe=ae(ke,Y,He,X[He],ie),qe!==null&&(e&&qe.alternate!==null&&ke.delete(qe.key===null?He:qe.key),G=m(qe,G,He),Ze===null?Re=qe:Ze.sibling=qe,Ze=qe);return e&&ke.forEach(function(nr){return n(Y,nr)}),Ke&&pa(Y,He),Re}function Ae(Y,G,X,ie){if(X==null)throw Error(o(151));for(var Re=null,Ze=null,ke=G,He=G=0,qe=null,Je=X.next();ke!==null&&!Je.done;He++,Je=X.next()){ke.index>He?(qe=ke,ke=null):qe=ke.sibling;var nr=ee(Y,ke,Je.value,ie);if(nr===null){ke===null&&(ke=qe);break}e&&ke&&nr.alternate===null&&n(Y,ke),G=m(nr,G,He),Ze===null?Re=nr:Ze.sibling=nr,Ze=nr,ke=qe}if(Je.done)return l(Y,ke),Ke&&pa(Y,He),Re;if(ke===null){for(;!Je.done;He++,Je=X.next())Je=oe(Y,Je.value,ie),Je!==null&&(G=m(Je,G,He),Ze===null?Re=Je:Ze.sibling=Je,Ze=Je);return Ke&&pa(Y,He),Re}for(ke=i(ke);!Je.done;He++,Je=X.next())Je=ae(ke,Y,He,Je.value,ie),Je!==null&&(e&&Je.alternate!==null&&ke.delete(Je.key===null?He:Je.key),G=m(Je,G,He),Ze===null?Re=Je:Ze.sibling=Je,Ze=Je);return e&&ke.forEach(function(K1){return n(Y,K1)}),Ke&&pa(Y,He),Re}function ct(Y,G,X,ie){if(typeof X=="object"&&X!==null&&X.type===E&&X.key===null&&(X=X.props.children),typeof X=="object"&&X!==null){switch(X.$$typeof){case S:e:{for(var Re=X.key;G!==null;){if(G.key===Re){if(Re=X.type,Re===E){if(G.tag===7){l(Y,G.sibling),ie=d(G,X.props.children),ie.return=Y,Y=ie;break e}}else if(G.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===O&&Sr(Re)===G.type){l(Y,G.sibling),ie=d(G,X.props),Ql(ie,X),ie.return=Y,Y=ie;break e}l(Y,G);break}else n(Y,G);G=G.sibling}X.type===E?(ie=gr(X.props.children,Y.mode,ie,X.key),ie.return=Y,Y=ie):(ie=di(X.type,X.key,X.props,null,Y.mode,ie),Ql(ie,X),ie.return=Y,Y=ie)}return b(Y);case k:e:{for(Re=X.key;G!==null;){if(G.key===Re)if(G.tag===4&&G.stateNode.containerInfo===X.containerInfo&&G.stateNode.implementation===X.implementation){l(Y,G.sibling),ie=d(G,X.children||[]),ie.return=Y,Y=ie;break e}else{l(Y,G);break}else n(Y,G);G=G.sibling}ie=wc(X,Y.mode,ie),ie.return=Y,Y=ie}return b(Y);case O:return X=Sr(X),ct(Y,G,X,ie)}if(H(X))return Se(Y,G,X,ie);if(K(X)){if(Re=K(X),typeof Re!="function")throw Error(o(150));return X=Re.call(X),Ae(Y,G,X,ie)}if(typeof X.then=="function")return ct(Y,G,vi(X),ie);if(X.$$typeof===D)return ct(Y,G,mi(Y,X),ie);yi(Y,X)}return typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint"?(X=""+X,G!==null&&G.tag===6?(l(Y,G.sibling),ie=d(G,X),ie.return=Y,Y=ie):(l(Y,G),ie=kc(X,Y.mode,ie),ie.return=Y,Y=ie),b(Y)):l(Y,G)}return function(Y,G,X,ie){try{Xl=0;var Re=ct(Y,G,X,ie);return sl=null,Re}catch(ke){if(ke===ll||ke===xi)throw ke;var Ze=vn(29,ke,null,Y.mode);return Ze.lanes=ie,Ze.return=Y,Ze}finally{}}}var wr=Op(!0),Bp=Op(!1),Ha=!1;function Oc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Bc(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ua(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function $a(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(tt&2)!==0){var d=i.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),i.pending=n,n=ui(e),bp(e,null,l),n}return ci(e,i,n,l),ui(e)}function Zl(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,Ko(e,l)}}function Ic(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var b={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=b:m=m.next=b,l=l.next}while(l!==null);m===null?d=m=n:m=m.next=n}else d=m=n;l={baseState:i.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var Hc=!1;function Jl(){if(Hc){var e=rl;if(e!==null)throw e}}function es(e,n,l,i){Hc=!1;var d=e.updateQueue;Ha=!1;var m=d.firstBaseUpdate,b=d.lastBaseUpdate,R=d.shared.pending;if(R!==null){d.shared.pending=null;var $=R,Z=$.next;$.next=null,b===null?m=Z:b.next=Z,b=$;var se=e.alternate;se!==null&&(se=se.updateQueue,R=se.lastBaseUpdate,R!==b&&(R===null?se.firstBaseUpdate=Z:R.next=Z,se.lastBaseUpdate=$))}if(m!==null){var oe=d.baseState;b=0,se=Z=$=null,R=m;do{var ee=R.lane&-536870913,ae=ee!==R.lane;if(ae?(Ye&ee)===ee:(i&ee)===ee){ee!==0&&ee===al&&(Hc=!0),se!==null&&(se=se.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var Se=e,Ae=R;ee=n;var ct=l;switch(Ae.tag){case 1:if(Se=Ae.payload,typeof Se=="function"){oe=Se.call(ct,oe,ee);break e}oe=Se;break e;case 3:Se.flags=Se.flags&-65537|128;case 0:if(Se=Ae.payload,ee=typeof Se=="function"?Se.call(ct,oe,ee):Se,ee==null)break e;oe=v({},oe,ee);break e;case 2:Ha=!0}}ee=R.callback,ee!==null&&(e.flags|=64,ae&&(e.flags|=8192),ae=d.callbacks,ae===null?d.callbacks=[ee]:ae.push(ee))}else ae={lane:ee,tag:R.tag,payload:R.payload,callback:R.callback,next:null},se===null?(Z=se=ae,$=oe):se=se.next=ae,b|=ee;if(R=R.next,R===null){if(R=d.shared.pending,R===null)break;ae=R,R=ae.next,ae.next=null,d.lastBaseUpdate=ae,d.shared.pending=null}}while(!0);se===null&&($=oe),d.baseState=$,d.firstBaseUpdate=Z,d.lastBaseUpdate=se,m===null&&(d.shared.lanes=0),Wa|=b,e.lanes=b,e.memoizedState=oe}}function Ip(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Hp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Ip(l[e],n)}var il=z(null),bi=z(0);function Up(e,n){e=wa,te(bi,e),te(il,n),wa=e|n.baseLanes}function Uc(){te(bi,wa),te(il,il.current)}function $c(){wa=bi.current,P(il),P(bi)}var yn=z(null),Bn=null;function Va(e){var n=e.alternate;te(Nt,Nt.current&1),te(yn,e),Bn===null&&(n===null||il.current!==null||n.memoizedState!==null)&&(Bn=e)}function Vc(e){te(Nt,Nt.current),te(yn,e),Bn===null&&(Bn=e)}function $p(e){e.tag===22?(te(Nt,Nt.current),te(yn,e),Bn===null&&(Bn=e)):Pa()}function Pa(){te(Nt,Nt.current),te(yn,yn.current)}function bn(e){P(yn),Bn===e&&(Bn=null),P(Nt)}var Nt=z(0);function ji(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||qu(l)||Ku(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var xa=0,Ie=null,it=null,Mt=null,Si=!1,ol=!1,Er=!1,ki=0,ts=0,cl=null,Hb=0;function Et(){throw Error(o(321))}function Pc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!gn(e[l],n[l]))return!1;return!0}function Fc(e,n,l,i,d,m){return xa=m,Ie=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,M.H=e===null||e.memoizedState===null?wm:lu,Er=!1,m=l(i,d),Er=!1,ol&&(m=Pp(n,l,i,d)),Vp(e),m}function Vp(e){M.H=rs;var n=it!==null&&it.next!==null;if(xa=0,Mt=it=Ie=null,Si=!1,ts=0,cl=null,n)throw Error(o(300));e===null||Lt||(e=e.dependencies,e!==null&&pi(e)&&(Lt=!0))}function Pp(e,n,l,i){Ie=e;var d=0;do{if(ol&&(cl=null),ts=0,ol=!1,25<=d)throw Error(o(301));if(d+=1,Mt=it=null,e.updateQueue!=null){var m=e.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}M.H=Em,m=n(l,i)}while(ol);return m}function Ub(){var e=M.H,n=e.useState()[0];return n=typeof n.then=="function"?ns(n):n,e=e.useState()[0],(it!==null?it.memoizedState:null)!==e&&(Ie.flags|=1024),n}function Gc(){var e=ki!==0;return ki=0,e}function Wc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Yc(e){if(Si){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Si=!1}xa=0,Mt=it=Ie=null,ol=!1,ts=ki=0,cl=null}function nn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Mt===null?Ie.memoizedState=Mt=e:Mt=Mt.next=e,Mt}function Tt(){if(it===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=it.next;var n=Mt===null?Ie.memoizedState:Mt.next;if(n!==null)Mt=n,it=e;else{if(e===null)throw Ie.alternate===null?Error(o(467)):Error(o(310));it=e,e={memoizedState:it.memoizedState,baseState:it.baseState,baseQueue:it.baseQueue,queue:it.queue,next:null},Mt===null?Ie.memoizedState=Mt=e:Mt=Mt.next=e}return Mt}function wi(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ns(e){var n=ts;return ts+=1,cl===null&&(cl=[]),e=zp(cl,e,n),n=Ie,(Mt===null?n.memoizedState:Mt.next)===null&&(n=n.alternate,M.H=n===null||n.memoizedState===null?wm:lu),e}function Ei(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ns(e);if(e.$$typeof===D)return Gt(e)}throw Error(o(438,String(e)))}function qc(e){var n=null,l=Ie.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=Ie.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(d){return d.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=wi(),Ie.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=_;return n.index++,l}function ga(e,n){return typeof n=="function"?n(e):n}function Ci(e){var n=Tt();return Kc(n,it,e)}function Kc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var d=e.baseQueue,m=i.pending;if(m!==null){if(d!==null){var b=d.next;d.next=m.next,m.next=b}n.baseQueue=d=m,i.pending=null}if(m=e.baseState,d===null)e.memoizedState=m;else{n=d.next;var R=b=null,$=null,Z=n,se=!1;do{var oe=Z.lane&-536870913;if(oe!==Z.lane?(Ye&oe)===oe:(xa&oe)===oe){var ee=Z.revertLane;if(ee===0)$!==null&&($=$.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),oe===al&&(se=!0);else if((xa&ee)===ee){Z=Z.next,ee===al&&(se=!0);continue}else oe={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},$===null?(R=$=oe,b=m):$=$.next=oe,Ie.lanes|=ee,Wa|=ee;oe=Z.action,Er&&l(m,oe),m=Z.hasEagerState?Z.eagerState:l(m,oe)}else ee={lane:oe,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},$===null?(R=$=ee,b=m):$=$.next=ee,Ie.lanes|=oe,Wa|=oe;Z=Z.next}while(Z!==null&&Z!==n);if($===null?b=m:$.next=R,!gn(m,e.memoizedState)&&(Lt=!0,se&&(l=rl,l!==null)))throw l;e.memoizedState=m,e.baseState=b,e.baseQueue=$,i.lastRenderedState=m}return d===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Xc(e){var n=Tt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,d=l.pending,m=n.memoizedState;if(d!==null){l.pending=null;var b=d=d.next;do m=e(m,b.action),b=b.next;while(b!==d);gn(m,n.memoizedState)||(Lt=!0),n.memoizedState=m,n.baseQueue===null&&(n.baseState=m),l.lastRenderedState=m}return[m,i]}function Fp(e,n,l){var i=Ie,d=Tt(),m=Ke;if(m){if(l===void 0)throw Error(o(407));l=l()}else l=n();var b=!gn((it||d).memoizedState,l);if(b&&(d.memoizedState=l,Lt=!0),d=d.queue,Jc(Yp.bind(null,i,d,e),[e]),d.getSnapshot!==n||b||Mt!==null&&Mt.memoizedState.tag&1){if(i.flags|=2048,ul(9,{destroy:void 0},Wp.bind(null,i,d,l,n),null),ft===null)throw Error(o(349));m||(xa&127)!==0||Gp(i,n,l)}return l}function Gp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Ie.updateQueue,n===null?(n=wi(),Ie.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Wp(e,n,l,i){n.value=l,n.getSnapshot=i,qp(n)&&Kp(e)}function Yp(e,n,l){return l(function(){qp(n)&&Kp(e)})}function qp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!gn(e,l)}catch{return!0}}function Kp(e){var n=xr(e,2);n!==null&&hn(n,e,2)}function Qc(e){var n=nn();if(typeof e=="function"){var l=e;if(e=l(),Er){wt(!0);try{l()}finally{wt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ga,lastRenderedState:e},n}function Xp(e,n,l,i){return e.baseState=l,Kc(e,it,typeof i=="function"?i:ga)}function $b(e,n,l,i,d){if(Ri(e))throw Error(o(485));if(e=n.action,e!==null){var m={payload:d,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){m.listeners.push(b)}};M.T!==null?l(!0):m.isTransition=!1,i(m),l=n.pending,l===null?(m.next=n.pending=m,Qp(n,m)):(m.next=l.next,n.pending=l.next=m)}}function Qp(e,n){var l=n.action,i=n.payload,d=e.state;if(n.isTransition){var m=M.T,b={};M.T=b;try{var R=l(d,i),$=M.S;$!==null&&$(b,R),Zp(e,n,R)}catch(Z){Zc(e,n,Z)}finally{m!==null&&b.types!==null&&(m.types=b.types),M.T=m}}else try{m=l(d,i),Zp(e,n,m)}catch(Z){Zc(e,n,Z)}}function Zp(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){Jp(e,n,i)},function(i){return Zc(e,n,i)}):Jp(e,n,l)}function Jp(e,n,l){n.status="fulfilled",n.value=l,em(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,Qp(e,l)))}function Zc(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,em(n),n=n.next;while(n!==i)}e.action=null}function em(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function tm(e,n){return n}function nm(e,n){if(Ke){var l=ft.formState;if(l!==null){e:{var i=Ie;if(Ke){if(gt){t:{for(var d=gt,m=On;d.nodeType!==8;){if(!m){d=null;break t}if(d=In(d.nextSibling),d===null){d=null;break t}}m=d.data,d=m==="F!"||m==="F"?d:null}if(d){gt=In(d.nextSibling),i=d.data==="F!";break e}}Ba(i)}i=!1}i&&(n=l[0])}}return l=nn(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:tm,lastRenderedState:n},l.queue=i,l=jm.bind(null,Ie,i),i.dispatch=l,i=Qc(!1),m=ru.bind(null,Ie,!1,i.queue),i=nn(),d={state:n,dispatch:null,action:e,pending:null},i.queue=d,l=$b.bind(null,Ie,d,m,l),d.dispatch=l,i.memoizedState=e,[n,l,!1]}function am(e){var n=Tt();return rm(n,it,e)}function rm(e,n,l){if(n=Kc(e,n,tm)[0],e=Ci(ga)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=ns(n)}catch(b){throw b===ll?xi:b}else i=n;n=Tt();var d=n.queue,m=d.dispatch;return l!==n.memoizedState&&(Ie.flags|=2048,ul(9,{destroy:void 0},Vb.bind(null,d,l),null)),[i,m,e]}function Vb(e,n){e.action=n}function lm(e){var n=Tt(),l=it;if(l!==null)return rm(n,l,e);Tt(),n=n.memoizedState,l=Tt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function ul(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=Ie.updateQueue,n===null&&(n=wi(),Ie.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function sm(){return Tt().memoizedState}function Ni(e,n,l,i){var d=nn();Ie.flags|=e,d.memoizedState=ul(1|n,{destroy:void 0},l,i===void 0?null:i)}function Ti(e,n,l,i){var d=Tt();i=i===void 0?null:i;var m=d.memoizedState.inst;it!==null&&i!==null&&Pc(i,it.memoizedState.deps)?d.memoizedState=ul(n,m,l,i):(Ie.flags|=e,d.memoizedState=ul(1|n,m,l,i))}function im(e,n){Ni(8390656,8,e,n)}function Jc(e,n){Ti(2048,8,e,n)}function Pb(e){Ie.flags|=4;var n=Ie.updateQueue;if(n===null)n=wi(),Ie.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function om(e){var n=Tt().memoizedState;return Pb({ref:n,nextImpl:e}),function(){if((tt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function cm(e,n){return Ti(4,2,e,n)}function um(e,n){return Ti(4,4,e,n)}function dm(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function fm(e,n,l){l=l!=null?l.concat([e]):null,Ti(4,4,dm.bind(null,n,e),l)}function eu(){}function pm(e,n){var l=Tt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&Pc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function mm(e,n){var l=Tt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&Pc(n,i[1]))return i[0];if(i=e(),Er){wt(!0);try{e()}finally{wt(!1)}}return l.memoizedState=[i,n],i}function tu(e,n,l){return l===void 0||(xa&1073741824)!==0&&(Ye&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=hh(),Ie.lanes|=e,Wa|=e,l)}function hm(e,n,l,i){return gn(l,n)?l:il.current!==null?(e=tu(e,l,i),gn(e,n)||(Lt=!0),e):(xa&42)===0||(xa&1073741824)!==0&&(Ye&261930)===0?(Lt=!0,e.memoizedState=l):(e=hh(),Ie.lanes|=e,Wa|=e,n)}function xm(e,n,l,i,d){var m=B.p;B.p=m!==0&&8>m?m:8;var b=M.T,R={};M.T=R,ru(e,!1,n,l);try{var $=d(),Z=M.S;if(Z!==null&&Z(R,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var se=Ib($,i);as(e,n,se,kn(e))}else as(e,n,i,kn(e))}catch(oe){as(e,n,{then:function(){},status:"rejected",reason:oe},kn())}finally{B.p=m,b!==null&&R.types!==null&&(b.types=R.types),M.T=b}}function Fb(){}function nu(e,n,l,i){if(e.tag!==5)throw Error(o(476));var d=gm(e).queue;xm(e,d,n,V,l===null?Fb:function(){return vm(e),l(i)})}function gm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ga,lastRenderedState:V},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ga,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function vm(e){var n=gm(e);n.next===null&&(n=e.alternate.memoizedState),as(e,n.next.queue,{},kn())}function au(){return Gt(bs)}function ym(){return Tt().memoizedState}function bm(){return Tt().memoizedState}function Gb(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=kn();e=Ua(l);var i=$a(n,e,l);i!==null&&(hn(i,n,l),Zl(i,n,l)),n={cache:Lc()},e.payload=n;return}n=n.return}}function Wb(e,n,l){var i=kn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Ri(e)?Sm(n,l):(l=jc(e,n,l,i),l!==null&&(hn(l,e,i),km(l,n,i)))}function jm(e,n,l){var i=kn();as(e,n,l,i)}function as(e,n,l,i){var d={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Ri(e))Sm(n,d);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=n.lastRenderedReducer,m!==null))try{var b=n.lastRenderedState,R=m(b,l);if(d.hasEagerState=!0,d.eagerState=R,gn(R,b))return ci(e,n,d,0),ft===null&&oi(),!1}catch{}finally{}if(l=jc(e,n,d,i),l!==null)return hn(l,e,i),km(l,n,i),!0}return!1}function ru(e,n,l,i){if(i={lane:2,revertLane:Ou(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Ri(e)){if(n)throw Error(o(479))}else n=jc(e,l,i,2),n!==null&&hn(n,e,2)}function Ri(e){var n=e.alternate;return e===Ie||n!==null&&n===Ie}function Sm(e,n){ol=Si=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function km(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,Ko(e,l)}}var rs={readContext:Gt,use:Ei,useCallback:Et,useContext:Et,useEffect:Et,useImperativeHandle:Et,useLayoutEffect:Et,useInsertionEffect:Et,useMemo:Et,useReducer:Et,useRef:Et,useState:Et,useDebugValue:Et,useDeferredValue:Et,useTransition:Et,useSyncExternalStore:Et,useId:Et,useHostTransitionStatus:Et,useFormState:Et,useActionState:Et,useOptimistic:Et,useMemoCache:Et,useCacheRefresh:Et};rs.useEffectEvent=Et;var wm={readContext:Gt,use:Ei,useCallback:function(e,n){return nn().memoizedState=[e,n===void 0?null:n],e},useContext:Gt,useEffect:im,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Ni(4194308,4,dm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Ni(4194308,4,e,n)},useInsertionEffect:function(e,n){Ni(4,2,e,n)},useMemo:function(e,n){var l=nn();n=n===void 0?null:n;var i=e();if(Er){wt(!0);try{e()}finally{wt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=nn();if(l!==void 0){var d=l(n);if(Er){wt(!0);try{l(n)}finally{wt(!1)}}}else d=n;return i.memoizedState=i.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},i.queue=e,e=e.dispatch=Wb.bind(null,Ie,e),[i.memoizedState,e]},useRef:function(e){var n=nn();return e={current:e},n.memoizedState=e},useState:function(e){e=Qc(e);var n=e.queue,l=jm.bind(null,Ie,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:eu,useDeferredValue:function(e,n){var l=nn();return tu(l,e,n)},useTransition:function(){var e=Qc(!1);return e=xm.bind(null,Ie,e.queue,!0,!1),nn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=Ie,d=nn();if(Ke){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),ft===null)throw Error(o(349));(Ye&127)!==0||Gp(i,n,l)}d.memoizedState=l;var m={value:l,getSnapshot:n};return d.queue=m,im(Yp.bind(null,i,m,e),[e]),i.flags|=2048,ul(9,{destroy:void 0},Wp.bind(null,i,m,l,n),null),l},useId:function(){var e=nn(),n=ft.identifierPrefix;if(Ke){var l=Zn,i=Qn;l=(i&~(1<<32-dt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=ki++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=Hb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:au,useFormState:nm,useActionState:nm,useOptimistic:function(e){var n=nn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=ru.bind(null,Ie,!0,l),l.dispatch=n,[e,n]},useMemoCache:qc,useCacheRefresh:function(){return nn().memoizedState=Gb.bind(null,Ie)},useEffectEvent:function(e){var n=nn(),l={impl:e};return n.memoizedState=l,function(){if((tt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},lu={readContext:Gt,use:Ei,useCallback:pm,useContext:Gt,useEffect:Jc,useImperativeHandle:fm,useInsertionEffect:cm,useLayoutEffect:um,useMemo:mm,useReducer:Ci,useRef:sm,useState:function(){return Ci(ga)},useDebugValue:eu,useDeferredValue:function(e,n){var l=Tt();return hm(l,it.memoizedState,e,n)},useTransition:function(){var e=Ci(ga)[0],n=Tt().memoizedState;return[typeof e=="boolean"?e:ns(e),n]},useSyncExternalStore:Fp,useId:ym,useHostTransitionStatus:au,useFormState:am,useActionState:am,useOptimistic:function(e,n){var l=Tt();return Xp(l,it,e,n)},useMemoCache:qc,useCacheRefresh:bm};lu.useEffectEvent=om;var Em={readContext:Gt,use:Ei,useCallback:pm,useContext:Gt,useEffect:Jc,useImperativeHandle:fm,useInsertionEffect:cm,useLayoutEffect:um,useMemo:mm,useReducer:Xc,useRef:sm,useState:function(){return Xc(ga)},useDebugValue:eu,useDeferredValue:function(e,n){var l=Tt();return it===null?tu(l,e,n):hm(l,it.memoizedState,e,n)},useTransition:function(){var e=Xc(ga)[0],n=Tt().memoizedState;return[typeof e=="boolean"?e:ns(e),n]},useSyncExternalStore:Fp,useId:ym,useHostTransitionStatus:au,useFormState:lm,useActionState:lm,useOptimistic:function(e,n){var l=Tt();return it!==null?Xp(l,it,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:qc,useCacheRefresh:bm};Em.useEffectEvent=om;function su(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var iu={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=kn(),d=Ua(i);d.payload=n,l!=null&&(d.callback=l),n=$a(e,d,i),n!==null&&(hn(n,e,i),Zl(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=kn(),d=Ua(i);d.tag=1,d.payload=n,l!=null&&(d.callback=l),n=$a(e,d,i),n!==null&&(hn(n,e,i),Zl(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=kn(),i=Ua(l);i.tag=2,n!=null&&(i.callback=n),n=$a(e,i,l),n!==null&&(hn(n,e,l),Zl(n,e,l))}};function Cm(e,n,l,i,d,m,b){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,m,b):n.prototype&&n.prototype.isPureReactComponent?!Fl(l,i)||!Fl(d,m):!0}function Nm(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&iu.enqueueReplaceState(n,n.state,null)}function Cr(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var d in e)l[d]===void 0&&(l[d]=e[d])}return l}function Tm(e){ii(e)}function Rm(e){console.error(e)}function Am(e){ii(e)}function Ai(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function Mm(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function ou(e,n,l){return l=Ua(l),l.tag=3,l.payload={element:null},l.callback=function(){Ai(e,n)},l}function Lm(e){return e=Ua(e),e.tag=3,e}function zm(e,n,l,i){var d=l.type.getDerivedStateFromError;if(typeof d=="function"){var m=i.value;e.payload=function(){return d(m)},e.callback=function(){Mm(n,l,i)}}var b=l.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(e.callback=function(){Mm(n,l,i),typeof d!="function"&&(Ya===null?Ya=new Set([this]):Ya.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function Yb(e,n,l,i,d){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&nl(n,l,d,!0),l=yn.current,l!==null){switch(l.tag){case 31:case 13:return Bn===null?Vi():l.alternate===null&&Ct===0&&(Ct=3),l.flags&=-257,l.flags|=65536,l.lanes=d,i===gi?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),zu(e,i,d)),!1;case 22:return l.flags|=65536,i===gi?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),zu(e,i,d)),!1}throw Error(o(435,l.tag))}return zu(e,i,d),Vi(),!1}if(Ke)return n=yn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=d,i!==Nc&&(e=Error(o(422),{cause:i}),Yl(zn(e,l)))):(i!==Nc&&(n=Error(o(423),{cause:i}),Yl(zn(n,l))),e=e.current.alternate,e.flags|=65536,d&=-d,e.lanes|=d,i=zn(i,l),d=ou(e.stateNode,i,d),Ic(e,d),Ct!==4&&(Ct=2)),!1;var m=Error(o(520),{cause:i});if(m=zn(m,l),fs===null?fs=[m]:fs.push(m),Ct!==4&&(Ct=2),n===null)return!0;i=zn(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=d&-d,l.lanes|=e,e=ou(l.stateNode,i,e),Ic(l,e),!1;case 1:if(n=l.type,m=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Ya===null||!Ya.has(m))))return l.flags|=65536,d&=-d,l.lanes|=d,d=Lm(d),zm(d,e,l,i),Ic(l,d),!1}l=l.return}while(l!==null);return!1}var cu=Error(o(461)),Lt=!1;function Wt(e,n,l,i){n.child=e===null?Bp(n,null,l,i):wr(n,e.child,l,i)}function Dm(e,n,l,i,d){l=l.render;var m=n.ref;if("ref"in i){var b={};for(var R in i)R!=="ref"&&(b[R]=i[R])}else b=i;return br(n),i=Fc(e,n,l,b,m,d),R=Gc(),e!==null&&!Lt?(Wc(e,n,d),va(e,n,d)):(Ke&&R&&Ec(n),n.flags|=1,Wt(e,n,i,d),n.child)}function _m(e,n,l,i,d){if(e===null){var m=l.type;return typeof m=="function"&&!Sc(m)&&m.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=m,Om(e,n,m,i,d)):(e=di(l.type,null,i,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(m=e.child,!gu(e,d)){var b=m.memoizedProps;if(l=l.compare,l=l!==null?l:Fl,l(b,i)&&e.ref===n.ref)return va(e,n,d)}return n.flags|=1,e=fa(m,i),e.ref=n.ref,e.return=n,n.child=e}function Om(e,n,l,i,d){if(e!==null){var m=e.memoizedProps;if(Fl(m,i)&&e.ref===n.ref)if(Lt=!1,n.pendingProps=i=m,gu(e,d))(e.flags&131072)!==0&&(Lt=!0);else return n.lanes=e.lanes,va(e,n,d)}return uu(e,n,l,i,d)}function Bm(e,n,l,i){var d=i.children,m=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(m=m!==null?m.baseLanes|l:l,e!==null){for(i=n.child=e.child,d=0;i!==null;)d=d|i.lanes|i.childLanes,i=i.sibling;i=d&~m}else i=0,n.child=null;return Im(e,n,m,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&hi(n,m!==null?m.cachePool:null),m!==null?Up(n,m):Uc(),$p(n);else return i=n.lanes=536870912,Im(e,n,m!==null?m.baseLanes|l:l,l,i)}else m!==null?(hi(n,m.cachePool),Up(n,m),Pa(),n.memoizedState=null):(e!==null&&hi(n,null),Uc(),Pa());return Wt(e,n,d,l),n.child}function ls(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Im(e,n,l,i,d){var m=Dc();return m=m===null?null:{parent:At._currentValue,pool:m},n.memoizedState={baseLanes:l,cachePool:m},e!==null&&hi(n,null),Uc(),$p(n),e!==null&&nl(e,n,i,!0),n.childLanes=d,null}function Mi(e,n){return n=zi({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Hm(e,n,l){return wr(n,e.child,null,l),e=Mi(n,n.pendingProps),e.flags|=2,bn(n),n.memoizedState=null,e}function qb(e,n,l){var i=n.pendingProps,d=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Ke){if(i.mode==="hidden")return e=Mi(n,i),n.lanes=536870912,ls(null,e);if(Vc(n),(e=gt)?(e=Qh(e,On),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:_a!==null?{id:Qn,overflow:Zn}:null,retryLane:536870912,hydrationErrors:null},l=Sp(e),l.return=n,n.child=l,Ft=n,gt=null)):e=null,e===null)throw Ba(n);return n.lanes=536870912,null}return Mi(n,i)}var m=e.memoizedState;if(m!==null){var b=m.dehydrated;if(Vc(n),d)if(n.flags&256)n.flags&=-257,n=Hm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(Lt||nl(e,n,l,!1),d=(l&e.childLanes)!==0,Lt||d){if(i=ft,i!==null&&(b=oa(i,l),b!==0&&b!==m.retryLane))throw m.retryLane=b,xr(e,b),hn(i,e,b),cu;Vi(),n=Hm(e,n,l)}else e=m.treeContext,gt=In(b.nextSibling),Ft=n,Ke=!0,Oa=null,On=!1,e!==null&&Ep(n,e),n=Mi(n,i),n.flags|=4096;return n}return e=fa(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Li(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function uu(e,n,l,i,d){return br(n),l=Fc(e,n,l,i,void 0,d),i=Gc(),e!==null&&!Lt?(Wc(e,n,d),va(e,n,d)):(Ke&&i&&Ec(n),n.flags|=1,Wt(e,n,l,d),n.child)}function Um(e,n,l,i,d,m){return br(n),n.updateQueue=null,l=Pp(n,i,l,d),Vp(e),i=Gc(),e!==null&&!Lt?(Wc(e,n,m),va(e,n,m)):(Ke&&i&&Ec(n),n.flags|=1,Wt(e,n,l,m),n.child)}function $m(e,n,l,i,d){if(br(n),n.stateNode===null){var m=Zr,b=l.contextType;typeof b=="object"&&b!==null&&(m=Gt(b)),m=new l(i,m),n.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=iu,n.stateNode=m,m._reactInternals=n,m=n.stateNode,m.props=i,m.state=n.memoizedState,m.refs={},Oc(n),b=l.contextType,m.context=typeof b=="object"&&b!==null?Gt(b):Zr,m.state=n.memoizedState,b=l.getDerivedStateFromProps,typeof b=="function"&&(su(n,l,b,i),m.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(b=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),b!==m.state&&iu.enqueueReplaceState(m,m.state,null),es(n,i,m,d),Jl(),m.state=n.memoizedState),typeof m.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){m=n.stateNode;var R=n.memoizedProps,$=Cr(l,R);m.props=$;var Z=m.context,se=l.contextType;b=Zr,typeof se=="object"&&se!==null&&(b=Gt(se));var oe=l.getDerivedStateFromProps;se=typeof oe=="function"||typeof m.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,se||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(R||Z!==b)&&Nm(n,m,i,b),Ha=!1;var ee=n.memoizedState;m.state=ee,es(n,i,m,d),Jl(),Z=n.memoizedState,R||ee!==Z||Ha?(typeof oe=="function"&&(su(n,l,oe,i),Z=n.memoizedState),($=Ha||Cm(n,l,$,i,ee,Z,b))?(se||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(n.flags|=4194308)):(typeof m.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),m.props=i,m.state=Z,m.context=b,i=$):(typeof m.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{m=n.stateNode,Bc(e,n),b=n.memoizedProps,se=Cr(l,b),m.props=se,oe=n.pendingProps,ee=m.context,Z=l.contextType,$=Zr,typeof Z=="object"&&Z!==null&&($=Gt(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(b!==oe||ee!==$)&&Nm(n,m,i,$),Ha=!1,ee=n.memoizedState,m.state=ee,es(n,i,m,d),Jl();var ae=n.memoizedState;b!==oe||ee!==ae||Ha||e!==null&&e.dependencies!==null&&pi(e.dependencies)?(typeof R=="function"&&(su(n,l,R,i),ae=n.memoizedState),(se=Ha||Cm(n,l,se,i,ee,ae,$)||e!==null&&e.dependencies!==null&&pi(e.dependencies))?(Z||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(i,ae,$),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(i,ae,$)),typeof m.componentDidUpdate=="function"&&(n.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof m.componentDidUpdate!="function"||b===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=ae),m.props=i,m.state=ae,m.context=$,i=se):(typeof m.componentDidUpdate!="function"||b===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return m=i,Li(e,n),i=(n.flags&128)!==0,m||i?(m=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:m.render(),n.flags|=1,e!==null&&i?(n.child=wr(n,e.child,null,d),n.child=wr(n,null,l,d)):Wt(e,n,l,d),n.memoizedState=m.state,e=n.child):e=va(e,n,d),e}function Vm(e,n,l,i){return vr(),n.flags|=256,Wt(e,n,l,i),n.child}var du={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function fu(e){return{baseLanes:e,cachePool:Mp()}}function pu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=Sn),e}function Pm(e,n,l){var i=n.pendingProps,d=!1,m=(n.flags&128)!==0,b;if((b=m)||(b=e!==null&&e.memoizedState===null?!1:(Nt.current&2)!==0),b&&(d=!0,n.flags&=-129),b=(n.flags&32)!==0,n.flags&=-33,e===null){if(Ke){if(d?Va(n):Pa(),(e=gt)?(e=Qh(e,On),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:_a!==null?{id:Qn,overflow:Zn}:null,retryLane:536870912,hydrationErrors:null},l=Sp(e),l.return=n,n.child=l,Ft=n,gt=null)):e=null,e===null)throw Ba(n);return Ku(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,d?(Pa(),d=n.mode,R=zi({mode:"hidden",children:R},d),i=gr(i,d,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=fu(l),i.childLanes=pu(e,b,l),n.memoizedState=du,ls(null,i)):(Va(n),mu(n,R))}var $=e.memoizedState;if($!==null&&(R=$.dehydrated,R!==null)){if(m)n.flags&256?(Va(n),n.flags&=-257,n=hu(e,n,l)):n.memoizedState!==null?(Pa(),n.child=e.child,n.flags|=128,n=null):(Pa(),R=i.fallback,d=n.mode,i=zi({mode:"visible",children:i.children},d),R=gr(R,d,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,wr(n,e.child,null,l),i=n.child,i.memoizedState=fu(l),i.childLanes=pu(e,b,l),n.memoizedState=du,n=ls(null,i));else if(Va(n),Ku(R)){if(b=R.nextSibling&&R.nextSibling.dataset,b)var Z=b.dgst;b=Z,i=Error(o(419)),i.stack="",i.digest=b,Yl({value:i,source:null,stack:null}),n=hu(e,n,l)}else if(Lt||nl(e,n,l,!1),b=(l&e.childLanes)!==0,Lt||b){if(b=ft,b!==null&&(i=oa(b,l),i!==0&&i!==$.retryLane))throw $.retryLane=i,xr(e,i),hn(b,e,i),cu;qu(R)||Vi(),n=hu(e,n,l)}else qu(R)?(n.flags|=192,n.child=e.child,n=null):(e=$.treeContext,gt=In(R.nextSibling),Ft=n,Ke=!0,Oa=null,On=!1,e!==null&&Ep(n,e),n=mu(n,i.children),n.flags|=4096);return n}return d?(Pa(),R=i.fallback,d=n.mode,$=e.child,Z=$.sibling,i=fa($,{mode:"hidden",children:i.children}),i.subtreeFlags=$.subtreeFlags&65011712,Z!==null?R=fa(Z,R):(R=gr(R,d,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,ls(null,i),i=n.child,R=e.child.memoizedState,R===null?R=fu(l):(d=R.cachePool,d!==null?($=At._currentValue,d=d.parent!==$?{parent:$,pool:$}:d):d=Mp(),R={baseLanes:R.baseLanes|l,cachePool:d}),i.memoizedState=R,i.childLanes=pu(e,b,l),n.memoizedState=du,ls(e.child,i)):(Va(n),l=e.child,e=l.sibling,l=fa(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(b=n.deletions,b===null?(n.deletions=[e],n.flags|=16):b.push(e)),n.child=l,n.memoizedState=null,l)}function mu(e,n){return n=zi({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function zi(e,n){return e=vn(22,e,null,n),e.lanes=0,e}function hu(e,n,l){return wr(n,e.child,null,l),e=mu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Fm(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),Ac(e.return,n,l)}function xu(e,n,l,i,d,m){var b=e.memoizedState;b===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:d,treeForkCount:m}:(b.isBackwards=n,b.rendering=null,b.renderingStartTime=0,b.last=i,b.tail=l,b.tailMode=d,b.treeForkCount=m)}function Gm(e,n,l){var i=n.pendingProps,d=i.revealOrder,m=i.tail;i=i.children;var b=Nt.current,R=(b&2)!==0;if(R?(b=b&1|2,n.flags|=128):b&=1,te(Nt,b),Wt(e,n,i,l),i=Ke?Wl:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Fm(e,l,n);else if(e.tag===19)Fm(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(d){case"forwards":for(l=n.child,d=null;l!==null;)e=l.alternate,e!==null&&ji(e)===null&&(d=l),l=l.sibling;l=d,l===null?(d=n.child,n.child=null):(d=l.sibling,l.sibling=null),xu(n,!1,d,l,m,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&ji(e)===null){n.child=d;break}e=d.sibling,d.sibling=l,l=d,d=e}xu(n,!0,l,null,m,i);break;case"together":xu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function va(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),Wa|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(nl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=fa(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=fa(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function gu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&pi(e)))}function Kb(e,n,l){switch(n.tag){case 3:ue(n,n.stateNode.containerInfo),Ia(n,At,e.memoizedState.cache),vr();break;case 27:case 5:Ne(n);break;case 4:ue(n,n.stateNode.containerInfo);break;case 10:Ia(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Vc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Va(n),n.flags|=128,null):(l&n.child.childLanes)!==0?Pm(e,n,l):(Va(n),e=va(e,n,l),e!==null?e.sibling:null);Va(n);break;case 19:var d=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(nl(e,n,l,!1),i=(l&n.childLanes)!==0),d){if(i)return Gm(e,n,l);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),te(Nt,Nt.current),i)break;return null;case 22:return n.lanes=0,Bm(e,n,l,n.pendingProps);case 24:Ia(n,At,e.memoizedState.cache)}return va(e,n,l)}function Wm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Lt=!0;else{if(!gu(e,l)&&(n.flags&128)===0)return Lt=!1,Kb(e,n,l);Lt=(e.flags&131072)!==0}else Lt=!1,Ke&&(n.flags&1048576)!==0&&wp(n,Wl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Sr(n.elementType),n.type=e,typeof e=="function")Sc(e)?(i=Cr(e,i),n.tag=1,n=$m(null,n,e,i,l)):(n.tag=0,n=uu(null,n,e,i,l));else{if(e!=null){var d=e.$$typeof;if(d===U){n.tag=11,n=Dm(null,n,e,i,l);break e}else if(d===C){n.tag=14,n=_m(null,n,e,i,l);break e}}throw n=q(e)||e,Error(o(306,n,""))}}return n;case 0:return uu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,d=Cr(i,n.pendingProps),$m(e,n,i,d,l);case 3:e:{if(ue(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var m=n.memoizedState;d=m.element,Bc(e,n),es(n,i,null,l);var b=n.memoizedState;if(i=b.cache,Ia(n,At,i),i!==m.cache&&Mc(n,[At],l,!0),Jl(),i=b.element,m.isDehydrated)if(m={element:i,isDehydrated:!1,cache:b.cache},n.updateQueue.baseState=m,n.memoizedState=m,n.flags&256){n=Vm(e,n,i,l);break e}else if(i!==d){d=zn(Error(o(424)),n),Yl(d),n=Vm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(gt=In(e.firstChild),Ft=n,Ke=!0,Oa=null,On=!0,l=Bp(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(vr(),i===d){n=va(e,n,l);break e}Wt(e,n,i,l)}n=n.child}return n;case 26:return Li(e,n),e===null?(l=ax(n.type,null,n.pendingProps,null))?n.memoizedState=l:Ke||(l=n.type,e=n.pendingProps,i=Ki(ce.current).createElement(l),i[Pt]=n,i[cn]=e,Yt(i,l,e),Ut(i),n.stateNode=i):n.memoizedState=ax(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Ne(n),e===null&&Ke&&(i=n.stateNode=ex(n.type,n.pendingProps,ce.current),Ft=n,On=!0,d=gt,Qa(n.type)?(Xu=d,gt=In(i.firstChild)):gt=d),Wt(e,n,n.pendingProps.children,l),Li(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Ke&&((d=i=gt)&&(i=E1(i,n.type,n.pendingProps,On),i!==null?(n.stateNode=i,Ft=n,gt=In(i.firstChild),On=!1,d=!0):d=!1),d||Ba(n)),Ne(n),d=n.type,m=n.pendingProps,b=e!==null?e.memoizedProps:null,i=m.children,Gu(d,m)?i=null:b!==null&&Gu(d,b)&&(n.flags|=32),n.memoizedState!==null&&(d=Fc(e,n,Ub,null,null,l),bs._currentValue=d),Li(e,n),Wt(e,n,i,l),n.child;case 6:return e===null&&Ke&&((e=l=gt)&&(l=C1(l,n.pendingProps,On),l!==null?(n.stateNode=l,Ft=n,gt=null,e=!0):e=!1),e||Ba(n)),null;case 13:return Pm(e,n,l);case 4:return ue(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=wr(n,null,i,l):Wt(e,n,i,l),n.child;case 11:return Dm(e,n,n.type,n.pendingProps,l);case 7:return Wt(e,n,n.pendingProps,l),n.child;case 8:return Wt(e,n,n.pendingProps.children,l),n.child;case 12:return Wt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ia(n,n.type,i.value),Wt(e,n,i.children,l),n.child;case 9:return d=n.type._context,i=n.pendingProps.children,br(n),d=Gt(d),i=i(d),n.flags|=1,Wt(e,n,i,l),n.child;case 14:return _m(e,n,n.type,n.pendingProps,l);case 15:return Om(e,n,n.type,n.pendingProps,l);case 19:return Gm(e,n,l);case 31:return qb(e,n,l);case 22:return Bm(e,n,l,n.pendingProps);case 24:return br(n),i=Gt(At),e===null?(d=Dc(),d===null&&(d=ft,m=Lc(),d.pooledCache=m,m.refCount++,m!==null&&(d.pooledCacheLanes|=l),d=m),n.memoizedState={parent:i,cache:d},Oc(n),Ia(n,At,d)):((e.lanes&l)!==0&&(Bc(e,n),es(n,null,null,l),Jl()),d=e.memoizedState,m=n.memoizedState,d.parent!==i?(d={parent:i,cache:i},n.memoizedState=d,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=d),Ia(n,At,i)):(i=m.cache,Ia(n,At,i),i!==d.cache&&Mc(n,[At],l,!0))),Wt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function ya(e){e.flags|=4}function vu(e,n,l,i,d){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(d&335544128)===d)if(e.stateNode.complete)e.flags|=8192;else if(yh())e.flags|=8192;else throw kr=gi,_c}else e.flags&=-16777217}function Ym(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!ox(n))if(yh())e.flags|=8192;else throw kr=gi,_c}function Di(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?st():536870912,e.lanes|=n,ml|=n)}function ss(e,n){if(!Ke)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function vt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var d=e.child;d!==null;)l|=d.lanes|d.childLanes,i|=d.subtreeFlags&65011712,i|=d.flags&65011712,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)l|=d.lanes|d.childLanes,i|=d.subtreeFlags,i|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function Xb(e,n,l){var i=n.pendingProps;switch(Cc(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vt(n),null;case 1:return vt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),ha(At),ye(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(tl(n)?ya(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Tc())),vt(n),null;case 26:var d=n.type,m=n.memoizedState;return e===null?(ya(n),m!==null?(vt(n),Ym(n,m)):(vt(n),vu(n,d,null,i,l))):m?m!==e.memoizedState?(ya(n),vt(n),Ym(n,m)):(vt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&ya(n),vt(n),vu(n,d,e,i,l)),null;case 27:if(Me(n),l=ce.current,d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&ya(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return vt(n),null}e=le.current,tl(n)?Cp(n):(e=ex(d,i,l),n.stateNode=e,ya(n))}return vt(n),null;case 5:if(Me(n),d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&ya(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return vt(n),null}if(m=le.current,tl(n))Cp(n);else{var b=Ki(ce.current);switch(m){case 1:m=b.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:m=b.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":m=b.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":m=b.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":m=b.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof i.is=="string"?b.createElement("select",{is:i.is}):b.createElement("select"),i.multiple?m.multiple=!0:i.size&&(m.size=i.size);break;default:m=typeof i.is=="string"?b.createElement(d,{is:i.is}):b.createElement(d)}}m[Pt]=n,m[cn]=i;e:for(b=n.child;b!==null;){if(b.tag===5||b.tag===6)m.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===n)break e;for(;b.sibling===null;){if(b.return===null||b.return===n)break e;b=b.return}b.sibling.return=b.return,b=b.sibling}n.stateNode=m;e:switch(Yt(m,d,i),d){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&ya(n)}}return vt(n),vu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&ya(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=ce.current,tl(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,d=Ft,d!==null)switch(d.tag){case 27:case 5:i=d.memoizedProps}e[Pt]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Ph(e.nodeValue,l)),e||Ba(n,!0)}else e=Ki(e).createTextNode(i),e[Pt]=n,n.stateNode=e}return vt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=tl(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[Pt]=n}else vr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;vt(n),e=!1}else l=Tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(bn(n),n):(bn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return vt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=tl(n),i!==null&&i.dehydrated!==null){if(e===null){if(!d)throw Error(o(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(o(317));d[Pt]=n}else vr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;vt(n),d=!1}else d=Tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(bn(n),n):(bn(n),null)}return bn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,d=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(d=i.alternate.memoizedState.cachePool.pool),m=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(m=i.memoizedState.cachePool.pool),m!==d&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Di(n,n.updateQueue),vt(n),null);case 4:return ye(),e===null&&Uu(n.stateNode.containerInfo),vt(n),null;case 10:return ha(n.type),vt(n),null;case 19:if(P(Nt),i=n.memoizedState,i===null)return vt(n),null;if(d=(n.flags&128)!==0,m=i.rendering,m===null)if(d)ss(i,!1);else{if(Ct!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(m=ji(e),m!==null){for(n.flags|=128,ss(i,!1),e=m.updateQueue,n.updateQueue=e,Di(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)jp(l,e),l=l.sibling;return te(Nt,Nt.current&1|2),Ke&&pa(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Qe()>Hi&&(n.flags|=128,d=!0,ss(i,!1),n.lanes=4194304)}else{if(!d)if(e=ji(m),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,Di(n,e),ss(i,!0),i.tail===null&&i.tailMode==="hidden"&&!m.alternate&&!Ke)return vt(n),null}else 2*Qe()-i.renderingStartTime>Hi&&l!==536870912&&(n.flags|=128,d=!0,ss(i,!1),n.lanes=4194304);i.isBackwards?(m.sibling=n.child,n.child=m):(e=i.last,e!==null?e.sibling=m:n.child=m,i.last=m)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Qe(),e.sibling=null,l=Nt.current,te(Nt,d?l&1|2:l&1),Ke&&pa(n,i.treeForkCount),e):(vt(n),null);case 22:case 23:return bn(n),$c(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(vt(n),n.subtreeFlags&6&&(n.flags|=8192)):vt(n),l=n.updateQueue,l!==null&&Di(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&P(jr),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),ha(At),vt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function Qb(e,n){switch(Cc(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ha(At),ye(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Me(n),null;case 31:if(n.memoizedState!==null){if(bn(n),n.alternate===null)throw Error(o(340));vr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(bn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));vr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return P(Nt),null;case 4:return ye(),null;case 10:return ha(n.type),null;case 22:case 23:return bn(n),$c(),e!==null&&P(jr),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ha(At),null;case 25:return null;default:return null}}function qm(e,n){switch(Cc(n),n.tag){case 3:ha(At),ye();break;case 26:case 27:case 5:Me(n);break;case 4:ye();break;case 31:n.memoizedState!==null&&bn(n);break;case 13:bn(n);break;case 19:P(Nt);break;case 10:ha(n.type);break;case 22:case 23:bn(n),$c(),e!==null&&P(jr);break;case 24:ha(At)}}function is(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var d=i.next;l=d;do{if((l.tag&e)===e){i=void 0;var m=l.create,b=l.inst;i=m(),b.destroy=i}l=l.next}while(l!==d)}}catch(R){lt(n,n.return,R)}}function Fa(e,n,l){try{var i=n.updateQueue,d=i!==null?i.lastEffect:null;if(d!==null){var m=d.next;i=m;do{if((i.tag&e)===e){var b=i.inst,R=b.destroy;if(R!==void 0){b.destroy=void 0,d=n;var $=l,Z=R;try{Z()}catch(se){lt(d,$,se)}}}i=i.next}while(i!==m)}}catch(se){lt(n,n.return,se)}}function Km(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Hp(n,l)}catch(i){lt(e,e.return,i)}}}function Xm(e,n,l){l.props=Cr(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){lt(e,n,i)}}function os(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(d){lt(e,n,d)}}function Jn(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(d){lt(e,n,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){lt(e,n,d)}else l.current=null}function Qm(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(d){lt(e,e.return,d)}}function yu(e,n,l){try{var i=e.stateNode;y1(i,e.type,l,n),i[cn]=n}catch(d){lt(e,e.return,d)}}function Zm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Qa(e.type)||e.tag===4}function bu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Zm(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&&Qa(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 ju(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=ua));else if(i!==4&&(i===27&&Qa(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(ju(e,n,l),e=e.sibling;e!==null;)ju(e,n,l),e=e.sibling}function _i(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Qa(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(_i(e,n,l),e=e.sibling;e!==null;)_i(e,n,l),e=e.sibling}function Jm(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);Yt(n,i,l),n[Pt]=e,n[cn]=l}catch(m){lt(e,e.return,m)}}var ba=!1,zt=!1,Su=!1,eh=typeof WeakSet=="function"?WeakSet:Set,$t=null;function Zb(e,n){if(e=e.containerInfo,Pu=no,e=fp(e),hc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var d=i.anchorOffset,m=i.focusNode;i=i.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var b=0,R=-1,$=-1,Z=0,se=0,oe=e,ee=null;t:for(;;){for(var ae;oe!==l||d!==0&&oe.nodeType!==3||(R=b+d),oe!==m||i!==0&&oe.nodeType!==3||($=b+i),oe.nodeType===3&&(b+=oe.nodeValue.length),(ae=oe.firstChild)!==null;)ee=oe,oe=ae;for(;;){if(oe===e)break t;if(ee===l&&++Z===d&&(R=b),ee===m&&++se===i&&($=b),(ae=oe.nextSibling)!==null)break;oe=ee,ee=oe.parentNode}oe=ae}l=R===-1||$===-1?null:{start:R,end:$}}else l=null}l=l||{start:0,end:0}}else l=null;for(Fu={focusedElem:e,selectionRange:l},no=!1,$t=n;$t!==null;)if(n=$t,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,$t=e;else for(;$t!==null;){switch(n=$t,m=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)d=e[l],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&m!==null){e=void 0,l=n,d=m.memoizedProps,m=m.memoizedState,i=l.stateNode;try{var Se=Cr(l.type,d);e=i.getSnapshotBeforeUpdate(Se,m),i.__reactInternalSnapshotBeforeUpdate=e}catch(Ae){lt(l,l.return,Ae)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Yu(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Yu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,$t=e;break}$t=n.return}}function th(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Sa(e,l),i&4&&is(5,l);break;case 1:if(Sa(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(b){lt(l,l.return,b)}else{var d=Cr(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(d,n,e.__reactInternalSnapshotBeforeUpdate)}catch(b){lt(l,l.return,b)}}i&64&&Km(l),i&512&&os(l,l.return);break;case 3:if(Sa(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Hp(e,n)}catch(b){lt(l,l.return,b)}}break;case 27:n===null&&i&4&&Jm(l);case 26:case 5:Sa(e,l),n===null&&i&4&&Qm(l),i&512&&os(l,l.return);break;case 12:Sa(e,l);break;case 31:Sa(e,l),i&4&&rh(e,l);break;case 13:Sa(e,l),i&4&&lh(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=i1.bind(null,l),N1(e,l))));break;case 22:if(i=l.memoizedState!==null||ba,!i){n=n!==null&&n.memoizedState!==null||zt,d=ba;var m=zt;ba=i,(zt=n)&&!m?ka(e,l,(l.subtreeFlags&8772)!==0):Sa(e,l),ba=d,zt=m}break;case 30:break;default:Sa(e,l)}}function nh(e){var n=e.alternate;n!==null&&(e.alternate=null,nh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&Zo(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var jt=null,dn=!1;function ja(e,n,l){for(l=l.child;l!==null;)ah(e,n,l),l=l.sibling}function ah(e,n,l){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(Fe,l)}catch{}switch(l.tag){case 26:zt||Jn(l,n),ja(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:zt||Jn(l,n);var i=jt,d=dn;Qa(l.type)&&(jt=l.stateNode,dn=!1),ja(e,n,l),gs(l.stateNode),jt=i,dn=d;break;case 5:zt||Jn(l,n);case 6:if(i=jt,d=dn,jt=null,ja(e,n,l),jt=i,dn=d,jt!==null)if(dn)try{(jt.nodeType===9?jt.body:jt.nodeName==="HTML"?jt.ownerDocument.body:jt).removeChild(l.stateNode)}catch(m){lt(l,n,m)}else try{jt.removeChild(l.stateNode)}catch(m){lt(l,n,m)}break;case 18:jt!==null&&(dn?(e=jt,Kh(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Sl(e)):Kh(jt,l.stateNode));break;case 4:i=jt,d=dn,jt=l.stateNode.containerInfo,dn=!0,ja(e,n,l),jt=i,dn=d;break;case 0:case 11:case 14:case 15:Fa(2,l,n),zt||Fa(4,l,n),ja(e,n,l);break;case 1:zt||(Jn(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&Xm(l,n,i)),ja(e,n,l);break;case 21:ja(e,n,l);break;case 22:zt=(i=zt)||l.memoizedState!==null,ja(e,n,l),zt=i;break;default:ja(e,n,l)}}function rh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Sl(e)}catch(l){lt(n,n.return,l)}}}function lh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Sl(e)}catch(l){lt(n,n.return,l)}}function Jb(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new eh),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new eh),n;default:throw Error(o(435,e.tag))}}function Oi(e,n){var l=Jb(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var d=o1.bind(null,e,i);i.then(d,d)}})}function fn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var d=l[i],m=e,b=n,R=b;e:for(;R!==null;){switch(R.tag){case 27:if(Qa(R.type)){jt=R.stateNode,dn=!1;break e}break;case 5:jt=R.stateNode,dn=!1;break e;case 3:case 4:jt=R.stateNode.containerInfo,dn=!0;break e}R=R.return}if(jt===null)throw Error(o(160));ah(m,b,d),jt=null,dn=!1,m=d.alternate,m!==null&&(m.return=null),d.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)sh(n,e),n=n.sibling}var Fn=null;function sh(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fn(n,e),pn(e),i&4&&(Fa(3,e,e.return),is(3,e),Fa(5,e,e.return));break;case 1:fn(n,e),pn(e),i&512&&(zt||l===null||Jn(l,l.return)),i&64&&ba&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var d=Fn;if(fn(n,e),pn(e),i&512&&(zt||l===null||Jn(l,l.return)),i&4){var m=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,d=d.ownerDocument||d;t:switch(i){case"title":m=d.getElementsByTagName("title")[0],(!m||m[_l]||m[Pt]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=d.createElement(i),d.head.insertBefore(m,d.querySelector("head > title"))),Yt(m,i,l),m[Pt]=e,Ut(m),i=m;break e;case"link":var b=sx("link","href",d).get(i+(l.href||""));if(b){for(var R=0;R<b.length;R++)if(m=b[R],m.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&m.getAttribute("rel")===(l.rel==null?null:l.rel)&&m.getAttribute("title")===(l.title==null?null:l.title)&&m.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){b.splice(R,1);break t}}m=d.createElement(i),Yt(m,i,l),d.head.appendChild(m);break;case"meta":if(b=sx("meta","content",d).get(i+(l.content||""))){for(R=0;R<b.length;R++)if(m=b[R],m.getAttribute("content")===(l.content==null?null:""+l.content)&&m.getAttribute("name")===(l.name==null?null:l.name)&&m.getAttribute("property")===(l.property==null?null:l.property)&&m.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&m.getAttribute("charset")===(l.charSet==null?null:l.charSet)){b.splice(R,1);break t}}m=d.createElement(i),Yt(m,i,l),d.head.appendChild(m);break;default:throw Error(o(468,i))}m[Pt]=e,Ut(m),i=m}e.stateNode=i}else ix(d,e.type,e.stateNode);else e.stateNode=lx(d,i,e.memoizedProps);else m!==i?(m===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):m.count--,i===null?ix(d,e.type,e.stateNode):lx(d,i,e.memoizedProps)):i===null&&e.stateNode!==null&&yu(e,e.memoizedProps,l.memoizedProps)}break;case 27:fn(n,e),pn(e),i&512&&(zt||l===null||Jn(l,l.return)),l!==null&&i&4&&yu(e,e.memoizedProps,l.memoizedProps);break;case 5:if(fn(n,e),pn(e),i&512&&(zt||l===null||Jn(l,l.return)),e.flags&32){d=e.stateNode;try{Gr(d,"")}catch(Se){lt(e,e.return,Se)}}i&4&&e.stateNode!=null&&(d=e.memoizedProps,yu(e,d,l!==null?l.memoizedProps:d)),i&1024&&(Su=!0);break;case 6:if(fn(n,e),pn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(Se){lt(e,e.return,Se)}}break;case 3:if(Zi=null,d=Fn,Fn=Xi(n.containerInfo),fn(n,e),Fn=d,pn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{Sl(n.containerInfo)}catch(Se){lt(e,e.return,Se)}Su&&(Su=!1,ih(e));break;case 4:i=Fn,Fn=Xi(e.stateNode.containerInfo),fn(n,e),pn(e),Fn=i;break;case 12:fn(n,e),pn(e);break;case 31:fn(n,e),pn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Oi(e,i)));break;case 13:fn(n,e),pn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Ii=Qe()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Oi(e,i)));break;case 22:d=e.memoizedState!==null;var $=l!==null&&l.memoizedState!==null,Z=ba,se=zt;if(ba=Z||d,zt=se||$,fn(n,e),zt=se,ba=Z,pn(e),i&8192)e:for(n=e.stateNode,n._visibility=d?n._visibility&-2:n._visibility|1,d&&(l===null||$||ba||zt||Nr(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){$=l=n;try{if(m=$.stateNode,d)b=m.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{R=$.stateNode;var oe=$.memoizedProps.style,ee=oe!=null&&oe.hasOwnProperty("display")?oe.display:null;R.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(Se){lt($,$.return,Se)}}}else if(n.tag===6){if(l===null){$=n;try{$.stateNode.nodeValue=d?"":$.memoizedProps}catch(Se){lt($,$.return,Se)}}}else if(n.tag===18){if(l===null){$=n;try{var ae=$.stateNode;d?Xh(ae,!0):Xh($.stateNode,!1)}catch(Se){lt($,$.return,Se)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Oi(e,l))));break;case 19:fn(n,e),pn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Oi(e,i)));break;case 30:break;case 21:break;default:fn(n,e),pn(e)}}function pn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(Zm(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var d=l.stateNode,m=bu(e);_i(e,m,d);break;case 5:var b=l.stateNode;l.flags&32&&(Gr(b,""),l.flags&=-33);var R=bu(e);_i(e,R,b);break;case 3:case 4:var $=l.stateNode.containerInfo,Z=bu(e);ju(e,Z,$);break;default:throw Error(o(161))}}catch(se){lt(e,e.return,se)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function ih(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;ih(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Sa(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)th(e,n.alternate,n),n=n.sibling}function Nr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Fa(4,n,n.return),Nr(n);break;case 1:Jn(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&Xm(n,n.return,l),Nr(n);break;case 27:gs(n.stateNode);case 26:case 5:Jn(n,n.return),Nr(n);break;case 22:n.memoizedState===null&&Nr(n);break;case 30:Nr(n);break;default:Nr(n)}e=e.sibling}}function ka(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,d=e,m=n,b=m.flags;switch(m.tag){case 0:case 11:case 15:ka(d,m,l),is(4,m);break;case 1:if(ka(d,m,l),i=m,d=i.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(Z){lt(i,i.return,Z)}if(i=m,d=i.updateQueue,d!==null){var R=i.stateNode;try{var $=d.shared.hiddenCallbacks;if($!==null)for(d.shared.hiddenCallbacks=null,d=0;d<$.length;d++)Ip($[d],R)}catch(Z){lt(i,i.return,Z)}}l&&b&64&&Km(m),os(m,m.return);break;case 27:Jm(m);case 26:case 5:ka(d,m,l),l&&i===null&&b&4&&Qm(m),os(m,m.return);break;case 12:ka(d,m,l);break;case 31:ka(d,m,l),l&&b&4&&rh(d,m);break;case 13:ka(d,m,l),l&&b&4&&lh(d,m);break;case 22:m.memoizedState===null&&ka(d,m,l),os(m,m.return);break;case 30:break;default:ka(d,m,l)}n=n.sibling}}function ku(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&ql(l))}function wu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ql(e))}function Gn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)oh(e,n,l,i),n=n.sibling}function oh(e,n,l,i){var d=n.flags;switch(n.tag){case 0:case 11:case 15:Gn(e,n,l,i),d&2048&&is(9,n);break;case 1:Gn(e,n,l,i);break;case 3:Gn(e,n,l,i),d&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ql(e)));break;case 12:if(d&2048){Gn(e,n,l,i),e=n.stateNode;try{var m=n.memoizedProps,b=m.id,R=m.onPostCommit;typeof R=="function"&&R(b,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch($){lt(n,n.return,$)}}else Gn(e,n,l,i);break;case 31:Gn(e,n,l,i);break;case 13:Gn(e,n,l,i);break;case 23:break;case 22:m=n.stateNode,b=n.alternate,n.memoizedState!==null?m._visibility&2?Gn(e,n,l,i):cs(e,n):m._visibility&2?Gn(e,n,l,i):(m._visibility|=2,dl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),d&2048&&ku(b,n);break;case 24:Gn(e,n,l,i),d&2048&&wu(n.alternate,n);break;default:Gn(e,n,l,i)}}function dl(e,n,l,i,d){for(d=d&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var m=e,b=n,R=l,$=i,Z=b.flags;switch(b.tag){case 0:case 11:case 15:dl(m,b,R,$,d),is(8,b);break;case 23:break;case 22:var se=b.stateNode;b.memoizedState!==null?se._visibility&2?dl(m,b,R,$,d):cs(m,b):(se._visibility|=2,dl(m,b,R,$,d)),d&&Z&2048&&ku(b.alternate,b);break;case 24:dl(m,b,R,$,d),d&&Z&2048&&wu(b.alternate,b);break;default:dl(m,b,R,$,d)}n=n.sibling}}function cs(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,d=i.flags;switch(i.tag){case 22:cs(l,i),d&2048&&ku(i.alternate,i);break;case 24:cs(l,i),d&2048&&wu(i.alternate,i);break;default:cs(l,i)}n=n.sibling}}var us=8192;function fl(e,n,l){if(e.subtreeFlags&us)for(e=e.child;e!==null;)ch(e,n,l),e=e.sibling}function ch(e,n,l){switch(e.tag){case 26:fl(e,n,l),e.flags&us&&e.memoizedState!==null&&H1(l,Fn,e.memoizedState,e.memoizedProps);break;case 5:fl(e,n,l);break;case 3:case 4:var i=Fn;Fn=Xi(e.stateNode.containerInfo),fl(e,n,l),Fn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=us,us=16777216,fl(e,n,l),us=i):fl(e,n,l));break;default:fl(e,n,l)}}function uh(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function ds(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];$t=i,fh(i,e)}uh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)dh(e),e=e.sibling}function dh(e){switch(e.tag){case 0:case 11:case 15:ds(e),e.flags&2048&&Fa(9,e,e.return);break;case 3:ds(e);break;case 12:ds(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Bi(e)):ds(e);break;default:ds(e)}}function Bi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];$t=i,fh(i,e)}uh(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Fa(8,n,n.return),Bi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Bi(n));break;default:Bi(n)}e=e.sibling}}function fh(e,n){for(;$t!==null;){var l=$t;switch(l.tag){case 0:case 11:case 15:Fa(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:ql(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,$t=i;else e:for(l=e;$t!==null;){i=$t;var d=i.sibling,m=i.return;if(nh(i),i===l){$t=null;break e}if(d!==null){d.return=m,$t=d;break e}$t=m}}}var e1={getCacheForType:function(e){var n=Gt(At),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Gt(At).controller.signal}},t1=typeof WeakMap=="function"?WeakMap:Map,tt=0,ft=null,Ge=null,Ye=0,rt=0,jn=null,Ga=!1,pl=!1,Eu=!1,wa=0,Ct=0,Wa=0,Tr=0,Cu=0,Sn=0,ml=0,fs=null,mn=null,Nu=!1,Ii=0,ph=0,Hi=1/0,Ui=null,Ya=null,Ot=0,qa=null,hl=null,Ea=0,Tu=0,Ru=null,mh=null,ps=0,Au=null;function kn(){return(tt&2)!==0&&Ye!==0?Ye&-Ye:M.T!==null?Ou():Af()}function hh(){if(Sn===0)if((Ye&536870912)===0||Ke){var e=Vt;Vt<<=1,(Vt&3932160)===0&&(Vt=262144),Sn=e}else Sn=536870912;return e=yn.current,e!==null&&(e.flags|=32),Sn}function hn(e,n,l){(e===ft&&(rt===2||rt===9)||e.cancelPendingCommit!==null)&&(xl(e,0),Ka(e,Ye,Sn,!1)),Rn(e,l),((tt&2)===0||e!==ft)&&(e===ft&&((tt&2)===0&&(Tr|=l),Ct===4&&Ka(e,Ye,Sn,!1)),ea(e))}function xh(e,n,l){if((tt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Ma(e,n),d=i?r1(e,n):Lu(e,n,!0),m=i;do{if(d===0){pl&&!i&&Ka(e,n,0,!1);break}else{if(l=e.current.alternate,m&&!n1(l)){d=Lu(e,n,!1),m=!1;continue}if(d===2){if(m=n,e.errorRecoveryDisabledLanes&m)var b=0;else b=e.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){n=b;e:{var R=e;d=fs;var $=R.current.memoizedState.isDehydrated;if($&&(xl(R,b).flags|=256),b=Lu(R,b,!1),b!==2){if(Eu&&!$){R.errorRecoveryDisabledLanes|=m,Tr|=m,d=4;break e}m=mn,mn=d,m!==null&&(mn===null?mn=m:mn.push.apply(mn,m))}d=b}if(m=!1,d!==2)continue}}if(d===1){xl(e,0),Ka(e,n,0,!0);break}e:{switch(i=e,m=d,m){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Ka(i,n,Sn,!Ga);break e;case 2:mn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(d=Ii+300-Qe(),10<d)){if(Ka(i,n,Sn,!Ga),ia(i,0,!0)!==0)break e;Ea=n,i.timeoutHandle=Yh(gh.bind(null,i,l,mn,Ui,Nu,n,Sn,Tr,ml,Ga,m,"Throttled",-0,0),d);break e}gh(i,l,mn,Ui,Nu,n,Sn,Tr,ml,Ga,m,null,-0,0)}}break}while(!0);ea(e)}function gh(e,n,l,i,d,m,b,R,$,Z,se,oe,ee,ae){if(e.timeoutHandle=-1,oe=n.subtreeFlags,oe&8192||(oe&16785408)===16785408){oe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ua},ch(n,m,oe);var Se=(m&62914560)===m?Ii-Qe():(m&4194048)===m?ph-Qe():0;if(Se=U1(oe,Se),Se!==null){Ea=m,e.cancelPendingCommit=Se(Eh.bind(null,e,n,m,l,i,d,b,R,$,se,oe,null,ee,ae)),Ka(e,m,b,!Z);return}}Eh(e,n,m,l,i,d,b,R,$)}function n1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var d=l[i],m=d.getSnapshot;d=d.value;try{if(!gn(m(),d))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Ka(e,n,l,i){n&=~Cu,n&=~Tr,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var d=n;0<d;){var m=31-dt(d),b=1<<m;i[m]=-1,d&=~b}l!==0&&Kt(e,l,n)}function $i(){return(tt&6)===0?(ms(0),!1):!0}function Mu(){if(Ge!==null){if(rt===0)var e=Ge.return;else e=Ge,ma=yr=null,Yc(e),sl=null,Xl=0,e=Ge;for(;e!==null;)qm(e.alternate,e),e=e.return;Ge=null}}function xl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,S1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Ea=0,Mu(),ft=e,Ge=l=fa(e.current,null),Ye=n,rt=0,jn=null,Ga=!1,pl=Ma(e,n),Eu=!1,ml=Sn=Cu=Tr=Wa=Ct=0,mn=fs=null,Nu=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var d=31-dt(i),m=1<<d;n|=e[d],i&=~m}return wa=n,oi(),l}function vh(e,n){Ie=null,M.H=rs,n===ll||n===xi?(n=Dp(),rt=3):n===_c?(n=Dp(),rt=4):rt=n===cu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,jn=n,Ge===null&&(Ct=1,Ai(e,zn(n,e.current)))}function yh(){var e=yn.current;return e===null?!0:(Ye&4194048)===Ye?Bn===null:(Ye&62914560)===Ye||(Ye&536870912)!==0?e===Bn:!1}function bh(){var e=M.H;return M.H=rs,e===null?rs:e}function jh(){var e=M.A;return M.A=e1,e}function Vi(){Ct=4,Ga||(Ye&4194048)!==Ye&&yn.current!==null||(pl=!0),(Wa&134217727)===0&&(Tr&134217727)===0||ft===null||Ka(ft,Ye,Sn,!1)}function Lu(e,n,l){var i=tt;tt|=2;var d=bh(),m=jh();(ft!==e||Ye!==n)&&(Ui=null,xl(e,n)),n=!1;var b=Ct;e:do try{if(rt!==0&&Ge!==null){var R=Ge,$=jn;switch(rt){case 8:Mu(),b=6;break e;case 3:case 2:case 9:case 6:yn.current===null&&(n=!0);var Z=rt;if(rt=0,jn=null,gl(e,R,$,Z),l&&pl){b=0;break e}break;default:Z=rt,rt=0,jn=null,gl(e,R,$,Z)}}a1(),b=Ct;break}catch(se){vh(e,se)}while(!0);return n&&e.shellSuspendCounter++,ma=yr=null,tt=i,M.H=d,M.A=m,Ge===null&&(ft=null,Ye=0,oi()),b}function a1(){for(;Ge!==null;)Sh(Ge)}function r1(e,n){var l=tt;tt|=2;var i=bh(),d=jh();ft!==e||Ye!==n?(Ui=null,Hi=Qe()+500,xl(e,n)):pl=Ma(e,n);e:do try{if(rt!==0&&Ge!==null){n=Ge;var m=jn;t:switch(rt){case 1:rt=0,jn=null,gl(e,n,m,1);break;case 2:case 9:if(Lp(m)){rt=0,jn=null,kh(n);break}n=function(){rt!==2&&rt!==9||ft!==e||(rt=7),ea(e)},m.then(n,n);break e;case 3:rt=7;break e;case 4:rt=5;break e;case 7:Lp(m)?(rt=0,jn=null,kh(n)):(rt=0,jn=null,gl(e,n,m,7));break;case 5:var b=null;switch(Ge.tag){case 26:b=Ge.memoizedState;case 5:case 27:var R=Ge;if(b?ox(b):R.stateNode.complete){rt=0,jn=null;var $=R.sibling;if($!==null)Ge=$;else{var Z=R.return;Z!==null?(Ge=Z,Pi(Z)):Ge=null}break t}}rt=0,jn=null,gl(e,n,m,5);break;case 6:rt=0,jn=null,gl(e,n,m,6);break;case 8:Mu(),Ct=6;break e;default:throw Error(o(462))}}l1();break}catch(se){vh(e,se)}while(!0);return ma=yr=null,M.H=i,M.A=d,tt=l,Ge!==null?0:(ft=null,Ye=0,oi(),Ct)}function l1(){for(;Ge!==null&&!Jt();)Sh(Ge)}function Sh(e){var n=Wm(e.alternate,e,wa);e.memoizedProps=e.pendingProps,n===null?Pi(e):Ge=n}function kh(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Um(l,n,n.pendingProps,n.type,void 0,Ye);break;case 11:n=Um(l,n,n.pendingProps,n.type.render,n.ref,Ye);break;case 5:Yc(n);default:qm(l,n),n=Ge=jp(n,wa),n=Wm(l,n,wa)}e.memoizedProps=e.pendingProps,n===null?Pi(e):Ge=n}function gl(e,n,l,i){ma=yr=null,Yc(n),sl=null,Xl=0;var d=n.return;try{if(Yb(e,d,n,l,Ye)){Ct=1,Ai(e,zn(l,e.current)),Ge=null;return}}catch(m){if(d!==null)throw Ge=d,m;Ct=1,Ai(e,zn(l,e.current)),Ge=null;return}n.flags&32768?(Ke||i===1?e=!0:pl||(Ye&536870912)!==0?e=!1:(Ga=e=!0,(i===2||i===9||i===3||i===6)&&(i=yn.current,i!==null&&i.tag===13&&(i.flags|=16384))),wh(n,e)):Pi(n)}function Pi(e){var n=e;do{if((n.flags&32768)!==0){wh(n,Ga);return}e=n.return;var l=Xb(n.alternate,n,wa);if(l!==null){Ge=l;return}if(n=n.sibling,n!==null){Ge=n;return}Ge=n=e}while(n!==null);Ct===0&&(Ct=5)}function wh(e,n){do{var l=Qb(e.alternate,e);if(l!==null){l.flags&=32767,Ge=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ge=e;return}Ge=e=l}while(e!==null);Ct=6,Ge=null}function Eh(e,n,l,i,d,m,b,R,$){e.cancelPendingCommit=null;do Fi();while(Ot!==0);if((tt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(m=n.lanes|n.childLanes,m|=bc,qo(e,l,m,b,R,$),e===ft&&(Ge=ft=null,Ye=0),hl=n,qa=e,Ea=l,Tu=m,Ru=d,mh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,c1(Pe,function(){return Ah(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=M.T,M.T=null,d=B.p,B.p=2,b=tt,tt|=4;try{Zb(e,n,l)}finally{tt=b,B.p=d,M.T=i}}Ot=1,Ch(),Nh(),Th()}}function Ch(){if(Ot===1){Ot=0;var e=qa,n=hl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=M.T,M.T=null;var i=B.p;B.p=2;var d=tt;tt|=4;try{sh(n,e);var m=Fu,b=fp(e.containerInfo),R=m.focusedElem,$=m.selectionRange;if(b!==R&&R&&R.ownerDocument&&dp(R.ownerDocument.documentElement,R)){if($!==null&&hc(R)){var Z=$.start,se=$.end;if(se===void 0&&(se=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(se,R.value.length);else{var oe=R.ownerDocument||document,ee=oe&&oe.defaultView||window;if(ee.getSelection){var ae=ee.getSelection(),Se=R.textContent.length,Ae=Math.min($.start,Se),ct=$.end===void 0?Ae:Math.min($.end,Se);!ae.extend&&Ae>ct&&(b=ct,ct=Ae,Ae=b);var Y=up(R,Ae),G=up(R,ct);if(Y&&G&&(ae.rangeCount!==1||ae.anchorNode!==Y.node||ae.anchorOffset!==Y.offset||ae.focusNode!==G.node||ae.focusOffset!==G.offset)){var X=oe.createRange();X.setStart(Y.node,Y.offset),ae.removeAllRanges(),Ae>ct?(ae.addRange(X),ae.extend(G.node,G.offset)):(X.setEnd(G.node,G.offset),ae.addRange(X))}}}}for(oe=[],ae=R;ae=ae.parentNode;)ae.nodeType===1&&oe.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<oe.length;R++){var ie=oe[R];ie.element.scrollLeft=ie.left,ie.element.scrollTop=ie.top}}no=!!Pu,Fu=Pu=null}finally{tt=d,B.p=i,M.T=l}}e.current=n,Ot=2}}function Nh(){if(Ot===2){Ot=0;var e=qa,n=hl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=M.T,M.T=null;var i=B.p;B.p=2;var d=tt;tt|=4;try{th(e,n.alternate,n)}finally{tt=d,B.p=i,M.T=l}}Ot=3}}function Th(){if(Ot===4||Ot===3){Ot=0,ht();var e=qa,n=hl,l=Ea,i=mh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Ot=5:(Ot=0,hl=qa=null,Rh(e,e.pendingLanes));var d=e.pendingLanes;if(d===0&&(Ya=null),Xo(l),n=n.stateNode,nt&&typeof nt.onCommitFiberRoot=="function")try{nt.onCommitFiberRoot(Fe,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=M.T,d=B.p,B.p=2,M.T=null;try{for(var m=e.onRecoverableError,b=0;b<i.length;b++){var R=i[b];m(R.value,{componentStack:R.stack})}}finally{M.T=n,B.p=d}}(Ea&3)!==0&&Fi(),ea(e),d=e.pendingLanes,(l&261930)!==0&&(d&42)!==0?e===Au?ps++:(ps=0,Au=e):ps=0,ms(0)}}function Rh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,ql(n)))}function Fi(){return Ch(),Nh(),Th(),Ah()}function Ah(){if(Ot!==5)return!1;var e=qa,n=Tu;Tu=0;var l=Xo(Ea),i=M.T,d=B.p;try{B.p=32>l?32:l,M.T=null,l=Ru,Ru=null;var m=qa,b=Ea;if(Ot=0,hl=qa=null,Ea=0,(tt&6)!==0)throw Error(o(331));var R=tt;if(tt|=4,dh(m.current),oh(m,m.current,b,l),tt=R,ms(0,!1),nt&&typeof nt.onPostCommitFiberRoot=="function")try{nt.onPostCommitFiberRoot(Fe,m)}catch{}return!0}finally{B.p=d,M.T=i,Rh(e,n)}}function Mh(e,n,l){n=zn(l,n),n=ou(e.stateNode,n,2),e=$a(e,n,2),e!==null&&(Rn(e,2),ea(e))}function lt(e,n,l){if(e.tag===3)Mh(e,e,l);else for(;n!==null;){if(n.tag===3){Mh(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Ya===null||!Ya.has(i))){e=zn(l,e),l=Lm(2),i=$a(n,l,2),i!==null&&(zm(l,i,n,e),Rn(i,2),ea(i));break}}n=n.return}}function zu(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new t1;var d=new Set;i.set(n,d)}else d=i.get(n),d===void 0&&(d=new Set,i.set(n,d));d.has(l)||(Eu=!0,d.add(l),e=s1.bind(null,e,n,l),n.then(e,e))}function s1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,ft===e&&(Ye&l)===l&&(Ct===4||Ct===3&&(Ye&62914560)===Ye&&300>Qe()-Ii?(tt&2)===0&&xl(e,0):Cu|=l,ml===Ye&&(ml=0)),ea(e)}function Lh(e,n){n===0&&(n=st()),e=xr(e,n),e!==null&&(Rn(e,n),ea(e))}function i1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Lh(e,l)}function o1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,d=e.memoizedState;d!==null&&(l=d.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),Lh(e,l)}function c1(e,n){return _t(e,n)}var Gi=null,vl=null,Du=!1,Wi=!1,_u=!1,Xa=0;function ea(e){e!==vl&&e.next===null&&(vl===null?Gi=vl=e:vl=vl.next=e),Wi=!0,Du||(Du=!0,d1())}function ms(e,n){if(!_u&&Wi){_u=!0;do for(var l=!1,i=Gi;i!==null;){if(e!==0){var d=i.pendingLanes;if(d===0)var m=0;else{var b=i.suspendedLanes,R=i.pingedLanes;m=(1<<31-dt(42|e)+1)-1,m&=d&~(b&~R),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,Oh(i,m))}else m=Ye,m=ia(i,i===ft?m:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(m&3)===0||Ma(i,m)||(l=!0,Oh(i,m));i=i.next}while(l);_u=!1}}function u1(){zh()}function zh(){Wi=Du=!1;var e=0;Xa!==0&&j1()&&(e=Xa);for(var n=Qe(),l=null,i=Gi;i!==null;){var d=i.next,m=Dh(i,n);m===0?(i.next=null,l===null?Gi=d:l.next=d,d===null&&(vl=l)):(l=i,(e!==0||(m&3)!==0)&&(Wi=!0)),i=d}Ot!==0&&Ot!==5||ms(e),Xa!==0&&(Xa=0)}function Dh(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,d=e.expirationTimes,m=e.pendingLanes&-62914561;0<m;){var b=31-dt(m),R=1<<b,$=d[b];$===-1?((R&l)===0||(R&i)!==0)&&(d[b]=Ir(R,n)):$<=n&&(e.expiredLanes|=R),m&=~R}if(n=ft,l=Ye,l=ia(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(rt===2||rt===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&mt(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Ma(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&mt(i),Xo(l)){case 2:case 8:l=Te;break;case 32:l=Pe;break;case 268435456:l=Xn;break;default:l=Pe}return i=_h.bind(null,e),l=_t(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&mt(i),e.callbackPriority=2,e.callbackNode=null,2}function _h(e,n){if(Ot!==0&&Ot!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Fi()&&e.callbackNode!==l)return null;var i=Ye;return i=ia(e,e===ft?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(xh(e,i,n),Dh(e,Qe()),e.callbackNode!=null&&e.callbackNode===l?_h.bind(null,e):null)}function Oh(e,n){if(Fi())return null;xh(e,n,!0)}function d1(){k1(function(){(tt&6)!==0?_t(J,u1):zh()})}function Ou(){if(Xa===0){var e=al;e===0&&(e=Rt,Rt<<=1,(Rt&261888)===0&&(Rt=256)),Xa=e}return Xa}function Bh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ei(""+e)}function Ih(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function f1(e,n,l,i,d){if(n==="submit"&&l&&l.stateNode===d){var m=Bh((d[cn]||null).action),b=i.submitter;b&&(n=(n=b[cn]||null)?Bh(n.formAction):b.getAttribute("formAction"),n!==null&&(m=n,b=null));var R=new ri("action","action",null,i,d);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Xa!==0){var $=b?Ih(d,b):new FormData(d);nu(l,{pending:!0,data:$,method:d.method,action:m},null,$)}}else typeof m=="function"&&(R.preventDefault(),$=b?Ih(d,b):new FormData(d),nu(l,{pending:!0,data:$,method:d.method,action:m},m,$))},currentTarget:d}]})}}for(var Bu=0;Bu<yc.length;Bu++){var Iu=yc[Bu],p1=Iu.toLowerCase(),m1=Iu[0].toUpperCase()+Iu.slice(1);Pn(p1,"on"+m1)}Pn(hp,"onAnimationEnd"),Pn(xp,"onAnimationIteration"),Pn(gp,"onAnimationStart"),Pn("dblclick","onDoubleClick"),Pn("focusin","onFocus"),Pn("focusout","onBlur"),Pn(Ab,"onTransitionRun"),Pn(Mb,"onTransitionStart"),Pn(Lb,"onTransitionCancel"),Pn(vp,"onTransitionEnd"),Pr("onMouseEnter",["mouseout","mouseover"]),Pr("onMouseLeave",["mouseout","mouseover"]),Pr("onPointerEnter",["pointerout","pointerover"]),Pr("onPointerLeave",["pointerout","pointerover"]),fr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),fr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),fr("onBeforeInput",["compositionend","keypress","textInput","paste"]),fr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),fr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hs="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(" "),h1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(hs));function Hh(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],d=i.event;i=i.listeners;e:{var m=void 0;if(n)for(var b=i.length-1;0<=b;b--){var R=i[b],$=R.instance,Z=R.currentTarget;if(R=R.listener,$!==m&&d.isPropagationStopped())break e;m=R,d.currentTarget=Z;try{m(d)}catch(se){ii(se)}d.currentTarget=null,m=$}else for(b=0;b<i.length;b++){if(R=i[b],$=R.instance,Z=R.currentTarget,R=R.listener,$!==m&&d.isPropagationStopped())break e;m=R,d.currentTarget=Z;try{m(d)}catch(se){ii(se)}d.currentTarget=null,m=$}}}}function We(e,n){var l=n[Qo];l===void 0&&(l=n[Qo]=new Set);var i=e+"__bubble";l.has(i)||(Uh(n,e,2,!1),l.add(i))}function Hu(e,n,l){var i=0;n&&(i|=4),Uh(l,e,i,n)}var Yi="_reactListening"+Math.random().toString(36).slice(2);function Uu(e){if(!e[Yi]){e[Yi]=!0,zf.forEach(function(l){l!=="selectionchange"&&(h1.has(l)||Hu(l,!1,e),Hu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Yi]||(n[Yi]=!0,Hu("selectionchange",!1,n))}}function Uh(e,n,l,i){switch(hx(n)){case 2:var d=P1;break;case 8:d=F1;break;default:d=td}l=d.bind(null,n,l,e),d=void 0,!sc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),i?d!==void 0?e.addEventListener(n,l,{capture:!0,passive:d}):e.addEventListener(n,l,!0):d!==void 0?e.addEventListener(n,l,{passive:d}):e.addEventListener(n,l,!1)}function $u(e,n,l,i,d){var m=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var b=i.tag;if(b===3||b===4){var R=i.stateNode.containerInfo;if(R===d)break;if(b===4)for(b=i.return;b!==null;){var $=b.tag;if(($===3||$===4)&&b.stateNode.containerInfo===d)return;b=b.return}for(;R!==null;){if(b=Ur(R),b===null)return;if($=b.tag,$===5||$===6||$===26||$===27){i=m=b;continue e}R=R.parentNode}}i=i.return}Gf(function(){var Z=m,se=rc(l),oe=[];e:{var ee=yp.get(e);if(ee!==void 0){var ae=ri,Se=e;switch(e){case"keypress":if(ni(l)===0)break e;case"keydown":case"keyup":ae=ob;break;case"focusin":Se="focus",ae=uc;break;case"focusout":Se="blur",ae=uc;break;case"beforeblur":case"afterblur":ae=uc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ae=qf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ae=Xy;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ae=db;break;case hp:case xp:case gp:ae=Jy;break;case vp:ae=pb;break;case"scroll":case"scrollend":ae=qy;break;case"wheel":ae=hb;break;case"copy":case"cut":case"paste":ae=tb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ae=Xf;break;case"toggle":case"beforetoggle":ae=gb}var Ae=(n&4)!==0,ct=!Ae&&(e==="scroll"||e==="scrollend"),Y=Ae?ee!==null?ee+"Capture":null:ee;Ae=[];for(var G=Z,X;G!==null;){var ie=G;if(X=ie.stateNode,ie=ie.tag,ie!==5&&ie!==26&&ie!==27||X===null||Y===null||(ie=Bl(G,Y),ie!=null&&Ae.push(xs(G,ie,X))),ct)break;G=G.return}0<Ae.length&&(ee=new ae(ee,Se,null,l,se),oe.push({event:ee,listeners:Ae}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",ae=e==="mouseout"||e==="pointerout",ee&&l!==ac&&(Se=l.relatedTarget||l.fromElement)&&(Ur(Se)||Se[Hr]))break e;if((ae||ee)&&(ee=se.window===se?se:(ee=se.ownerDocument)?ee.defaultView||ee.parentWindow:window,ae?(Se=l.relatedTarget||l.toElement,ae=Z,Se=Se?Ur(Se):null,Se!==null&&(ct=u(Se),Ae=Se.tag,Se!==ct||Ae!==5&&Ae!==27&&Ae!==6)&&(Se=null)):(ae=null,Se=Z),ae!==Se)){if(Ae=qf,ie="onMouseLeave",Y="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Ae=Xf,ie="onPointerLeave",Y="onPointerEnter",G="pointer"),ct=ae==null?ee:Ol(ae),X=Se==null?ee:Ol(Se),ee=new Ae(ie,G+"leave",ae,l,se),ee.target=ct,ee.relatedTarget=X,ie=null,Ur(se)===Z&&(Ae=new Ae(Y,G+"enter",Se,l,se),Ae.target=X,Ae.relatedTarget=ct,ie=Ae),ct=ie,ae&&Se)t:{for(Ae=x1,Y=ae,G=Se,X=0,ie=Y;ie;ie=Ae(ie))X++;ie=0;for(var Re=G;Re;Re=Ae(Re))ie++;for(;0<X-ie;)Y=Ae(Y),X--;for(;0<ie-X;)G=Ae(G),ie--;for(;X--;){if(Y===G||G!==null&&Y===G.alternate){Ae=Y;break t}Y=Ae(Y),G=Ae(G)}Ae=null}else Ae=null;ae!==null&&$h(oe,ee,ae,Ae,!1),Se!==null&&ct!==null&&$h(oe,ct,Se,Ae,!0)}}e:{if(ee=Z?Ol(Z):window,ae=ee.nodeName&&ee.nodeName.toLowerCase(),ae==="select"||ae==="input"&&ee.type==="file")var Ze=rp;else if(np(ee))if(lp)Ze=Nb;else{Ze=Eb;var ke=wb}else ae=ee.nodeName,!ae||ae.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&nc(Z.elementType)&&(Ze=rp):Ze=Cb;if(Ze&&(Ze=Ze(e,Z))){ap(oe,Ze,l,se);break e}ke&&ke(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&tc(ee,"number",ee.value)}switch(ke=Z?Ol(Z):window,e){case"focusin":(np(ke)||ke.contentEditable==="true")&&(Kr=ke,xc=Z,Gl=null);break;case"focusout":Gl=xc=Kr=null;break;case"mousedown":gc=!0;break;case"contextmenu":case"mouseup":case"dragend":gc=!1,pp(oe,l,se);break;case"selectionchange":if(Rb)break;case"keydown":case"keyup":pp(oe,l,se)}var He;if(fc)e:{switch(e){case"compositionstart":var qe="onCompositionStart";break e;case"compositionend":qe="onCompositionEnd";break e;case"compositionupdate":qe="onCompositionUpdate";break e}qe=void 0}else qr?ep(e,l)&&(qe="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(qe="onCompositionStart");qe&&(Qf&&l.locale!=="ko"&&(qr||qe!=="onCompositionStart"?qe==="onCompositionEnd"&&qr&&(He=Wf()):(Da=se,ic="value"in Da?Da.value:Da.textContent,qr=!0)),ke=qi(Z,qe),0<ke.length&&(qe=new Kf(qe,e,null,l,se),oe.push({event:qe,listeners:ke}),He?qe.data=He:(He=tp(l),He!==null&&(qe.data=He)))),(He=yb?bb(e,l):jb(e,l))&&(qe=qi(Z,"onBeforeInput"),0<qe.length&&(ke=new Kf("onBeforeInput","beforeinput",null,l,se),oe.push({event:ke,listeners:qe}),ke.data=He)),f1(oe,e,Z,l,se)}Hh(oe,n)})}function xs(e,n,l){return{instance:e,listener:n,currentTarget:l}}function qi(e,n){for(var l=n+"Capture",i=[];e!==null;){var d=e,m=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||m===null||(d=Bl(e,l),d!=null&&i.unshift(xs(e,d,m)),d=Bl(e,n),d!=null&&i.push(xs(e,d,m))),e.tag===3)return i;e=e.return}return[]}function x1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function $h(e,n,l,i,d){for(var m=n._reactName,b=[];l!==null&&l!==i;){var R=l,$=R.alternate,Z=R.stateNode;if(R=R.tag,$!==null&&$===i)break;R!==5&&R!==26&&R!==27||Z===null||($=Z,d?(Z=Bl(l,m),Z!=null&&b.unshift(xs(l,Z,$))):d||(Z=Bl(l,m),Z!=null&&b.push(xs(l,Z,$)))),l=l.return}b.length!==0&&e.push({event:n,listeners:b})}var g1=/\r\n?/g,v1=/\u0000|\uFFFD/g;function Vh(e){return(typeof e=="string"?e:""+e).replace(g1,`
50
+ `).replace(v1,"")}function Ph(e,n){return n=Vh(n),Vh(e)===n}function ot(e,n,l,i,d,m){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Gr(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Gr(e,""+i);break;case"className":Zs(e,"class",i);break;case"tabIndex":Zs(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":Zs(e,l,i);break;case"style":Pf(e,i,m);break;case"data":if(n!=="object"){Zs(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ei(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(l==="formAction"?(n!=="input"&&ot(e,n,"name",d.name,d,null),ot(e,n,"formEncType",d.formEncType,d,null),ot(e,n,"formMethod",d.formMethod,d,null),ot(e,n,"formTarget",d.formTarget,d,null)):(ot(e,n,"encType",d.encType,d,null),ot(e,n,"method",d.method,d,null),ot(e,n,"target",d.target,d,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=ei(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=ua);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(d.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=ei(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":We("beforetoggle",e),We("toggle",e),Qs(e,"popover",i);break;case"xlinkActuate":ca(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":ca(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":ca(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":ca(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":ca(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":ca(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":ca(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":ca(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":ca(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":Qs(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Wy.get(l)||l,Qs(e,l,i))}}function Vu(e,n,l,i,d,m){switch(l){case"style":Pf(e,i,m);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(d.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Gr(e,i):(typeof i=="number"||typeof i=="bigint")&&Gr(e,""+i);break;case"onScroll":i!=null&&We("scroll",e);break;case"onScrollEnd":i!=null&&We("scrollend",e);break;case"onClick":i!=null&&(e.onclick=ua);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Df.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(d=l.endsWith("Capture"),n=l.slice(2,d?l.length-7:void 0),m=e[cn]||null,m=m!=null?m[l]:null,typeof m=="function"&&e.removeEventListener(n,m,d),typeof i=="function")){typeof m!="function"&&m!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,d);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):Qs(e,l,i)}}}function Yt(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var i=!1,d=!1,m;for(m in l)if(l.hasOwnProperty(m)){var b=l[m];if(b!=null)switch(m){case"src":i=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ot(e,n,m,b,l,null)}}d&&ot(e,n,"srcSet",l.srcSet,l,null),i&&ot(e,n,"src",l.src,l,null);return;case"input":We("invalid",e);var R=m=b=d=null,$=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var se=l[i];if(se!=null)switch(i){case"name":d=se;break;case"type":b=se;break;case"checked":$=se;break;case"defaultChecked":Z=se;break;case"value":m=se;break;case"defaultValue":R=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(o(137,n));break;default:ot(e,n,i,se,l,null)}}Hf(e,m,R,$,Z,b,d,!1);return;case"select":We("invalid",e),i=b=m=null;for(d in l)if(l.hasOwnProperty(d)&&(R=l[d],R!=null))switch(d){case"value":m=R;break;case"defaultValue":b=R;break;case"multiple":i=R;default:ot(e,n,d,R,l,null)}n=m,l=b,e.multiple=!!i,n!=null?Fr(e,!!i,n,!1):l!=null&&Fr(e,!!i,l,!0);return;case"textarea":We("invalid",e),m=d=i=null;for(b in l)if(l.hasOwnProperty(b)&&(R=l[b],R!=null))switch(b){case"value":i=R;break;case"defaultValue":d=R;break;case"children":m=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:ot(e,n,b,R,l,null)}$f(e,i,d,m);return;case"option":for($ in l)if(l.hasOwnProperty($)&&(i=l[$],i!=null))switch($){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:ot(e,n,$,i,l,null)}return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(i=0;i<hs.length;i++)We(hs[i],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:ot(e,n,Z,i,l,null)}return;default:if(nc(n)){for(se in l)l.hasOwnProperty(se)&&(i=l[se],i!==void 0&&Vu(e,n,se,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&ot(e,n,R,i,l,null))}function y1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,m=null,b=null,R=null,$=null,Z=null,se=null;for(ae in l){var oe=l[ae];if(l.hasOwnProperty(ae)&&oe!=null)switch(ae){case"checked":break;case"value":break;case"defaultValue":$=oe;default:i.hasOwnProperty(ae)||ot(e,n,ae,null,i,oe)}}for(var ee in i){var ae=i[ee];if(oe=l[ee],i.hasOwnProperty(ee)&&(ae!=null||oe!=null))switch(ee){case"type":m=ae;break;case"name":d=ae;break;case"checked":Z=ae;break;case"defaultChecked":se=ae;break;case"value":b=ae;break;case"defaultValue":R=ae;break;case"children":case"dangerouslySetInnerHTML":if(ae!=null)throw Error(o(137,n));break;default:ae!==oe&&ot(e,n,ee,ae,i,oe)}}ec(e,b,R,$,Z,se,m,d);return;case"select":ae=b=R=ee=null;for(m in l)if($=l[m],l.hasOwnProperty(m)&&$!=null)switch(m){case"value":break;case"multiple":ae=$;default:i.hasOwnProperty(m)||ot(e,n,m,null,i,$)}for(d in i)if(m=i[d],$=l[d],i.hasOwnProperty(d)&&(m!=null||$!=null))switch(d){case"value":ee=m;break;case"defaultValue":R=m;break;case"multiple":b=m;default:m!==$&&ot(e,n,d,m,i,$)}n=R,l=b,i=ae,ee!=null?Fr(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Fr(e,!!l,n,!0):Fr(e,!!l,l?[]:"",!1));return;case"textarea":ae=ee=null;for(R in l)if(d=l[R],l.hasOwnProperty(R)&&d!=null&&!i.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:ot(e,n,R,null,i,d)}for(b in i)if(d=i[b],m=l[b],i.hasOwnProperty(b)&&(d!=null||m!=null))switch(b){case"value":ee=d;break;case"defaultValue":ae=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(o(91));break;default:d!==m&&ot(e,n,b,d,i,m)}Uf(e,ee,ae);return;case"option":for(var Se in l)if(ee=l[Se],l.hasOwnProperty(Se)&&ee!=null&&!i.hasOwnProperty(Se))switch(Se){case"selected":e.selected=!1;break;default:ot(e,n,Se,null,i,ee)}for($ in i)if(ee=i[$],ae=l[$],i.hasOwnProperty($)&&ee!==ae&&(ee!=null||ae!=null))switch($){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:ot(e,n,$,ee,i,ae)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ae in l)ee=l[Ae],l.hasOwnProperty(Ae)&&ee!=null&&!i.hasOwnProperty(Ae)&&ot(e,n,Ae,null,i,ee);for(Z in i)if(ee=i[Z],ae=l[Z],i.hasOwnProperty(Z)&&ee!==ae&&(ee!=null||ae!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:ot(e,n,Z,ee,i,ae)}return;default:if(nc(n)){for(var ct in l)ee=l[ct],l.hasOwnProperty(ct)&&ee!==void 0&&!i.hasOwnProperty(ct)&&Vu(e,n,ct,void 0,i,ee);for(se in i)ee=i[se],ae=l[se],!i.hasOwnProperty(se)||ee===ae||ee===void 0&&ae===void 0||Vu(e,n,se,ee,i,ae);return}}for(var Y in l)ee=l[Y],l.hasOwnProperty(Y)&&ee!=null&&!i.hasOwnProperty(Y)&&ot(e,n,Y,null,i,ee);for(oe in i)ee=i[oe],ae=l[oe],!i.hasOwnProperty(oe)||ee===ae||ee==null&&ae==null||ot(e,n,oe,ee,i,ae)}function Fh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function b1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var d=l[i],m=d.transferSize,b=d.initiatorType,R=d.duration;if(m&&R&&Fh(b)){for(b=0,R=d.responseEnd,i+=1;i<l.length;i++){var $=l[i],Z=$.startTime;if(Z>R)break;var se=$.transferSize,oe=$.initiatorType;se&&Fh(oe)&&($=$.responseEnd,b+=se*($<R?1:(R-Z)/($-Z)))}if(--i,n+=8*(m+b)/(d.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Pu=null,Fu=null;function Ki(e){return e.nodeType===9?e:e.ownerDocument}function Gh(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 Wh(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Gu(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Wu=null;function j1(){var e=window.event;return e&&e.type==="popstate"?e===Wu?!1:(Wu=e,!0):(Wu=null,!1)}var Yh=typeof setTimeout=="function"?setTimeout:void 0,S1=typeof clearTimeout=="function"?clearTimeout:void 0,qh=typeof Promise=="function"?Promise:void 0,k1=typeof queueMicrotask=="function"?queueMicrotask:typeof qh<"u"?function(e){return qh.resolve(null).then(e).catch(w1)}:Yh;function w1(e){setTimeout(function(){throw e})}function Qa(e){return e==="head"}function Kh(e,n){var l=n,i=0;do{var d=l.nextSibling;if(e.removeChild(l),d&&d.nodeType===8)if(l=d.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(d),Sl(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")gs(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,gs(l);for(var m=l.firstChild;m;){var b=m.nextSibling,R=m.nodeName;m[_l]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&m.rel.toLowerCase()==="stylesheet"||l.removeChild(m),m=b}}else l==="body"&&gs(e.ownerDocument.body);l=d}while(l);Sl(n)}function Xh(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Yu(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Yu(l),Zo(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function E1(e,n,l,i){for(;e.nodeType===1;){var d=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[_l])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(m=e.getAttribute("rel"),m==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(m!==d.rel||e.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||e.getAttribute("title")!==(d.title==null?null:d.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(m=e.getAttribute("src"),(m!==(d.src==null?null:d.src)||e.getAttribute("type")!==(d.type==null?null:d.type)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&m&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var m=d.name==null?null:""+d.name;if(d.type==="hidden"&&e.getAttribute("name")===m)return e}else return e;if(e=In(e.nextSibling),e===null)break}return null}function C1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=In(e.nextSibling),e===null))return null;return e}function Qh(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=In(e.nextSibling),e===null))return null;return e}function qu(e){return e.data==="$?"||e.data==="$~"}function Ku(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function N1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function In(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var Xu=null;function Zh(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return In(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function Jh(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function ex(e,n,l){switch(n=Ki(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function gs(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Zo(e)}var Hn=new Map,tx=new Set;function Xi(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ca=B.d;B.d={f:T1,r:R1,D:A1,C:M1,L:L1,m:z1,X:_1,S:D1,M:O1};function T1(){var e=Ca.f(),n=$i();return e||n}function R1(e){var n=$r(e);n!==null&&n.tag===5&&n.type==="form"?vm(n):Ca.r(e)}var yl=typeof document>"u"?null:document;function nx(e,n,l){var i=yl;if(i&&typeof n=="string"&&n){var d=Mn(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),tx.has(d)||(tx.add(d),e={rel:e,crossOrigin:l,href:n},i.querySelector(d)===null&&(n=i.createElement("link"),Yt(n,"link",e),Ut(n),i.head.appendChild(n)))}}function A1(e){Ca.D(e),nx("dns-prefetch",e,null)}function M1(e,n){Ca.C(e,n),nx("preconnect",e,n)}function L1(e,n,l){Ca.L(e,n,l);var i=yl;if(i&&e&&n){var d='link[rel="preload"][as="'+Mn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Mn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Mn(l.imageSizes)+'"]')):d+='[href="'+Mn(e)+'"]';var m=d;switch(n){case"style":m=bl(e);break;case"script":m=jl(e)}Hn.has(m)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Hn.set(m,e),i.querySelector(d)!==null||n==="style"&&i.querySelector(vs(m))||n==="script"&&i.querySelector(ys(m))||(n=i.createElement("link"),Yt(n,"link",e),Ut(n),i.head.appendChild(n)))}}function z1(e,n){Ca.m(e,n);var l=yl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+Mn(i)+'"][href="'+Mn(e)+'"]',m=d;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=jl(e)}if(!Hn.has(m)&&(e=v({rel:"modulepreload",href:e},n),Hn.set(m,e),l.querySelector(d)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(ys(m)))return}i=l.createElement("link"),Yt(i,"link",e),Ut(i),l.head.appendChild(i)}}}function D1(e,n,l){Ca.S(e,n,l);var i=yl;if(i&&e){var d=Vr(i).hoistableStyles,m=bl(e);n=n||"default";var b=d.get(m);if(!b){var R={loading:0,preload:null};if(b=i.querySelector(vs(m)))R.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Hn.get(m))&&Qu(e,l);var $=b=i.createElement("link");Ut($),Yt($,"link",e),$._p=new Promise(function(Z,se){$.onload=Z,$.onerror=se}),$.addEventListener("load",function(){R.loading|=1}),$.addEventListener("error",function(){R.loading|=2}),R.loading|=4,Qi(b,n,i)}b={type:"stylesheet",instance:b,count:1,state:R},d.set(m,b)}}}function _1(e,n){Ca.X(e,n);var l=yl;if(l&&e){var i=Vr(l).hoistableScripts,d=jl(e),m=i.get(d);m||(m=l.querySelector(ys(d)),m||(e=v({src:e,async:!0},n),(n=Hn.get(d))&&Zu(e,n),m=l.createElement("script"),Ut(m),Yt(m,"link",e),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},i.set(d,m))}}function O1(e,n){Ca.M(e,n);var l=yl;if(l&&e){var i=Vr(l).hoistableScripts,d=jl(e),m=i.get(d);m||(m=l.querySelector(ys(d)),m||(e=v({src:e,async:!0,type:"module"},n),(n=Hn.get(d))&&Zu(e,n),m=l.createElement("script"),Ut(m),Yt(m,"link",e),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},i.set(d,m))}}function ax(e,n,l,i){var d=(d=ce.current)?Xi(d):null;if(!d)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=bl(l.href),l=Vr(d).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=bl(l.href);var m=Vr(d).hoistableStyles,b=m.get(e);if(b||(d=d.ownerDocument||d,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,b),(m=d.querySelector(vs(e)))&&!m._p&&(b.instance=m,b.state.loading=5),Hn.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},Hn.set(e,l),m||B1(d,e,l,b.state))),n&&i===null)throw Error(o(528,""));return b}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=jl(l),l=Vr(d).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function bl(e){return'href="'+Mn(e)+'"'}function vs(e){return'link[rel="stylesheet"]['+e+"]"}function rx(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function B1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),Yt(n,"link",l),Ut(n),e.head.appendChild(n))}function jl(e){return'[src="'+Mn(e)+'"]'}function ys(e){return"script[async]"+e}function lx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+Mn(l.href)+'"]');if(i)return n.instance=i,Ut(i),i;var d=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Ut(i),Yt(i,"style",d),Qi(i,l.precedence,e),n.instance=i;case"stylesheet":d=bl(l.href);var m=e.querySelector(vs(d));if(m)return n.state.loading|=4,n.instance=m,Ut(m),m;i=rx(l),(d=Hn.get(d))&&Qu(i,d),m=(e.ownerDocument||e).createElement("link"),Ut(m);var b=m;return b._p=new Promise(function(R,$){b.onload=R,b.onerror=$}),Yt(m,"link",i),n.state.loading|=4,Qi(m,l.precedence,e),n.instance=m;case"script":return m=jl(l.src),(d=e.querySelector(ys(m)))?(n.instance=d,Ut(d),d):(i=l,(d=Hn.get(m))&&(i=v({},l),Zu(i,d)),e=e.ownerDocument||e,d=e.createElement("script"),Ut(d),Yt(d,"link",i),e.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,Qi(i,l.precedence,e));return n.instance}function Qi(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=i.length?i[i.length-1]:null,m=d,b=0;b<i.length;b++){var R=i[b];if(R.dataset.precedence===n)m=R;else if(m!==d)break}m?m.parentNode.insertBefore(e,m.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function Qu(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function Zu(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var Zi=null;function sx(e,n,l){if(Zi===null){var i=new Map,d=Zi=new Map;d.set(l,i)}else d=Zi,i=d.get(l),i||(i=new Map,d.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),d=0;d<l.length;d++){var m=l[d];if(!(m[_l]||m[Pt]||e==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var b=m.getAttribute(n)||"";b=e+b;var R=i.get(b);R?R.push(m):i.set(b,[m])}}return i}function ix(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function I1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function ox(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function H1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=bl(i.href),m=n.querySelector(vs(d));if(m){n=m._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=Ji.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=m,Ut(m);return}m=n.ownerDocument||n,i=rx(i),(d=Hn.get(d))&&Qu(i,d),m=m.createElement("link"),Ut(m);var b=m;b._p=new Promise(function(R,$){b.onload=R,b.onerror=$}),Yt(m,"link",i),l.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Ji.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var Ju=0;function U1(e,n){return e.stylesheets&&e.count===0&&to(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&to(e,e.stylesheets),e.unsuspend){var m=e.unsuspend;e.unsuspend=null,m()}},6e4+n);0<e.imgBytes&&Ju===0&&(Ju=62500*b1());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&to(e,e.stylesheets),e.unsuspend)){var m=e.unsuspend;e.unsuspend=null,m()}},(e.imgBytes>Ju?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(d)}}:null}function Ji(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)to(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var eo=null;function to(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,eo=new Map,n.forEach($1,e),eo=null,Ji.call(e))}function $1(e,n){if(!(n.state.loading&4)){var l=eo.get(e);if(l)var i=l.get(null);else{l=new Map,eo.set(e,l);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<d.length;m++){var b=d[m];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(l.set(b.dataset.precedence,b),i=b)}i&&l.set(null,i)}d=n.instance,b=d.getAttribute("data-precedence"),m=l.get(b)||i,m===i&&l.set(null,d),l.set(b,d),this.count++,i=Ji.bind(this),d.addEventListener("load",i),d.addEventListener("error",i),m?m.parentNode.insertBefore(d,m.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(d,e.firstChild)),n.state.loading|=4}}var bs={$$typeof:D,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function V1(e,n,l,i,d,m,b,R,$){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=La(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=La(0),this.hiddenUpdates=La(null),this.identifierPrefix=i,this.onUncaughtError=d,this.onCaughtError=m,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=$,this.incompleteTransitions=new Map}function cx(e,n,l,i,d,m,b,R,$,Z,se,oe){return e=new V1(e,n,l,b,$,Z,se,oe,R),n=1,m===!0&&(n|=24),m=vn(3,null,null,n),e.current=m,m.stateNode=e,n=Lc(),n.refCount++,e.pooledCache=n,n.refCount++,m.memoizedState={element:i,isDehydrated:l,cache:n},Oc(m),e}function ux(e){return e?(e=Zr,e):Zr}function dx(e,n,l,i,d,m){d=ux(d),i.context===null?i.context=d:i.pendingContext=d,i=Ua(n),i.payload={element:l},m=m===void 0?null:m,m!==null&&(i.callback=m),l=$a(e,i,n),l!==null&&(hn(l,e,n),Zl(l,e,n))}function fx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function ed(e,n){fx(e,n),(e=e.alternate)&&fx(e,n)}function px(e){if(e.tag===13||e.tag===31){var n=xr(e,67108864);n!==null&&hn(n,e,67108864),ed(e,67108864)}}function mx(e){if(e.tag===13||e.tag===31){var n=kn();n=Dl(n);var l=xr(e,n);l!==null&&hn(l,e,n),ed(e,n)}}var no=!0;function P1(e,n,l,i){var d=M.T;M.T=null;var m=B.p;try{B.p=2,td(e,n,l,i)}finally{B.p=m,M.T=d}}function F1(e,n,l,i){var d=M.T;M.T=null;var m=B.p;try{B.p=8,td(e,n,l,i)}finally{B.p=m,M.T=d}}function td(e,n,l,i){if(no){var d=nd(i);if(d===null)$u(e,n,i,ao,l),xx(e,i);else if(W1(d,e,n,l,i))i.stopPropagation();else if(xx(e,i),n&4&&-1<G1.indexOf(e)){for(;d!==null;){var m=$r(d);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var b=Tn(m.pendingLanes);if(b!==0){var R=m;for(R.pendingLanes|=2,R.entangledLanes|=2;b;){var $=1<<31-dt(b);R.entanglements[1]|=$,b&=~$}ea(m),(tt&6)===0&&(Hi=Qe()+500,ms(0))}}break;case 31:case 13:R=xr(m,2),R!==null&&hn(R,m,2),$i(),ed(m,2)}if(m=nd(i),m===null&&$u(e,n,i,ao,l),m===d)break;d=m}d!==null&&i.stopPropagation()}else $u(e,n,i,null,l)}}function nd(e){return e=rc(e),ad(e)}var ao=null;function ad(e){if(ao=null,e=Ur(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=f(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return ao=e,null}function hx(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(xt()){case J:return 2;case Te:return 8;case Pe:case en:return 32;case Xn:return 268435456;default:return 32}default:return 32}}var rd=!1,Za=null,Ja=null,er=null,js=new Map,Ss=new Map,tr=[],G1="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 xx(e,n){switch(e){case"focusin":case"focusout":Za=null;break;case"dragenter":case"dragleave":Ja=null;break;case"mouseover":case"mouseout":er=null;break;case"pointerover":case"pointerout":js.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ss.delete(n.pointerId)}}function ks(e,n,l,i,d,m){return e===null||e.nativeEvent!==m?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:m,targetContainers:[d]},n!==null&&(n=$r(n),n!==null&&px(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function W1(e,n,l,i,d){switch(n){case"focusin":return Za=ks(Za,e,n,l,i,d),!0;case"dragenter":return Ja=ks(Ja,e,n,l,i,d),!0;case"mouseover":return er=ks(er,e,n,l,i,d),!0;case"pointerover":var m=d.pointerId;return js.set(m,ks(js.get(m)||null,e,n,l,i,d)),!0;case"gotpointercapture":return m=d.pointerId,Ss.set(m,ks(Ss.get(m)||null,e,n,l,i,d)),!0}return!1}function gx(e){var n=Ur(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=f(l),n!==null){e.blockedOn=n,Mf(e.priority,function(){mx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,Mf(e.priority,function(){mx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function ro(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=nd(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);ac=i,l.target.dispatchEvent(i),ac=null}else return n=$r(l),n!==null&&px(n),e.blockedOn=l,!1;n.shift()}return!0}function vx(e,n,l){ro(e)&&l.delete(n)}function Y1(){rd=!1,Za!==null&&ro(Za)&&(Za=null),Ja!==null&&ro(Ja)&&(Ja=null),er!==null&&ro(er)&&(er=null),js.forEach(vx),Ss.forEach(vx)}function lo(e,n){e.blockedOn===n&&(e.blockedOn=null,rd||(rd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Y1)))}var so=null;function yx(e){so!==e&&(so=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){so===e&&(so=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],d=e[n+2];if(typeof i!="function"){if(ad(i||l)===null)continue;break}var m=$r(l);m!==null&&(e.splice(n,3),n-=3,nu(m,{pending:!0,data:d,method:l.method,action:i},i,d))}}))}function Sl(e){function n($){return lo($,e)}Za!==null&&lo(Za,e),Ja!==null&&lo(Ja,e),er!==null&&lo(er,e),js.forEach(n),Ss.forEach(n);for(var l=0;l<tr.length;l++){var i=tr[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<tr.length&&(l=tr[0],l.blockedOn===null);)gx(l),l.blockedOn===null&&tr.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var d=l[i],m=l[i+1],b=d[cn]||null;if(typeof m=="function")b||yx(l);else if(b){var R=null;if(m&&m.hasAttribute("formAction")){if(d=m,b=m[cn]||null)R=b.formAction;else if(ad(d)!==null)continue}else R=b.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),yx(l)}}}function bx(){function e(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(b){return d=b})},focusReset:"manual",scroll:"manual"})}function n(){d!==null&&(d(),d=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,d=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),d!==null&&(d(),d=null)}}}function ld(e){this._internalRoot=e}io.prototype.render=ld.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=kn();dx(l,i,e,n,null,null)},io.prototype.unmount=ld.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;dx(e.current,2,null,e,null,null),$i(),n[Hr]=null}};function io(e){this._internalRoot=e}io.prototype.unstable_scheduleHydration=function(e){if(e){var n=Af();e={blockedOn:null,target:e,priority:n};for(var l=0;l<tr.length&&n!==0&&n<tr[l].priority;l++);tr.splice(l,0,e),l===0&&gx(e)}};var jx=r.version;if(jx!=="19.2.4")throw Error(o(527,jx,"19.2.4"));B.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=p(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var q1={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var oo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oo.isDisabled&&oo.supportsFiber)try{Fe=oo.inject(q1),nt=oo}catch{}}return Es.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",d=Tm,m=Rm,b=Am;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(d=n.onUncaughtError),n.onCaughtError!==void 0&&(m=n.onCaughtError),n.onRecoverableError!==void 0&&(b=n.onRecoverableError)),n=cx(e,1,!1,null,null,l,i,null,d,m,b,bx),e[Hr]=n.current,Uu(e),new ld(n)},Es.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,d="",m=Tm,b=Rm,R=Am,$=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(d=l.identifierPrefix),l.onUncaughtError!==void 0&&(m=l.onUncaughtError),l.onCaughtError!==void 0&&(b=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&($=l.formState)),n=cx(e,1,!0,n,l??null,i,d,$,m,b,R,bx),n.context=ux(null),l=n.current,i=kn(),i=Dl(i),d=Ua(i),d.callback=null,$a(l,d,i),l=i,n.current.lanes=l,Rn(n,l),ea(n),e[Hr]=n.current,Uu(e),new io(n)},Es.version="19.2.4",Es}var Mx;function a0(){if(Mx)return od.exports;Mx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),od.exports=n0(),od.exports}var r0=a0();/**
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 Lx="popstate";function zx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function l0(t={}){function r(c,u){let{pathname:f="/",search:h="",hash:g=""}=Rl(c.location.hash.substring(1));return!f.startsWith("/")&&!f.startsWith(".")&&(f="/"+f),Pd("",{pathname:f,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let f=c.document.querySelector("base"),h="";if(f&&f.getAttribute("href")){let g=c.location.href,p=g.indexOf("#");h=p===-1?g:g.slice(0,p)}return h+"#"+(typeof u=="string"?u:Os(u))}function o(c,u){Yn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return i0(r,s,o,t)}function Ht(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function Yn(t,r){if(!t){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function s0(){return Math.random().toString(36).substring(2,10)}function Dx(t,r){return{usr:t.state,key:t.key,idx:r,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Pd(t,r,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof r=="string"?Rl(r):r,state:s,key:r&&r.key||o||s0(),unstable_mask:c}}function Os({pathname:t="/",search:r="",hash:s=""}){return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function Rl(t){let r={};if(t){let s=t.indexOf("#");s>=0&&(r.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(r.search=t.substring(o),t=t.substring(0,o)),t&&(r.pathname=t)}return r}function i0(t,r,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,f=c.history,h="POP",g=null,p=y();p==null&&(p=0,f.replaceState({...f.state,idx:p},""));function y(){return(f.state||{idx:null}).idx}function v(){h="POP";let w=y(),N=w==null?null:w-p;p=w,g&&g({action:h,location:E.location,delta:N})}function j(w,N){h="PUSH";let A=zx(w)?w:Pd(E.location,w,N);s&&s(A,w),p=y()+1;let D=Dx(A,p),U=E.createHref(A.unstable_mask||A);try{f.pushState(D,"",U)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;c.location.assign(U)}u&&g&&g({action:h,location:E.location,delta:1})}function S(w,N){h="REPLACE";let A=zx(w)?w:Pd(E.location,w,N);s&&s(A,w),p=y();let D=Dx(A,p),U=E.createHref(A.unstable_mask||A);f.replaceState(D,"",U),u&&g&&g({action:h,location:E.location,delta:0})}function k(w){return o0(w)}let E={get action(){return h},get location(){return t(c,f)},listen(w){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(Lx,v),g=w,()=>{c.removeEventListener(Lx,v),g=null}},createHref(w){return r(c,w)},createURL:k,encodeLocation(w){let N=k(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:j,replace:S,go(w){return f.go(w)}};return E}function o0(t,r=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ht(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Os(t);return o=o.replace(/ $/,"%20"),!r&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function nv(t,r,s="/"){return c0(t,r,s,!1)}function c0(t,r,s,o){let c=typeof r=="string"?Rl(r):r,u=Ta(c.pathname||"/",s);if(u==null)return null;let f=av(t);u0(f);let h=null;for(let g=0;h==null&&g<f.length;++g){let p=j0(u);h=y0(f[g],p,o)}return h}function av(t,r=[],s=[],o="",c=!1){let u=(f,h,g=c,p)=>{let y={relativePath:p===void 0?f.path||"":p,caseSensitive:f.caseSensitive===!0,childrenIndex:h,route:f};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Ht(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=ra([o,y.relativePath]),j=s.concat(y);f.children&&f.children.length>0&&(Ht(f.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),av(f.children,r,j,v,g)),!(f.path==null&&!f.index)&&r.push({path:v,score:g0(v,f.index),routesMeta:j})};return t.forEach((f,h)=>{var g;if(f.path===""||!((g=f.path)!=null&&g.includes("?")))u(f,h);else for(let p of rv(f.path))u(f,h,!0,p)}),r}function rv(t){let r=t.split("/");if(r.length===0)return[];let[s,...o]=r,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let f=rv(o.join("/")),h=[];return h.push(...f.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...f),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function u0(t){t.sort((r,s)=>r.score!==s.score?s.score-r.score:v0(r.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var d0=/^:[\w-]+$/,f0=3,p0=2,m0=1,h0=10,x0=-2,_x=t=>t==="*";function g0(t,r){let s=t.split("/"),o=s.length;return s.some(_x)&&(o+=x0),r&&(o+=p0),s.filter(c=>!_x(c)).reduce((c,u)=>c+(d0.test(u)?f0:u===""?m0:h0),o)}function v0(t,r){return t.length===r.length&&t.slice(0,-1).every((o,c)=>o===r[c])?t[t.length-1]-r[r.length-1]:0}function y0(t,r,s=!1){let{routesMeta:o}=t,c={},u="/",f=[];for(let h=0;h<o.length;++h){let g=o[h],p=h===o.length-1,y=u==="/"?r:r.slice(u.length)||"/",v=To({path:g.relativePath,caseSensitive:g.caseSensitive,end:p},y),j=g.route;if(!v&&p&&s&&!o[o.length-1].route.index&&(v=To({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),f.push({params:c,pathname:ra([u,v.pathname]),pathnameBase:E0(ra([u,v.pathnameBase])),route:j}),v.pathnameBase!=="/"&&(u=ra([u,v.pathnameBase]))}return f}function To(t,r){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=b0(t.path,t.caseSensitive,t.end),c=r.match(s);if(!c)return null;let u=c[0],f=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((p,{paramName:y,isOptional:v},j)=>{if(y==="*"){let k=h[j]||"";f=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[j];return v&&!S?p[y]=void 0:p[y]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:u,pathnameBase:f,pattern:t}}function b0(t,r=!1,s=!0){Yn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(f,h,g,p,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(p+f.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,r?void 0:"i"),o]}function j0(t){try{return t.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Yn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),t}}function Ta(t,r){if(r==="/")return t;if(!t.toLowerCase().startsWith(r.toLowerCase()))return null;let s=r.endsWith("/")?r.length-1:r.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var S0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function k0(t,r="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?Rl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Ox(s.substring(1),"/"):u=Ox(s,r)):u=r,{pathname:u,search:C0(o),hash:N0(c)}}function Ox(t,r){let s=r.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function fd(t,r,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${r}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function w0(t){return t.filter((r,s)=>s===0||r.route.path&&r.route.path.length>0)}function lv(t){let r=w0(t);return r.map((s,o)=>o===r.length-1?s.pathname:s.pathnameBase)}function of(t,r,s,o=!1){let c;typeof t=="string"?c=Rl(t):(c={...t},Ht(!c.pathname||!c.pathname.includes("?"),fd("?","pathname","search",c)),Ht(!c.pathname||!c.pathname.includes("#"),fd("#","pathname","hash",c)),Ht(!c.search||!c.search.includes("#"),fd("#","search","hash",c)));let u=t===""||c.pathname==="",f=u?"/":c.pathname,h;if(f==null)h=s;else{let v=r.length-1;if(!o&&f.startsWith("..")){let j=f.split("/");for(;j[0]==="..";)j.shift(),v-=1;c.pathname=j.join("/")}h=v>=0?r[v]:"/"}let g=k0(c,h),p=f&&f!=="/"&&f.endsWith("/"),y=(u||f===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(p||y)&&(g.pathname+="/"),g}var ra=t=>t.join("/").replace(/\/\/+/g,"/"),E0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),C0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,N0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,T0=class{constructor(t,r,s,o=!1){this.status=t,this.statusText=r||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function R0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function A0(t){return t.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var sv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function iv(t,r){let s=t;if(typeof s!="string"||!S0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(sv)try{let u=new URL(window.location.href),f=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Ta(f.pathname,r);f.origin===u.origin&&h!=null?s=h+f.search+f.hash:c=!0}catch{Yn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var ov=["POST","PUT","PATCH","DELETE"];new Set(ov);var M0=["GET",...ov];new Set(M0);var Al=x.createContext(null);Al.displayName="DataRouter";var Do=x.createContext(null);Do.displayName="DataRouterState";var L0=x.createContext(!1),cv=x.createContext({isTransitioning:!1});cv.displayName="ViewTransition";var z0=x.createContext(new Map);z0.displayName="Fetchers";var D0=x.createContext(null);D0.displayName="Await";var Vn=x.createContext(null);Vn.displayName="Navigation";var _o=x.createContext(null);_o.displayName="Location";var Ra=x.createContext({outlet:null,matches:[],isDataRoute:!1});Ra.displayName="Route";var cf=x.createContext(null);cf.displayName="RouteError";var uv="REACT_ROUTER_ERROR",_0="REDIRECT",O0="ROUTE_ERROR_RESPONSE";function B0(t){if(t.startsWith(`${uv}:${_0}:{`))try{let r=JSON.parse(t.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function I0(t){if(t.startsWith(`${uv}:${O0}:{`))try{let r=JSON.parse(t.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new T0(r.status,r.statusText,r.data)}catch{}}function H0(t,{relative:r}={}){Ht(Fs(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=x.useContext(Vn),{hash:c,pathname:u,search:f}=Gs(t,{relative:r}),h=u;return s!=="/"&&(h=u==="/"?s:ra([s,u])),o.createHref({pathname:h,search:f,hash:c})}function Fs(){return x.useContext(_o)!=null}function ir(){return Ht(Fs(),"useLocation() may be used only in the context of a <Router> component."),x.useContext(_o).location}var dv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function fv(t){x.useContext(Vn).static||x.useLayoutEffect(t)}function U0(){let{isDataRoute:t}=x.useContext(Ra);return t?J0():$0()}function $0(){Ht(Fs(),"useNavigate() may be used only in the context of a <Router> component.");let t=x.useContext(Al),{basename:r,navigator:s}=x.useContext(Vn),{matches:o}=x.useContext(Ra),{pathname:c}=ir(),u=JSON.stringify(lv(o)),f=x.useRef(!1);return fv(()=>{f.current=!0}),x.useCallback((g,p={})=>{if(Yn(f.current,dv),!f.current)return;if(typeof g=="number"){s.go(g);return}let y=of(g,JSON.parse(u),c,p.relative==="path");t==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:ra([r,y.pathname])),(p.replace?s.replace:s.push)(y,p.state,p)},[r,s,u,c,t])}x.createContext(null);function Gs(t,{relative:r}={}){let{matches:s}=x.useContext(Ra),{pathname:o}=ir(),c=JSON.stringify(lv(s));return x.useMemo(()=>of(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function V0(t,r,s){Ht(Fs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=x.useContext(Vn),{matches:c}=x.useContext(Ra),u=c[c.length-1],f=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",p=u&&u.route;{let w=p&&p.path||"";mv(h,!p||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${w}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
60
+
61
+ Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let y=ir(),v;v=y;let j=v.pathname||"/",S=j;if(g!=="/"){let w=g.replace(/^\//,"").split("/");S="/"+j.replace(/^\//,"").split("/").slice(w.length).join("/")}let k=nv(t,{pathname:S});return Yn(p||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Yn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),Y0(k&&k.map(w=>Object.assign({},w,{params:Object.assign({},f,w.params),pathname:ra([g,o.encodeLocation?o.encodeLocation(w.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?g:ra([g,o.encodeLocation?o.encodeLocation(w.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,s)}function P0(){let t=Z0(),r=R0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},f=null;return console.error("Error handled by React Router default ErrorBoundary:",t),f=x.createElement(x.Fragment,null,x.createElement("p",null,"💿 Hey developer 👋"),x.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",x.createElement("code",{style:u},"ErrorBoundary")," or"," ",x.createElement("code",{style:u},"errorElement")," prop on your route.")),x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},r),s?x.createElement("pre",{style:c},s):null,f)}var F0=x.createElement(P0,null),pv=class extends x.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){this.props.onError?this.props.onError(t,r):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=I0(t.digest);s&&(t=s)}let r=t!==void 0?x.createElement(Ra.Provider,{value:this.props.routeContext},x.createElement(cf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?x.createElement(G0,{error:t},r):r}};pv.contextType=L0;var pd=new WeakMap;function G0({children:t,error:r}){let{basename:s}=x.useContext(Vn);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=B0(r.digest);if(o){let c=pd.get(r);if(c)throw c;let u=iv(o.location,s);if(sv&&!pd.get(r))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const f=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw pd.set(r,f),f}return x.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function W0({routeContext:t,match:r,children:s}){let o=x.useContext(Al);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),x.createElement(Ra.Provider,{value:t},s)}function Y0(t,r=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(r.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Ht(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let f=!1,h=-1;if(s&&o){f=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:j,errors:S}=o,k=v.route.loader&&!j.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(f=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,p=o&&g?(y,v)=>{var j,S;g(y,{location:o.location,params:((S=(j=o.matches)==null?void 0:j[0])==null?void 0:S.params)??{},unstable_pattern:A0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,j)=>{let S,k=!1,E=null,w=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||F0,f&&(h<0&&j===0?(mv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,w=null):h===j&&(k=!0,w=v.route.hydrateFallbackElement||null)));let N=r.concat(c.slice(0,j+1)),A=()=>{let D;return S?D=E:k?D=w:v.route.Component?D=x.createElement(v.route.Component,null):v.route.element?D=v.route.element:D=y,x.createElement(W0,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:D})};return o&&(v.route.ErrorBoundary||v.route.errorElement||j===0)?x.createElement(pv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:A(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:p}):A()},null)}function uf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function q0(t){let r=x.useContext(Al);return Ht(r,uf(t)),r}function K0(t){let r=x.useContext(Do);return Ht(r,uf(t)),r}function X0(t){let r=x.useContext(Ra);return Ht(r,uf(t)),r}function df(t){let r=X0(t),s=r.matches[r.matches.length-1];return Ht(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Q0(){return df("useRouteId")}function Z0(){var o;let t=x.useContext(cf),r=K0("useRouteError"),s=df("useRouteError");return t!==void 0?t:(o=r.errors)==null?void 0:o[s]}function J0(){let{router:t}=q0("useNavigate"),r=df("useNavigate"),s=x.useRef(!1);return fv(()=>{s.current=!0}),x.useCallback(async(c,u={})=>{Yn(s.current,dv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:r,...u}))},[t,r])}var Bx={};function mv(t,r,s){!r&&!Bx[t]&&(Bx[t]=!0,Yn(!1,s))}x.memo(ej);function ej({routes:t,future:r,state:s,isStatic:o,onError:c}){return V0(t,void 0,{state:s,isStatic:o,onError:c})}function tj({basename:t="/",children:r=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:f}){Ht(!Fs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=x.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:f,future:{}}),[h,c,u,f]);typeof s=="string"&&(s=Rl(s));let{pathname:p="/",search:y="",hash:v="",state:j=null,key:S="default",unstable_mask:k}=s,E=x.useMemo(()=>{let w=Ta(p,h);return w==null?null:{location:{pathname:w,search:y,hash:v,state:j,key:S,unstable_mask:k},navigationType:o}},[h,p,y,v,j,S,o,k]);return Yn(E!=null,`<Router basename="${h}"> is not able to match the URL "${p}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:x.createElement(Vn.Provider,{value:g},x.createElement(_o.Provider,{children:r,value:E}))}var jo="get",So="application/x-www-form-urlencoded";function Oo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function nj(t){return Oo(t)&&t.tagName.toLowerCase()==="button"}function aj(t){return Oo(t)&&t.tagName.toLowerCase()==="form"}function rj(t){return Oo(t)&&t.tagName.toLowerCase()==="input"}function lj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function sj(t,r){return t.button===0&&(!r||r==="_self")&&!lj(t)}var co=null;function ij(){if(co===null)try{new FormData(document.createElement("form"),0),co=!1}catch{co=!0}return co}var oj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function md(t){return t!=null&&!oj.has(t)?(Yn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${So}"`),null):t}function cj(t,r){let s,o,c,u,f;if(aj(t)){let h=t.getAttribute("action");o=h?Ta(h,r):null,s=t.getAttribute("method")||jo,c=md(t.getAttribute("enctype"))||So,u=new FormData(t)}else if(nj(t)||rj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Ta(g,r):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||jo,c=md(t.getAttribute("formenctype"))||md(h.getAttribute("enctype"))||So,u=new FormData(h,t),!ij()){let{name:p,type:y,value:v}=t;if(y==="image"){let j=p?`${p}.`:"";u.append(`${j}x`,"0"),u.append(`${j}y`,"0")}else p&&u.append(p,v)}}else{if(Oo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=jo,o=null,c=So,f=t}return u&&c==="text/plain"&&(f=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:f}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ff(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function uj(t,r,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:r&&Ta(c.pathname,r)==="/"?c.pathname=`${r.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function dj(t,r){if(t.id in r)return r[t.id];try{let s=await import(t.module);return r[t.id]=s,s}catch(s){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function fj(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 pj(t,r,s){let o=await Promise.all(t.map(async c=>{let u=r.routes[c.route.id];if(u){let f=await dj(u,s);return f.links?f.links():[]}return[]}));return gj(o.flat(1).filter(fj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Ix(t,r,s,o,c,u){let f=(g,p)=>s[p]?g.route.id!==s[p].route.id:!0,h=(g,p)=>{var y;return s[p].pathname!==g.pathname||((y=s[p].route.path)==null?void 0:y.endsWith("*"))&&s[p].params["*"]!==g.params["*"]};return u==="assets"?r.filter((g,p)=>f(g,p)||h(g,p)):u==="data"?r.filter((g,p)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(f(g,p)||h(g,p))return!0;if(g.route.shouldRevalidate){let j=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof j=="boolean")return j}return!0}):[]}function mj(t,r,{includeHydrateFallback:s}={}){return hj(t.map(o=>{let c=r.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function hj(t){return[...new Set(t)]}function xj(t){let r={},s=Object.keys(t).sort();for(let o of s)r[o]=t[o];return r}function gj(t,r){let s=new Set;return new Set(r),t.reduce((o,c)=>{let u=JSON.stringify(xj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function hv(){let t=x.useContext(Al);return ff(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function vj(){let t=x.useContext(Do);return ff(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var pf=x.createContext(void 0);pf.displayName="FrameworkContext";function xv(){let t=x.useContext(pf);return ff(t,"You must render this element inside a <HydratedRouter> element"),t}function yj(t,r){let s=x.useContext(pf),[o,c]=x.useState(!1),[u,f]=x.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:p,onMouseLeave:y,onTouchStart:v}=r,j=x.useRef(null);x.useEffect(()=>{if(t==="render"&&f(!0),t==="viewport"){let E=N=>{N.forEach(A=>{f(A.isIntersecting)})},w=new IntersectionObserver(E,{threshold:.5});return j.current&&w.observe(j.current),()=>{w.disconnect()}}},[t]),x.useEffect(()=>{if(o){let E=setTimeout(()=>{f(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),f(!1)};return s?t!=="intent"?[u,j,{}]:[u,j,{onFocus:Cs(h,S),onBlur:Cs(g,k),onMouseEnter:Cs(p,S),onMouseLeave:Cs(y,k),onTouchStart:Cs(v,S)}]:[!1,j,{}]}function Cs(t,r){return s=>{t&&t(s),s.defaultPrevented||r(s)}}function bj({page:t,...r}){let{router:s}=hv(),o=x.useMemo(()=>nv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?x.createElement(Sj,{page:t,matches:o,...r}):null}function jj(t){let{manifest:r,routeModules:s}=xv(),[o,c]=x.useState([]);return x.useEffect(()=>{let u=!1;return pj(t,r,s).then(f=>{u||c(f)}),()=>{u=!0}},[t,r,s]),o}function Sj({page:t,matches:r,...s}){let o=ir(),{future:c,manifest:u,routeModules:f}=xv(),{basename:h}=hv(),{loaderData:g,matches:p}=vj(),y=x.useMemo(()=>Ix(t,r,p,u,o,"data"),[t,r,p,u,o]),v=x.useMemo(()=>Ix(t,r,p,u,o,"assets"),[t,r,p,u,o]),j=x.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,w=!1;if(r.forEach(A=>{var U;let D=u.routes[A.route.id];!D||!D.hasLoader||(!y.some(L=>L.route.id===A.route.id)&&A.route.id in g&&((U=f[A.route.id])!=null&&U.shouldRevalidate)||D.hasClientLoader?w=!0:E.add(A.route.id))}),E.size===0)return[];let N=uj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return w&&E.size>0&&N.searchParams.set("_routes",r.filter(A=>E.has(A.route.id)).map(A=>A.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,r,t,f]),S=x.useMemo(()=>mj(v,u),[v,u]),k=jj(v);return x.createElement(x.Fragment,null,j.map(E=>x.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>x.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:w})=>x.createElement("link",{key:E,nonce:s.nonce,...w,crossOrigin:w.crossOrigin??s.crossOrigin})))}function kj(...t){return r=>{t.forEach(s=>{typeof s=="function"?s(r):s!=null&&(s.current=r)})}}var wj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wj&&(window.__reactRouterVersion="7.13.1")}catch{}function Ej({basename:t,children:r,unstable_useTransitions:s,window:o}){let c=x.useRef();c.current==null&&(c.current=l0({window:o,v5Compat:!0}));let u=c.current,[f,h]=x.useState({action:u.action,location:u.location}),g=x.useCallback(p=>{s===!1?h(p):x.startTransition(()=>h(p))},[s]);return x.useLayoutEffect(()=>u.listen(g),[u,g]),x.createElement(tj,{basename:t,children:r,location:f.location,navigationType:f.action,navigator:u,unstable_useTransitions:s})}var gv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vv=x.forwardRef(function({onClick:r,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:f,unstable_mask:h,state:g,target:p,to:y,preventScrollReset:v,viewTransition:j,unstable_defaultShouldRevalidate:S,...k},E){let{basename:w,navigator:N,unstable_useTransitions:A}=x.useContext(Vn),D=typeof y=="string"&&gv.test(y),U=iv(y,w);y=U.to;let L=H0(y,{relative:c}),F=ir(),C=null;if(h){let H=of(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);w!=="/"&&(H.pathname=H.pathname==="/"?w:ra([w,H.pathname])),C=N.createHref(H)}let[O,T,_]=yj(o,k),I=Rj(y,{replace:f,unstable_mask:h,state:g,target:p,preventScrollReset:v,relative:c,viewTransition:j,unstable_defaultShouldRevalidate:S,unstable_useTransitions:A});function K(H){r&&r(H),H.defaultPrevented||I(H)}let Q=!(U.isExternal||u),q=x.createElement("a",{...k,..._,href:(Q?C:void 0)||U.absoluteURL||L,onClick:Q?K:r,ref:kj(E,T),target:p,"data-discover":!D&&s==="render"?"true":void 0});return O&&!D?x.createElement(x.Fragment,null,q,x.createElement(bj,{page:L})):q});vv.displayName="Link";var Cj=x.forwardRef(function({"aria-current":r="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:f,viewTransition:h,children:g,...p},y){let v=Gs(f,{relative:p.relative}),j=ir(),S=x.useContext(Do),{navigator:k,basename:E}=x.useContext(Vn),w=S!=null&&Dj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,A=j.pathname,D=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(A=A.toLowerCase(),D=D?D.toLowerCase():null,N=N.toLowerCase()),D&&E&&(D=Ta(D,E)||D);const U=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let L=A===N||!c&&A.startsWith(N)&&A.charAt(U)==="/",F=D!=null&&(D===N||!c&&D.startsWith(N)&&D.charAt(N.length)==="/"),C={isActive:L,isPending:F,isTransitioning:w},O=L?r:void 0,T;typeof o=="function"?T=o(C):T=[o,L?"active":null,F?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let _=typeof u=="function"?u(C):u;return x.createElement(vv,{...p,"aria-current":O,className:T,ref:y,style:_,to:f,viewTransition:h},typeof g=="function"?g(C):g)});Cj.displayName="NavLink";var Nj=x.forwardRef(({discover:t="render",fetcherKey:r,navigate:s,reloadDocument:o,replace:c,state:u,method:f=jo,action:h,onSubmit:g,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:j,...S},k)=>{let{unstable_useTransitions:E}=x.useContext(Vn),w=Lj(),N=zj(h,{relative:p}),A=f.toLowerCase()==="get"?"get":"post",D=typeof h=="string"&&gv.test(h),U=L=>{if(g&&g(L),L.defaultPrevented)return;L.preventDefault();let F=L.nativeEvent.submitter,C=(F==null?void 0:F.getAttribute("formmethod"))||f,O=()=>w(F||L.currentTarget,{fetcherKey:r,method:C,navigate:s,replace:c,state:u,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:j});E&&s!==!1?x.startTransition(()=>O()):O()};return x.createElement("form",{ref:k,method:A,action:N,onSubmit:o?g:U,...S,"data-discover":!D&&t==="render"?"true":void 0})});Nj.displayName="Form";function Tj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yv(t){let r=x.useContext(Al);return Ht(r,Tj(t)),r}function Rj(t,{target:r,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:p}={}){let y=U0(),v=ir(),j=Gs(t,{relative:f});return x.useCallback(S=>{if(sj(S,r)){S.preventDefault();let k=s!==void 0?s:Os(v)===Os(j),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:f,viewTransition:h,unstable_defaultShouldRevalidate:g});p?x.startTransition(()=>E()):E()}},[v,y,j,s,o,c,r,t,u,f,h,g,p])}var Aj=0,Mj=()=>`__${String(++Aj)}__`;function Lj(){let{router:t}=yv("useSubmit"),{basename:r}=x.useContext(Vn),s=Q0(),o=t.fetch,c=t.navigate;return x.useCallback(async(u,f={})=>{let{action:h,method:g,encType:p,formData:y,body:v}=cj(u,r);if(f.navigate===!1){let j=f.fetcherKey||Mj();await o(j,s,f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:v,formMethod:f.method||g,formEncType:f.encType||p,flushSync:f.flushSync})}else await c(f.action||h,{unstable_defaultShouldRevalidate:f.unstable_defaultShouldRevalidate,preventScrollReset:f.preventScrollReset,formData:y,body:v,formMethod:f.method||g,formEncType:f.encType||p,replace:f.replace,state:f.state,fromRouteId:s,flushSync:f.flushSync,viewTransition:f.viewTransition})},[o,c,r,s])}function zj(t,{relative:r}={}){let{basename:s}=x.useContext(Vn),o=x.useContext(Ra);Ht(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Gs(t||".",{relative:r})},f=ir();if(t==null){u.search=f.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:ra([s,u.pathname])),Os(u)}function Dj(t,{relative:r}={}){let s=x.useContext(cv);Ht(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=yv("useViewTransitionState"),c=Gs(t,{relative:r});if(!s.isTransitioning)return!1;let u=Ta(s.currentLocation.pathname,o)||s.currentLocation.pathname,f=Ta(s.nextLocation.pathname,o)||s.nextLocation.pathname;return To(c.pathname,f)!=null||To(c.pathname,u)!=null}var Bo=tv();const _j=ev(Bo),Oj="modulepreload",Bj=function(t){return"/"+t},Hx={},Io=function(r,s,o){let c=Promise.resolve();if(s&&s.length>0){let f=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=f(s.map(p=>{if(p=Bj(p),p in Hx)return;Hx[p]=!0;const y=p.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${v}`))return;const j=document.createElement("link");if(j.rel=y?"stylesheet":Oj,y||(j.as="script"),j.crossOrigin="",j.href=p,g&&j.setAttribute("nonce",g),document.head.appendChild(j),y)return new Promise((S,k)=>{j.addEventListener("load",S),j.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}function u(f){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=f,window.dispatchEvent(h),!h.defaultPrevented)throw f}return c.then(f=>{for(const h of f||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})},Ux={own:"authoring-project",installed:"available-project",global:"available-personal"},Fd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Ij(t){if(typeof t=="string"){if(Fd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Ux,t))return Ux[t]}return"authoring-project"}function Hj(t){return t.startsWith("available-")?"available":"authoring"}function Uj(t){const r=t.indexOf("-");return t.slice(r+1)}const ta="";class Ls extends Error{constructor(r,s){super(r),this.name="ApiError",this.status=s}}async function Ue(t,r){const s=await fetch(`${ta}${t}`,r);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Ls(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function an(t){return typeof t=="string"&&t.length>0?t:null}function $j(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function hd(t){if(!Array.isArray(t))return null;const r=t.filter(s=>typeof s=="string"&&s.length>0);return r.length>0?r:null}function Vj(t){const r=t??{};let s;r.origin==="source"||r.origin==="installed"?s=r.origin:(s="source",console.warn(`[api.getSkills] skill ${String(r.plugin)}/${String(r.skill)} has invalid origin=${JSON.stringify(r.origin)}; defaulting to 'source'`));let o;r.scope==="own"||r.scope==="installed"||r.scope==="global"?o=r.scope:o=s==="installed"?"installed":"own";let c;r.installMethod==="authored"||r.installMethod==="copied"||r.installMethod==="symlinked"?c=r.installMethod:c=o==="own"?"authored":"copied";const u=typeof r.scopeV2=="string"&&Fd.has(r.scopeV2)?r.scopeV2:Ij(r.scope),f=Hj(u),h=Uj(u),g=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let p;r.shadowedBy===null?p=null:typeof r.shadowedBy=="string"&&Fd.has(r.shadowedBy)?p=r.shadowedBy:p=void 0;const y={plugin:typeof r.plugin=="string"?r.plugin:"",skill:typeof r.skill=="string"?r.skill:"",dir:typeof r.dir=="string"?r.dir:"",hasEvals:!!r.hasEvals,hasBenchmark:!!r.hasBenchmark,evalCount:typeof r.evalCount=="number"?r.evalCount:0,assertionCount:typeof r.assertionCount=="number"?r.assertionCount:0,benchmarkStatus:r.benchmarkStatus==="pass"||r.benchmarkStatus==="fail"||r.benchmarkStatus==="pending"||r.benchmarkStatus==="stale"||r.benchmarkStatus==="missing"?r.benchmarkStatus:"missing",lastBenchmark:typeof r.lastBenchmark=="string"?r.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:an(r.symlinkTarget),installMethod:c,scopeV2:u,group:f,source:h,pluginName:an(r.pluginName),pluginNamespace:an(r.pluginNamespace),pluginMarketplace:an(r.pluginMarketplace),pluginManifestPath:an(r.pluginManifestPath),pluginVersion:an(r.pluginVersion),precedenceRank:g,shadowedBy:p,description:an(r.description),version:an(r.version),category:an(r.category),author:an(r.author),license:an(r.license),homepage:an(r.homepage),tags:hd(r.tags),deps:hd(r.deps),mcpDeps:hd(r.mcpDeps),entryPoint:an(r.entryPoint),lastModified:an(r.lastModified),sizeBytes:$j(r.sizeBytes),sourceAgent:an(r.sourceAgent)};if(r.provenance&&typeof r.provenance=="object"){const v=r.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else r.provenance===null&&(y.provenance=null);return typeof r.updateAvailable=="boolean"&&(y.updateAvailable=r.updateAvailable),typeof r.currentVersion=="string"&&(y.currentVersion=r.currentVersion),typeof r.latestVersion=="string"&&(y.latestVersion=r.latestVersion),typeof r.pinnedVersion=="string"&&(y.pinnedVersion=r.pinnedVersion),y}const Ee={getConfig(){return Ue("/api/config")},setConfig(t,r){return Ue("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:r})})},async getSkills(t){const r=new URLSearchParams;t!=null&&t.scope&&r.set("scope",t.scope),t!=null&&t.agent&&r.set("agent",t.agent);const s=r.toString(),o=await Ue(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Vj):[]},getAgents(){return Ue("/api/agents")},getSkillDetail(t,r){return Ue(`/api/skills/${t}/${r}`)},async getEvals(t,r){const s=await Ue(`/api/skills/${t}/${r}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:r,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,r){return Ue(`/api/skills/${t}/${r}/evals`)},getActivationHistoryEnvelope(t,r){return Ue(`/api/skills/${t}/${r}/activation-history`)},saveEvals(t,r,s){return Ue(`/api/skills/${t}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,r){return Ue(`/api/skills/${t}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,r){const s=await fetch(`${ta}/api/skills/${t}/${r}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Ls(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,r,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return Ue(`/api/skills/${t}/${r}/history${c?"?"+c:""}`)},getHistoryEntry(t,r,s){return Ue(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`)},compareRuns(t,r,s,o){return Ue(`/api/skills/${t}/${r}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,r,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return Ue(`/api/skills/${t}/${r}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,r,s){return Ue(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,r){return Ue(`/api/skills/${t}/${r}`,{method:"DELETE"})},improveSkill(t,r,s){return Ue(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,r,s){return Ue(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,r,s){return Ue(`/api/skills/${t}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,r){return Ue(`/api/skills/${t}/${r}/stats`)},getDependencies(t,r){return Ue(`/api/skills/${t}/${r}/dependencies`)},getProjectLayout(){return Ue("/api/project-layout")},createSkill(t){return Ue("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},saveDraft(t){return Ue("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Ue("/api/skill-creator-status")},generateSkill(t){return Ue("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,r){return Ue(`/api/skills/${t}/${r}/files`)},getSkillFile(t,r,s){return Ue(`/api/skills/${t}/${r}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,r,s,o){return Ue(`/api/skills/${t}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,r){return Ue(`/api/skills/${t}/${r}/leaderboard`)},getLeaderboardEntry(t,r,s){return Ue(`/api/skills/${t}/${r}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,r,s){const o=`${ta}/api/skills/${t}/${r}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,r){return Ue(`/api/credentials/${t}/${r}`)},setCredential(t,r,s,o){return Ue(`/api/credentials/${t}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,r){return Ue(`/api/credentials/${t}/${r}/params`)},getParamsRevealed(t,r,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Ue(`/api/credentials/${t}/${r}/params?${o}`)},searchModels(){return Ue("/api/openrouter/models")},async getSkillVersions(t,r){const s=await Ue(`/api/skills/${t}/${r}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,r){return Ue(`/api/skills/${t}/${r}/versions`)},getVersionDiff(t,r,s,o){return Ue(`/api/skills/${t}/${r}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const r=`${ta}/api/skills/batch-update`,s=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,r){const s=`${ta}/api/skills/${t}/${r}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async rescanSkill(t,r){const s=`${t}/${r}`,o=await fetch(`${ta}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${ta}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const r=await fetch(`${ta}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:[...t].sort()})});if(!r.ok)return[];const s=await r.json().catch(()=>null);return Array.isArray(s)?s:s&&typeof s=="object"&&Array.isArray(s.results)?s.results.map(o=>({skillId:typeof o.skillId=="string"?o.skillId:typeof o.name=="string"?o.name:"",version:typeof o.version=="string"?o.version:typeof o.latest=="string"?o.latest:"",eventId:typeof o.eventId=="string"?o.eventId:"",publishedAt:typeof o.publishedAt=="string"?o.publishedAt:"",diffSummary:typeof o.diffSummary=="string"?o.diffSummary:void 0,trackedForUpdates:typeof o.trackedForUpdates=="boolean"?o.trackedForUpdates:void 0,updateAvailable:typeof o.updateAvailable=="boolean"?o.updateAvailable:void 0,installed:typeof o.installed=="string"?o.installed:void 0,latest:typeof o.latest=="string"?o.latest:void 0,name:typeof o.name=="string"?o.name:void 0})):[]}catch{return[]}},promoteSkill(t,r,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return xd(`/api/skills/${t}/${r}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,r,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return xd(`/api/skills/${t}/${r}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,r,s){return xd(`/api/skills/${t}/${r}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const r=new URLSearchParams;(t==null?void 0:t.before)!=null&&r.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&r.set("limit",String(t.limit));const s=r.toString();return Ue(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Ue(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${ta}/api/studio/ops/stream`)}};async function xd(t,r,s){const o=await fetch(`${ta}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const j=new Ls(y,o.status);throw v&&(j.code=v),j}const c=o.body.getReader(),u=new TextDecoder;let f="",h="",g=null,p=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;f+=u.decode(v,{stream:!0});const j=f.split(`
62
+ `);f=j.pop()??"";for(const S of j)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};r==null||r(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Ls(p.message,500);throw y.code=p.code,y}if(!g)throw new Ls("Transfer stream ended without 'done' event",500);return g}function Pj(t,r){if(!r.length)return t;const s=new Map;for(const o of r){const c=o.name.split("/").pop()||o.name;s.set(c,o)}return t.map(o=>{const c=s.get(o.skill);if(!c)return o;const u={...o,updateAvailable:c.updateAvailable,currentVersion:c.installed,latestVersion:c.latest??void 0};return typeof c.trackedForUpdates=="boolean"&&(u.trackedForUpdates=c.trackedForUpdates),u})}function Fj(t){const[r,s]=x.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return x.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const Gj=500,Gd="vskill.updates.seenLastId";function Wj(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Gd)}catch{return null}}function gd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Gd):window.localStorage.setItem(Gd,t)}catch{}}function Yj(){let t=new Map;const r=new Set,s=new Set,o=[];let c=Wj();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function f(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>Gj){const g=o.shift();g&&s.delete(g)}c=h,gd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(f(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,gd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,gd(null),u()}}}const Rr=Yj(),qj=3e5,Kj=500,Xj=15e3,Qj=6e4,Zj=6e4,Jj="/api/v1/skills/stream";function $x(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Vx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function e2(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function t2(t){const r=(t==null?void 0:t.intervalMs)??qj,s=(t==null?void 0:t.debounceMs)??Kj,o=(t==null?void 0:t.timeoutMs)??Xj,c=(t==null?void 0:t.staleAfterMs)??Qj,u=(t==null?void 0:t.disconnectFallbackMs)??Zj,f=(t==null?void 0:t.streamUrlBase)??Jj,h=x.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=x.useMemo(()=>{const z=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return z.length===0?"":[...z].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=x.useState([]),[v,j]=x.useState(()=>new Map),[S,k]=x.useState(0),[E,w]=x.useState(!1),[N,A]=x.useState(null),[D,U]=x.useState(null),L=x.useRef(null),F=x.useRef(null),C=x.useRef(null),O=x.useRef(null),T=x.useRef(!0),[_,I]=x.useState(()=>h?"connecting":"fallback"),K=x.useRef(_);K.current=_;const Q=x.useSyncExternalStore(z=>Rr.subscribe(z),()=>Rr.getSnapshot(),()=>Rr.getSnapshot()),q=Q.size,H=x.useCallback(async()=>{w(!0);const z=new AbortController,P=setTimeout(()=>z.abort(),o);try{const te=await Promise.race([Ee.getSkillUpdates(),new Promise((le,xe)=>{z.signal.addEventListener("abort",()=>{xe(new Error("TIMEOUT"))})})]);if(te==="TIMEOUT")throw new Error("TIMEOUT");if(!T.current)return;y(te),j($x(te)),k(Vx(te)),F.current=Date.now(),A(F.current),U(null)}catch(te){if(!T.current)return;U(te instanceof Error?te:new Error(String(te)))}finally{clearTimeout(P),T.current&&w(!1)}},[o]),M=x.useCallback(()=>{if(L.current)return L.current;const z=H().finally(()=>{L.current=null});return L.current=z,z},[H]),B=x.useCallback(()=>{C.current==null&&(C.current=setInterval(()=>{M()},r))},[r,M]),V=x.useCallback(()=>{C.current!=null&&(clearInterval(C.current),C.current=null)},[]);x.useEffect(()=>{T.current=!0,(F.current==null||Date.now()-F.current>c)&&M(),(typeof document>"u"||document.visibilityState!=="hidden")&&B();const te=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){V();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&M(),B()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",te),()=>{T.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",te),O.current&&clearTimeout(O.current),V()}},[]);const W=x.useCallback(async z=>{if(z.length!==0)try{const P=await Ee.checkSkillUpdates(z);if(!T.current||P.length===0)return;const te=Date.now(),le=P.filter(ce=>ce.skillId&&ce.eventId&&ce.version).map(ce=>({skillId:ce.skillId,version:ce.version,eventId:ce.eventId,publishedAt:ce.publishedAt,diffSummary:ce.diffSummary,receivedAt:te}));le.length>0&&Rr.mergeBulk(le);const xe=P.filter(ce=>typeof ce.trackedForUpdates=="boolean"||typeof ce.updateAvailable=="boolean").map(ce=>({name:ce.name??ce.skillId,installed:ce.installed??"",latest:ce.latest??null,updateAvailable:ce.updateAvailable??!1,trackedForUpdates:typeof ce.trackedForUpdates=="boolean"?ce.trackedForUpdates:void 0}));xe.length>0&&y(ce=>{const ve=new Map;for(const Ne of ce)ve.set(Ne.name.split("/").pop()||Ne.name,Ne);let ue=0;for(const Ne of xe){const Me=Ne.name.split("/").pop()||Ne.name,re=ve.get(Me);if(re){const fe={...re};re.trackedForUpdates===void 0&&Ne.trackedForUpdates!==void 0&&(fe.trackedForUpdates=Ne.trackedForUpdates),ve.set(Me,fe)}else ve.set(Me,{name:Ne.name,installed:Ne.installed??"",latest:Ne.latest??null,updateAvailable:Ne.updateAvailable??!1,trackedForUpdates:Ne.trackedForUpdates}),ue+=1}if(ue===0&&ve.size===ce.length)return ce;const ye=[...ve.values()];return j($x(ye)),k(Vx(ye)),ye})}catch{}},[]);x.useEffect(()=>{const z=h||g;if(!z){I("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){I("fallback");return}I("connecting");const P=z.split(","),te=`${f}?skills=${encodeURIComponent(z)}`;let le=null,xe=null,ce=null;const ve=()=>{xe==null&&(xe=setTimeout(()=>{xe=null,T.current&&K.current!=="connected"&&I("fallback")},u))},ue=()=>{xe!=null&&(clearTimeout(xe),xe=null)};ve();const ye=1e3,Ne=()=>{T.current&&ce==null&&(ce=setTimeout(()=>{if(ce=null,!!T.current&&!(le&&le.readyState!==EventSource.CLOSED)){if(le)try{le.close()}catch{}fe()}},ye))},Me=me=>{if(!T.current)return;let he;try{he=JSON.parse(me.data)}catch{return}if(!e2(he)||Rr.ingest(he)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const De=`${he.skillId} updated to ${he.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:De,severity:"info",skillId:he.skillId,version:he.version,eventId:he.eventId}}))}},re=()=>{T.current&&(Rr.clearSeen(),W(P))},fe=()=>{T.current&&(le=new EventSource(te),le.onopen=()=>{T.current&&(ue(),I("connected"))},le.onerror=()=>{T.current&&(ve(),le&&le.readyState===EventSource.CLOSED&&Ne())},le.onmessage=Me,le.addEventListener("gone",re))};return fe(),()=>{if(ue(),ce!=null&&(clearTimeout(ce),ce=null),le){try{le.removeEventListener("gone",re)}catch{}try{le.close()}catch{}}}},[h,g,f,u,W]),x.useEffect(()=>{if(!g)return;const z=g.split(",");W(z)},[g,W]);const de=x.useCallback(z=>{Rr.dismiss(z)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:D,refresh:M,updatesById:Q,pushUpdateCount:q,status:_,dismiss:de}}const n2={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function a2(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const bv=x.createContext(null),jv=bv;function Kn(){const t=x.useContext(jv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function r2({children:t}){const[r,s]=x.useReducer(a2,n2),o=Fj("(max-width: 767px)");x.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=x.useState(()=>{try{const _=window.localStorage.getItem("vskill.studio.prefs");if(!_)return null;const I=JSON.parse(_);return typeof I.activeAgent=="string"?I.activeAgent:null}catch{return null}});x.useEffect(()=>{function _(I){if(!(I instanceof CustomEvent))return;const K=I.detail;K!=null&&K.agentId&&u(K.agentId)}return window.addEventListener("studio:agent-changed",_),()=>window.removeEventListener("studio:agent-changed",_)},[]);const f=x.useCallback(()=>{s({type:"SET_SKILLS_LOADING",loading:!0});const _=c?{agent:c}:void 0;Ee.getSkills(_).then(I=>{s({type:"SET_SKILLS",skills:I});const Q=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(Q){const[,q,H]=Q,M=I.find(B=>B.plugin===q&&B.skill===H);M&&s({type:"SELECT_SKILL",skill:{plugin:q,skill:H,origin:M.origin}})}}).catch(I=>s({type:"SET_SKILLS_ERROR",error:I.message}))},[c]);x.useEffect(()=>{f()},[f]);const h=x.useCallback(_=>{s({type:"SELECT_SKILL",skill:_}),window.location.hash=`/skills/${_.plugin}/${_.skill}`},[]),g=x.useRef(r.skills);x.useEffect(()=>{g.current=r.skills},[r.skills]);const p=x.useCallback((_,I)=>{const K=g.current,Q=_?K.find(M=>M.plugin===_&&M.skill===I):K.find(M=>M.skill===I&&M.source!=="plugin");if(!_&&!Q){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${I}" not yet in state — skipping reveal`);return}const q=(Q==null?void 0:Q.plugin)??_,H=(Q==null?void 0:Q.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:q,skill:I,origin:H}}),window.location.hash=`/skills/${q}/${I}`},[]),y=x.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),v=x.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),j=x.useCallback(_=>{s({type:"SET_MODE",mode:_})},[]),S=x.useCallback(_=>{s({type:"SET_SEARCH",query:_})},[]),k=x.useCallback(_=>{s({type:"SET_MOBILE_VIEW",view:_})},[]),E=x.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),w=x.useMemo(()=>{const _=[];for(const I of r.skills)I.origin==="installed"&&_.push(`${I.plugin}/${I.skill}`);return _},[r.skills]),N=x.useMemo(()=>r.skills.map(_=>`${_.plugin}/${_.skill}`),[r.skills]),A=t2({skillIds:w,trackingSkillIds:N}),D=x.useMemo(()=>{const _=r.skills.map(I=>{if(!I.updateAvailable&&I.latestVersion===void 0&&I.trackedForUpdates===void 0)return I;const K={...I};return delete K.updateAvailable,delete K.currentVersion,delete K.latestVersion,delete K.trackedForUpdates,K});return Pj(_,A.updates)},[r.skills,A.updates]),U=x.useMemo(()=>{const _={source:0,installed:0};for(const I of D)I.updateAvailable&&(_[I.origin]+=1);return _},[D]),L=x.useMemo(()=>({...r,skills:D}),[r,D]),F=A.updateCount,C=A.refresh,O=A.isRefreshing,T=x.useMemo(()=>({state:L,selectSkill:h,clearSelection:v,setMode:j,setSearch:S,setMobileView:k,refreshSkills:f,updateCount:F,dismissUpdateNotification:E,updates:A.updates,outdatedByOrigin:U,isRefreshingUpdates:O,refreshUpdates:C,revealSkill:p,clearReveal:y,updatesById:A.updatesById,pushUpdateCount:A.pushUpdateCount,updateStreamStatus:A.status,dismissPushUpdate:A.dismiss}),[L,h,v,j,S,k,f,F,E,A.updates,U,O,C,p,y,A.updatesById,A.pushUpdateCount,A.status,A.dismiss]);return a.jsx(jv.Provider,{value:T,children:t})}const l2={config:null,loading:!0};function s2(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Sv=x.createContext(null);function _r(){const t=x.useContext(Sv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function i2({children:t}){const[r,s]=x.useReducer(s2,l2),o=x.useCallback(()=>{Ee.getConfig().then(f=>s({type:"SET_CONFIG",config:f})).catch(()=>{})},[]);x.useEffect(()=>{o()},[o]);const c=x.useCallback(async(f,h)=>{const g=await Ee.setConfig(f,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=x.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(Sv.Provider,{value:u,children:t})}function o2({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:f,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:p,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:f??""})]})}const Px=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],c2={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},u2={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},d2={"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"},f2={"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 p2(t,r){var h,g;const s=c2[t.id]??null,o=u2[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,f=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:f2[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:m2(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:d2[t.id]??null,models:f,resolvedModel:t.resolvedModel??null}}function m2(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function h2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Px){const c=r.get(o);c&&s.push(c)}for(const o of t)Px.includes(o.id)||s.push(o);return s}function x2(t){const[r,s]=x.useState(null),[o,c]=x.useState("loading"),[u,f]=x.useState(null),h=x.useRef(null),g=x.useRef(0),p=x.useCallback(async()=>{try{const k=await fetch("/api/config");if(!k.ok)throw new Error(`/api/config returned ${k.status}`);const E=await k.json(),w=h2((E.providers||[]).map(N=>p2(N,E.detection)));s({agents:w,activeAgent:E.provider??null,activeModel:E.model??null}),c("ready"),f(null)}catch(k){c("error"),f(k.message)}},[]);x.useEffect(()=>{p()},[p]);const y=x.useCallback(async()=>{const k=Date.now();if(!(k-g.current<5*6e4))try{const E=await fetch("/api/openrouter/models");if(!E.ok)return;const w=await E.json();g.current=k,s(N=>{if(!N)return N;const A=N.agents.map(D=>{if(D.id!=="openrouter")return D;const U=w.models.map(F=>({id:F.id,displayName:F.name,contextWindow:F.contextWindow,pricing:F.pricing,billingMode:"per-token"}));return{...D,models:U,catalogAgeMs:w.ageSec?w.ageSec*1e3:0,cacheStale:!!w.stale}});return{...N,agents:A}}),w.stale&&(t!=null&&t.onStaleCatalog)&&t.onStaleCatalog("openrouter",(w.ageSec??0)*1e3)}catch{}},[t]),v=x.useCallback(k=>{h.current=k,k==="openrouter"&&y()},[y]),j=x.useCallback(()=>{g.current=0,p()},[p]),S=x.useCallback(async(k,E)=>{(await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:k,model:E})})).ok&&s(N=>N&&{...N,activeAgent:k,activeModel:E})},[]);return{status:o,catalog:r,error:u,focusAgent:v,refresh:j,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:S}}function vd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function f(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:f,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Wd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const g2={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <plugin> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,r)=>`${t} of ${r}`},v2={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"},y2={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"},b2={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},j2={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"},S2={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"},k2={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},w2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},E2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},C2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},N2={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"},T2={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)."}},R2={subscriptionBilling:"· subscription",free:"· free"},A2={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`},M2={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},L2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},z2={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.`},D2={compactLabel:"Covered by Max/Pro · overflow billed at API rates",tooltip:"Your Claude Code CLI usage runs under your Pro/Max subscription quota. If you've enabled extra usage in your account settings, excess usage continues 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 Pro/Max subscription. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},_2={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."},O2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},B2={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 under your Pro/Max subscription.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Pro/Max account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:g2,shell:v2,detail:y2,actions:b2,palette:j2,shortcuts:S2,toasts:k2,connection:w2,forms:E2,errors:C2,picker:N2,providers:T2,models:R2,settings:A2,statusBar:M2,scopePicker:L2,scopeSection:z2,claudeCodeLabel:D2,setupDrawer:_2,setupProviders:B2,scopeLabels:O2},Fx=new Set(["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function I2({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const f=t.filter(g=>Fx.has(g.id)),h=t.filter(g=>!Fx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[f.map(g=>a.jsx(Gx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Gx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Gx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:f}=ne,h={"claude-cli":f.claudeCli.caption,anthropic:f.anthropic.caption,openrouter:f.openrouter.caption},g={"claude-cli":{label:f.claudeCli.installCta,url:f.claudeCli.installUrl},cursor:{label:f.cursor.installCta},"codex-cli":{label:f.codexCli.installCta},"gemini-cli":{label:f.geminiCli.installCta},copilot:{label:f.copilot.installCta},zed:{label:f.zed.installCta}},p=t.id==="claude-cli"||t.id==="claude-code",y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),(t.id==="claude-cli"||t.id==="claude-code")&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Wd,{unlocked:!0,size:10}):a.jsx(Wd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(vd,{variant:"api-key",label:t.id==="anthropic"?f.anthropic.addKeyCta:f.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(vd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(vd,{variant:"start-service",label:t.id==="ollama"?f.ollama.startServiceCta:f.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function H2(t,r,s,o){const f=t>=80,h=x.useRef(null),[g,p]=x.useState(0),y=x.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:j}=x.useMemo(()=>{if(!f)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/r)-4),k=Math.ceil(s/r)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[f,g,r,s,t,4]);return{visibleStart:v,visibleEnd:j,totalHeight:t*r,offsetTop:v*r,virtualised:f,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:f?"transform":void 0}}}}const kv=44,U2=352,$2=60,Wx=480;function V2(t){var u,f;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((f=t.pricing)==null?void 0:f.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function P2(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const f=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return f!==h?f-h:c.displayName.length-u.displayName.length})}function F2({agent:t,activeModelId:r,onSelect:s,onOpenSettings:o}){const[c,u]=x.useState(""),[f,h]=x.useState(""),g=x.useRef(null);if(x.useEffect(()=>{const v=setTimeout(()=>h(c),$2);return()=>clearTimeout(v)},[c]),x.useEffect(()=>{t.id==="openrouter"&&t.available&&g.current&&g.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Wx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>o("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const p=x.useMemo(()=>P2(t.models,f),[t.models,f]),y=H2(p.length,kv,U2);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Wx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:g,type:"text",placeholder:ne.picker.searchPlaceholder,value:c,onChange:v=>u(v.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),p.length===0&&f?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(f)}),a.jsx("button",{type:"button",onClick:()=>u(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):p.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):a.jsx("div",{...y.containerProps,children:a.jsx("div",{style:{height:y.virtualised?y.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:y.virtualised?`translateY(${y.offsetTop}px)`:void 0},children:p.slice(y.visibleStart,y.visibleEnd).map(v=>a.jsx(W2,{model:v,isActive:v.id===r,onSelect:()=>s(v.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},v.id))})})})]})}function G2(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function W2({model:t,isActive:r,onSelect:s,resolvedModel:o}){const c=V2(t),u=G2(t.id,o,t.resolvedId),f=u!==null;return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,onClick:s,title:t.id,style:{width:"100%",minHeight:kv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:c}),f&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",u]})]})}const Yx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function Y2(){const[t,r]=x.useState(null),[s,o]=x.useState(!0),[c,u]=x.useState(null),f=x.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();r({...Yx,...y}),u(null)}catch(p){u(p.message),r(Yx)}finally{o(!1)}},[]);x.useEffect(()=>{f()},[f]);const h=x.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const j=await v.json();return await f(),j},[f]),g=x.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await f()},[f]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:f}}function q2({onMigrated:t,fetchImpl:r}){const[s,o]=x.useState({kind:"loading"}),c=r??globalThis.fetch,u=x.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);x.useEffect(()=>{u()},[u]);const f=x.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=x.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:yd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void f(),disabled:g,"data-testid":"migration-migrate",style:{...yd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...yd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const yd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},K2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function X2(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function wv({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:f,refresh:h}=Y2(),g=x.useRef(null),p=x.useRef(null),[y,v]=x.useState(null);x.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),x.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",w=(N=g.current)==null?void 0:N.querySelector(E);w==null||w.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),x.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),r();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const w=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===w?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),w.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]);const j=x.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),a.jsx(q2,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),K2.map(S=>a.jsx(Q2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await f(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:j,disabled:!y,"data-testid":"settings-copy-path",style:{...Mr,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function Q2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:f,onRemove:h,inputRef:g}){const[p,y]=x.useState(""),[v,j]=x.useState(!1),[S,k]=x.useState(!1),[E,w]=x.useState(!1),[N,A]=x.useState(null),D=p.trim(),U=D.length===0,L=D.length>0&&!D.startsWith(o),F=x.useCallback(async()=>{if(U)return;k(!0);const T=D;y("");try{const _=await f(T);_.warning?A(_.warning):A(null)}finally{k(!1)}},[U,f,D]),C=x.useCallback(async()=>{var T;try{if(!((T=navigator.clipboard)!=null&&T.readText))return;const _=await navigator.clipboard.readText();y(_)}catch{}},[]),O=x.useCallback(async()=>{w(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:T=>{y(T.target.value),A(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>j(!v),style:Mr,children:v?ne.settings.hide:ne.settings.show}),a.jsx("button",{type:"button",onClick:C,style:Mr,children:ne.settings.paste})]}),L&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:qx,children:ne.settings.prefixWarn(r)}),N&&a.jsx("div",{role:"status",style:qx,children:N}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:U||S,"data-testid":`save-${t}`,style:{...Mr,background:U?"var(--surface-2)":"var(--accent, var(--color-accent))",color:U?"var(--text-muted)":"white",cursor:U?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:E?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Mr,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>w(!1),style:Mr,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>w(!0),"data-testid":`remove-${t}`,style:{...Mr,color:"var(--text-muted)"},children:ne.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(X2(u.updatedAt)):ne.settings.noKey})]})]})}const Mr={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},qx={fontSize:11,color:"var(--warning, var(--text-muted))"};function Z2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function J2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=x2({onStaleCatalog:(O,T)=>{const _=Math.round(T/6e4);t==null||t(`Using cached ${O} catalog (${_} min old)`)}}),[u,f]=x.useState(!1),[h,g]=x.useState(!1),[p,y]=x.useState(),[v,j]=x.useState(null),[S,k]=x.useState("agents"),E=x.useRef(null);x.useRef(null),x.useEffect(()=>{var O;s&&!v&&j(s.activeAgent??((O=s.agents[0])==null?void 0:O.id)??null)},[s,v]);const w=(s==null?void 0:s.agents)??[],N=x.useMemo(()=>w.find(O=>O.id===v)??w[0],[w,v]),A=x.useCallback(()=>{var O;f(!0),k("agents"),j((s==null?void 0:s.activeAgent)??((O=w[0])==null?void 0:O.id)??null)},[s,w]),D=x.useCallback(()=>{var O;f(!1),(O=E.current)==null||O.focus()},[]);x.useEffect(()=>{const O=T=>{var I;if(!(T.metaKey||T.ctrlKey)||T.key.toLowerCase()!=="k")return;const _=(I=document.activeElement)==null?void 0:I.tagName;_==="INPUT"||_==="TEXTAREA"||(T.preventDefault(),f(K=>!K))};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[]),x.useEffect(()=>{if(!u)return;const O=_=>{if(_.key==="Escape"){_.preventDefault(),D();return}if(_.key==="ArrowDown"){_.preventDefault(),T(1);return}if(_.key==="ArrowUp"){_.preventDefault(),T(-1);return}if(_.key==="ArrowRight"&&S==="agents"){_.preventDefault(),k("models");return}if(_.key==="ArrowLeft"&&S==="models"){_.preventDefault(),k("agents");return}if(_.key==="Enter"){_.preventDefault(),S==="agents"&&N?k("models"):S==="models"&&N&&N.models[0]&&(c(N.id,N.models[0].id),D());return}};function T(_){if(S==="agents"){const I=w.findIndex(Q=>Q.id===v),K=w[Math.max(0,Math.min(w.length-1,I+_))];K&&(j(K.id),o(K.id))}}return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[u,S,w,v,N,D,o,c]);const U=x.useCallback(O=>{y(O==="anthropic"||O==="openrouter"?O:void 0),g(!0),f(!1)},[]),L=w.find(O=>O.id===(s==null?void 0:s.activeAgent)),F=L==null?void 0:L.models.find(O=>O.id===(s==null?void 0:s.activeModel)),C=x.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const O=(L==null?void 0:L.displayName)??"Agent",T=(F==null?void 0:F.displayName)??s.activeModel??"Model";return`${O} · ${T}`},[r,s,L,F]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:E,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():A(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:L!=null&&L.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:C})]}),u&&typeof document<"u"&&Bo.createPortal(a.jsxs(eS,{reducedMotion:Z2(),onClickOutside:D,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx(I2,{agents:w,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:O=>{j(O),o(O)},onSelect:O=>{j(O),o(O),k("models")},onOpenSettings:U}),N&&a.jsx(F2,{agent:N,activeModelId:(s==null?void 0:s.activeModel)??null,onSelect:O=>{c(N.id,O),D()},onOpenSettings:U})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>U(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),a.jsx(wv,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function eS({children:t,reducedMotion:r,onClickOutside:s}){const o=x.useRef(null);return x.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
+ from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
+ }`})]})}function Kx(){typeof window>"u"||(window.location.hash="#/")}function tS({onHome:t}){const[r,s]=x.useState(!1),[o,c]=x.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Kx(),t==null||t())},f=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Kx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:f,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const nS="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",aS=x.lazy(()=>Io(()=>import("./UpdateDropdown-DnKKMBBN.js"),__vite__mapDeps([0,1])));function rS(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=Kn(),f=x.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,w]of u)w.diffSummary&&k.set(E,w.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=x.useState(!1),p=x.useRef(null),y=x.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",j=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:nS,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:j})]}),h&&a.jsx(x.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(aS,{updates:r,isRefreshing:s,diffSummariesById:f,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),w=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:w,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function Xx(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function lS({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const f=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(tS,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&f&&a.jsxs(a.Fragment,{children:[a.jsx(Qx,{segment:"origin",onClick:()=>Xx({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:f}),a.jsx(Zx,{}),a.jsx(Qx,{segment:"plugin",onClick:()=>Xx({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(Zx,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(J2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(rS,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function Qx({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function Zx(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Ho="vskill-theme";function Ev(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function sS(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function iS(t){try{const r=t.getItem(Ho);return Ev(r)}catch{return"auto"}}function oS(t,r){try{t.setItem(Ho,r)}catch{}}function cS(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function uS(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Cv=x.createContext(null);function dS({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),f=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=x.useState(()=>c?iS(c):"auto"),[p,y]=x.useState(()=>uS(u)),v=x.useMemo(()=>sS(h,p),[h,p]);x.useEffect(()=>{f&&cS(f,h,v)},[f,h,v]),x.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const w=k;return w.addListener(E),()=>w.removeListener(E)},[u]),x.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Ho&&g(Ev(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),x.useEffect(()=>{if(!u||!f)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=A=>{A?f.dataset.contrast="more":f.dataset.contrast==="more"&&delete f.dataset.contrast};E(k.matches);const w=A=>E(A.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",w),()=>k.removeEventListener("change",w);const N=k;return N.addListener(w),()=>N.removeListener(w)},[u,f]);const j=x.useCallback(k=>{g(k),c&&oS(c,k)},[c]),S=x.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:j}),[h,v,j]);return a.jsx(Cv.Provider,{value:S,children:o})}function Nv(){const t=x.useContext(Cv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const Jx=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function fS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Jx){const c=r.get(o);c&&s.push(c)}for(const o of t)Jx.includes(o.id)||s.push(o);return s}function pS(t){const[r,s]=x.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return x.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var f;return(f=o.removeEventListener)==null?void 0:f.call(o,"change",c)}},[t]),r}function mS({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=fS(t),c=pS(640),[u,f]=x.useState(!1),h=x.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>f(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(eg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(eg,{p:g,onClick:h,compact:!0},g.id))})}function eg({p:t,onClick:r,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Wd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function hS(){try{return typeof localStorage>"u"?null:localStorage.getItem(Ho)}catch{return null}}function xS({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:f}){const{mode:h,resolvedTheme:g,setTheme:p}=Nv(),v=hS()==="auto",j=gS(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(tg,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(vS,{color:S}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(tg,{}),a.jsx(mS,{providers:c,onOpenSettings:u,onOpenInstallHelp:f})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(j),"aria-label":`Switch to ${j} theme`,title:`Theme: ${h} — click for ${j}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(yS,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function gS(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function vS({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function tg(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function yS({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ko=new Map,Lr=new Map,As=new Map;function sn(t){ko.delete(t),Lr.delete(t);const r=As.get(t);if(r)for(const s of r)s()}function Ml(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=x.useState(0),f=x.useRef(!0),h=x.useRef(t);h.current=t;const g=()=>sn(t);x.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]),x.useEffect(()=>{if(!c)return;const j=()=>{f.current&&u(S=>S+1)};return As.has(t)||As.set(t,new Set),As.get(t).add(j),()=>{var S;(S=As.get(t))==null||S.delete(j)}},[t,c]),x.useEffect(()=>{if(!c)return;const j=ko.get(t);if(!(!j||Date.now()-j.fetchedAt>o))return;if(Lr.has(t)){const w=Lr.get(t),N=()=>{f.current&&h.current===t&&u(A=>A+1)};w.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=r().then(w=>{ko.set(t,{data:w,fetchedAt:Date.now()}),Lr.delete(t),f.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},w=>{Lr.delete(t),f.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw w});k.promise=E,Lr.set(t,k)},[t,r,o,c]);const p=ko.get(t),y=c&&!p&&Lr.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}const Uo=0,or=1,Ll=2,Tv=4;function ng(t){return()=>t}function bS(t){t()}function Rv(t,r){return s=>t(r(s))}function ag(t,r){return()=>t(r)}function jS(t,r){return s=>t(r,s)}function mf(t){return t!==void 0}function SS(...t){return()=>{t.map(bS)}}function zl(){}function $o(t,r){return r(t),t}function kS(t,r){return r(t)}function bt(...t){return t}function at(t,r){return t(or,r)}function $e(t,r){t(Uo,r)}function hf(t){t(Ll)}function kt(t){return t(Tv)}function Ce(t,r){return at(t,jS(r,Uo))}function Wn(t,r){const s=t(or,o=>{s(),r(o)});return s}function rg(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Av(t,r){return t===r}function yt(t=Av){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function ze(t){return r=>s=>{t(s)&&r(s)}}function je(t){return r=>Rv(r,t)}function na(t){return r=>()=>{r(t)}}function pe(t,...r){const s=wS(...r);return((o,c)=>{switch(o){case Ll:hf(t);return;case or:return at(t,s(c))}})}function aa(t,r){return s=>o=>{s(r=t(r,o))}}function Dr(t){return r=>s=>{t>0?t--:r(s)}}function Na(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Ve(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,f)=>{const h=2**f;at(u,g=>{const p=s;s|=h,r[f]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>f=>{const h=()=>{u([f].concat(r))};s===c?h():o=h}}function wS(...t){return r=>t.reduceRight(kS,r)}function ES(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case or:return u?s===u?void 0:(o(),s=u,r=at(t,u),r):(o(),zl);case Ll:o(),s=null;return}}}function ge(t){let r=t;const s=Xe();return((o,c)=>{switch(o){case Uo:r=c;break;case or:{c(r);break}case Tv:return r}return s(o,c)})}function Zt(t,r){return $o(ge(r),s=>Ce(t,s))}function Xe(){const t=[];return((r,s)=>{switch(r){case Uo:t.slice().forEach(o=>{o(s)});return;case Ll:t.splice(0,t.length);return;case or:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function En(t){return $o(Xe(),r=>Ce(t,r))}function et(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:CS(),singleton:s}}const CS=()=>Symbol();function NS(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:f})=>{if(f&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return f&&r.set(u,h),h};return s(t)}function Dt(...t){const r=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,f)=>{const h=2**f;at(u,g=>{s[f]=g,o|=h,o===c&&$e(r,s)})}),function(u,f){switch(u){case Ll:{hf(r);return}case or:return o===c&&f(s),at(r,f)}}}function Le(t,r=Av){return pe(t,yt(r))}function Yd(...t){return function(r,s){switch(r){case Ll:return;case or:return SS(...t.map(o=>at(o,s)))}}}const It={DEBUG:0,INFO:1,WARN:2,ERROR:3},TS={[It.DEBUG]:"debug",[It.ERROR]:"error",[It.INFO]:"log",[It.WARN]:"warn"},RS=()=>typeof globalThis>"u"?window:globalThis,cr=et(()=>{const t=ge(It.ERROR);return{log:ge((r,s,o=It.INFO)=>{const c=RS().VIRTUOSO_LOG_LEVEL??kt(t);o>=c&&console[TS[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function Or(t,r,s){return xf(t,r,s).callbackRef}function xf(t,r,s){const o=we.useRef(null);let c=f=>{};const u=we.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(f=>{const h=()=>{const g=f[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=f=>{f&&r?(u==null||u.observe(f),o.current=f):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function AS(t,r,s,o,c,u,f,h,g){const p=we.useCallback(y=>{const v=MS(y.children,r,h?"offsetWidth":"offsetHeight",c);let j=y.parentElement;for(;j.dataset.virtuosoScroller===void 0;)j=j.parentElement;const S=j.lastElementChild.dataset.viewportType==="window";let k;S&&(k=j.ownerDocument.defaultView);const E=f?h?f.scrollLeft:f.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?j.scrollLeft:j.scrollTop,w=f?h?f.scrollWidth:f.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?j.scrollWidth:j.scrollHeight,N=f?h?f.offsetWidth:f.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?j.offsetWidth:j.offsetHeight;o({scrollHeight:w,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?lg("column-gap",getComputedStyle(y).columnGap,c):lg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,f,o,h]);return xf(p,s,g)}function MS(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let f=0;f<c;f++){const h=t.item(f);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},It.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function lg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,It.WARN),r==="normal"?0:parseInt(r??"0",10)}function Mv(t,r,s){const o=we.useRef(null),c=we.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,j;if(r){const S=r.getBoundingClientRect(),k=p.top-S.top;j=S.height-Math.max(0,k),v=k+r.scrollTop}else{const S=f.current.ownerDocument.defaultView;j=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:j,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:f}=xf(c,!0,s),h=we.useCallback(()=>{c(f.current)},[c,f]);return we.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=f.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,f]),u}const on=et(()=>{const t=Xe(),r=Xe(),s=ge(0),o=Xe(),c=ge(0),u=Xe(),f=Xe(),h=ge(0),g=ge(0),p=ge(0),y=ge(0),v=Xe(),j=Xe(),S=ge(!1),k=ge(!1),E=ge(!1);return Ce(pe(t,je(({scrollTop:w})=>w)),r),Ce(pe(t,je(({scrollHeight:w})=>w)),f),Ce(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:j,scrollContainerState:t,scrollHeight:f,scrollingInProgress:S,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Bs={lvl:0};function Lv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let f=1;f<s;f++){const{index:h,value:g}=r(t[f]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ut(t){return t===Bs}function Is(t,r){if(!ut(t))return r===t.k?t.v:r<t.k?Is(t.l,r):Is(t.r,r)}function qn(t,r,s="k"){if(ut(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=qn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return qn(t.l,r,s)}function wn(t,r,s){return ut(t)?_v(r,s,1):r===t.k?Bt(t,{k:r,v:s}):r<t.k?sg(Bt(t,{l:wn(t.l,r,s)})):sg(Bt(t,{r:wn(t.r,r,s)}))}function El(){return Bs}function Cl(t,r,s){if(ut(t))return[];const o=qn(t,r)[0];return LS(Kd(t,o,s))}function qd(t,r){if(ut(t))return Bs;const{k:s,l:o,r:c}=t;if(r===s){if(ut(o))return c;if(ut(c))return o;const[u,f]=Dv(o);return wo(Bt(t,{k:u,l:zv(o),v:f}))}return r<s?wo(Bt(t,{l:qd(o,r)})):wo(Bt(t,{r:qd(c,r)}))}function zr(t){return ut(t)?[]:[...zr(t.l),{k:t.k,v:t.v},...zr(t.r)]}function Kd(t,r,s){if(ut(t))return[];const{k:o,l:c,r:u,v:f}=t;let h=[];return o>r&&(h=h.concat(Kd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:f}),o<=s&&(h=h.concat(Kd(u,r,s))),h}function wo(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(bd(r))return Ov(Bt(t,{lvl:s-1}));if(!ut(r)&&!ut(r.r))return Bt(r.r,{l:Bt(r,{r:r.r.l}),lvl:s,r:Bt(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(bd(t))return Xd(Bt(t,{lvl:s-1}));if(!ut(o)&&!ut(o.l)){const c=o.l,u=bd(c)?o.lvl-1:o.lvl;return Bt(c,{l:Bt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:Xd(Bt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Bt(t,r){return _v(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function zv(t){return ut(t.r)?t.l:wo(Bt(t,{r:zv(t.r)}))}function bd(t){return ut(t)||t.lvl>t.r.lvl}function Dv(t){return ut(t.r)?[t.k,t.v]:Dv(t.r)}function _v(t,r,s,o=Bs,c=Bs){return{k:t,l:o,lvl:s,r:c,v:r}}function sg(t){return Xd(Ov(t))}function Ov(t){const{l:r}=t;return!ut(r)&&r.lvl===t.lvl?Bt(r,{r:Bt(t,{l:r.r})}):t}function Xd(t){const{lvl:r,r:s}=t;return!ut(s)&&!ut(s.r)&&s.lvl===r&&s.r.lvl===r?Bt(s,{l:Bt(t,{r:s.l}),lvl:r+1}):t}function LS(t){return Lv(t,({k:r,v:s})=>({index:r,value:s}))}function Bv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Hs(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const gf=et(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Iv(t,r,s){return t[Ro(t,r,s)]}function Ro(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),f=t[u],h=s(f,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function zS(t,r,s,o){const c=Ro(t,r,o),u=Ro(t,s,o,c);return t.slice(c,u+1)}function sr(t,r){return Math.round(t.getBoundingClientRect()[r])}function Vo(t){return!ut(t.groupOffsetTree)}function vf({index:t},r){return r===t?0:r<t?-1:1}function DS(){return{groupIndices:[],groupOffsetTree:El(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:El()}}function _S(t,r){let s=ut(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:f}=o;if(s=Math.min(s,f),ut(t)){t=wn(t,0,u);continue}const h=Cl(t,f-1,c+1);if(h.some(VS(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:j}of h)g?(c>=v||u===j)&&(t=qd(t,v)):(p=j!==u,g=!0),y>c&&c>=v&&j!==u&&(t=wn(t,c+1,j));p&&(t=wn(t,f,u))}return[t,s]}function OS(t){return typeof t.groupIndex<"u"}function BS({offset:t},r){return r===t?0:r<t?-1:1}function Us(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Iv(r,t,vf),f=t-o,h=u*f+(f-1)*s+c;return h>0?h+s:h}function Hv(t,r){if(!Vo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Uv(t,r,s){if(OS(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Hv(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function IS(t,r,s,o=0){return o>0&&(r=Math.max(r,Iv(t,o,vf).offset)),Lv(zS(t,r,s,BS),$S)}function HS(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,It.DEBUG);const u=t.sizeTree;let f=u,h=0;if(s.length>0&&ut(u)&&r.length===2){const j=r[0].size,S=r[1].size;f=s.reduce((k,E)=>wn(wn(k,E,j),E+1,S),f)}else[f,h]=_S(f,r);if(f===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=Qd(t.offsetTree,h,f,c);return{groupIndices:s,groupOffsetTree:s.reduce((j,S)=>wn(j,S,Us(S,v,c)),El()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:f}}function US(t){return zr(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function ig(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function Qd(t,r,s,o){let c=t,u=0,f=0,h=0,g=0;if(r!==0){g=Ro(c,r-1,vf),h=c[g].offset;const p=qn(s,r-1);u=p[0],f=p[1],c.length&&c[g].size===qn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Cl(s,r,1/0)){const v=p-u,j=v*f+h+v*o;c.push({index:p,offset:j,size:y}),u=p,h=j,f=y}return{lastIndex:u,lastOffset:h,lastSize:f,offsetTree:c}}function $S(t){return{index:t.index,value:t}}function VS(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const PS={offsetHeight:"height",offsetWidth:"width"},la=et(([{log:t},{recalcInProgress:r}])=>{const s=Xe(),o=Xe(),c=Zt(o,0),u=Xe(),f=Xe(),h=ge(0),g=ge([]),p=ge(void 0),y=ge(void 0),v=ge(void 0),j=ge(void 0),S=ge((C,O)=>sr(C,PS[O])),k=ge(void 0),E=ge(0),w=DS(),N=Zt(pe(s,Ve(g,t,E),aa(HS,w),yt()),w),A=Zt(pe(g,yt(),aa((C,O)=>({current:O,prev:C.current}),{current:[],prev:[]}),je(({prev:C})=>C)),[]);Ce(pe(g,ze(C=>C.length>0),Ve(N,E),je(([C,O,T])=>{const _=C.reduce((I,K,Q)=>wn(I,K,Us(K,O.offsetTree,T)||Q),El());return{...O,groupIndices:C,groupOffsetTree:_}})),N),Ce(pe(o,Ve(N),ze(([C,{lastIndex:O}])=>C<O),je(([C,{lastIndex:O,lastSize:T}])=>[{endIndex:O,size:T,startIndex:C}])),s),Ce(p,y);const D=Zt(pe(p,je(C=>C===void 0)),!0);Ce(pe(y,ze(C=>C!==void 0&&ut(kt(N).sizeTree)),je(C=>{const O=kt(v),T=kt(g).length>0;return O!==void 0&&O!==0?T?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:C,startIndex:1}]:[]:[{endIndex:0,size:C,startIndex:0}]})),s),Ce(pe(j,ze(C=>C!==void 0&&C.length>0&&ut(kt(N).sizeTree)),je(C=>{const O=[];let T=C[0],_=0;for(let I=1;I<C.length;I++){const K=C[I];K!==T&&(O.push({endIndex:I-1,size:T,startIndex:_}),T=K,_=I)}return O.push({endIndex:C.length-1,size:T,startIndex:_}),O})),s),Ce(pe(g,Ve(v,y),ze(([,C,O])=>C!==void 0&&O!==void 0),je(([C,O,T])=>{const _=[];for(let I=0;I<C.length;I++){const K=C[I],Q=C[I+1];_.push({startIndex:K,endIndex:K,size:O}),Q!==void 0&&_.push({startIndex:K+1,endIndex:Q-1,size:T})}return _})),s);const U=En(pe(s,Ve(N),aa(({sizes:C},[O,T])=>({changed:T!==C,sizes:T}),{changed:!1,sizes:w}),je(C=>C.changed)));at(pe(h,aa((C,O)=>({diff:C.prev-O,prev:O}),{diff:0,prev:0}),je(C=>C.diff)),C=>{const{groupIndices:O}=kt(N);if(C>0)$e(r,!0),$e(u,C+ig(C,O));else if(C<0){const T=kt(A);T.length>0&&(C-=ig(-C,T)),$e(f,C)}}),at(pe(h,Ve(t)),([C,O])=>{C<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},It.ERROR)});const L=En(u);Ce(pe(u,Ve(N),je(([C,O])=>{const T=O.groupIndices.length>0,_=[],I=O.lastSize;if(T){const K=Is(O.sizeTree,0);let Q=0,q=0;for(;Q<C;){const M=O.groupIndices[q],B=O.groupIndices.length===q+1?1/0:O.groupIndices[q+1]-M-1;_.push({endIndex:M,size:K,startIndex:M}),_.push({endIndex:M+1+B-1,size:I,startIndex:M+1}),q++,Q+=B+1}const H=zr(O.sizeTree);return Q!==C&&H.shift(),H.reduce((M,{k:B,v:V})=>{let W=M.ranges;return M.prevSize!==0&&(W=[...M.ranges,{endIndex:B+C-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:B+C,prevSize:V,ranges:W}},{prevIndex:C,prevSize:0,ranges:_}).ranges}return zr(O.sizeTree).reduce((K,{k:Q,v:q})=>({prevIndex:Q+C,prevSize:q,ranges:[...K.ranges,{endIndex:Q+C-1,size:K.prevSize,startIndex:K.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),s);const F=En(pe(f,Ve(N,E),je(([C,{offsetTree:O},T])=>{const _=-C;return Us(_,O,T)})));return Ce(pe(f,Ve(N,E),je(([C,O,T])=>{if(O.groupIndices.length>0){if(ut(O.sizeTree))return O;let I=El();const K=kt(A);let Q=0,q=0,H=0;for(;Q<-C;){H=K[q];const M=K[q+1]-H-1;q++,Q+=M+1}if(I=zr(O.sizeTree).reduce((M,{k:B,v:V})=>wn(M,Math.max(0,B+C),V),I),Q!==-C){const M=Is(O.sizeTree,H);I=wn(I,0,M);const B=qn(O.sizeTree,-C+1)[1];I=wn(I,1,B)}return{...O,sizeTree:I,...Qd(O.offsetTree,0,I,T)}}const _=zr(O.sizeTree).reduce((I,{k:K,v:Q})=>wn(I,Math.max(0,K+C),Q),El());return{...O,sizeTree:_,...Qd(O.offsetTree,0,_,T)}})),N),{beforeUnshiftWith:L,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:j,itemSize:S,listRefresh:U,shiftWith:f,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:D,unshiftWith:u}},bt(cr,gf),{singleton:!0});function FS(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const $v=et(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),f=Xe(),h=En(pe(u,je(FS)));return Ce(pe(h,je(g=>g.totalCount)),s),Ce(pe(h,je(g=>g.groupIndices)),t),Ce(pe(Dt(c,r,o),ze(([g,p])=>Vo(p)),je(([g,p,y])=>qn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),yt(),je(g=>[g])),f),{groupCounts:u,topItemsIndexes:f}},bt(la,on)),ur=et(([{log:t}])=>{const r=ge(!1),s=En(pe(r,ze(o=>o),yt()));return at(r,o=>{o&&kt(t)("props updated",{},It.DEBUG)}),{didMount:s,propsReady:r}},bt(cr),{singleton:!0}),GS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Vv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!GS)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Ws=et(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:f,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:j}])=>{const S=Xe(),k=Xe(),E=ge(0);let w=null,N=null,A=null;function D(){w!==null&&(w(),w=null),A!==null&&(A(),A=null),N&&(clearTimeout(N),N=null),$e(g,!1)}return Ce(pe(S,Ve(s,v,o,E,h,f,j),Ve(t,u,c),je(([[U,L,F,C,O,T,_,I],K,Q,q])=>{const H=Vv(U),{align:M,behavior:B,offset:V}=H,W=C-1,de=Uv(H,L,W);let z=Us(de,L.offsetTree,K)+T;M==="end"?(z+=Q+qn(L.sizeTree,de)[1]-F+q,de===W&&(z+=_)):M==="center"?z+=(Q+qn(L.sizeTree,de)[1]-F+q)/2:z-=O,V!==void 0&&V!==0&&(z+=V);const P=te=>{D(),te?(I("retrying to scroll to",{location:U},It.DEBUG),$e(S,U)):($e(k,!0),I("list did not change, scroll successful",{},It.DEBUG))};if(D(),B==="smooth"){let te=!1;A=at(r,le=>{te=te||le}),w=Wn(y,()=>{P(te)})}else w=Wn(pe(r,WS(150)),P);return N=setTimeout(()=>{D()},1200),$e(g,!0),I("scrolling from index to",{behavior:B,index:de,top:z},It.DEBUG),{behavior:B,top:z}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},bt(la,on,cr),{singleton:!0});function WS(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function yf(t,r){t===0?r():requestAnimationFrame(()=>{yf(t-1,r)})}function bf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Ys=et(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:f}])=>{const h=ge(!0),g=ge(0),p=ge(!0);return Ce(pe(f,Ve(g),ze(([y,v])=>v!==0),na(!1)),h),Ce(pe(f,Ve(g),ze(([y,v])=>v!==0),na(!1)),p),at(pe(Dt(r,f),Ve(h,s,t,p),ze(([[,y],v,{sizeTree:j},S,k])=>y&&(!ut(j)||mf(S))&&!v&&!k),Ve(g)),([,y])=>{Wn(c,()=>{$e(p,!0)}),yf(4,()=>{Wn(o,()=>{$e(h,!0)}),$e(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},bt(la,on,Ws,ur),{singleton:!0});function Pv(t,r){return Math.abs(t-r)<1.01}const $s="up",zs="down",YS="none",qS={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},KS=0,qs=et(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const f=ge(!1),h=ge(!0),g=Xe(),p=Xe(),y=ge(4),v=ge(KS),j=Zt(pe(Yd(pe(Le(c),Dr(1),na(!0)),pe(Le(c),Dr(1),na(!1),rg(100))),yt()),!1),S=Zt(pe(Yd(pe(s,na(!0)),pe(s,na(!1),rg(200))),yt()),!1);Ce(pe(Dt(Le(c),Le(v)),je(([A,D])=>A<=D),yt()),h),Ce(pe(h,Na(50)),p);const k=En(pe(Dt(o,Le(u),Le(r),Le(t),Le(y)),aa((A,[{scrollHeight:D,scrollTop:U},L,F,C,O])=>{const T=U+L-D>-O,_={scrollHeight:D,scrollTop:U,viewportHeight:L};if(T){let K,Q;return U>A.state.scrollTop?(K="SCROLLED_DOWN",Q=A.state.scrollTop-U):(K="SIZE_DECREASED",Q=A.state.scrollTop-U||A.scrollTopDelta),{atBottom:!0,atBottomBecause:K,scrollTopDelta:Q,state:_}}let I;return _.scrollHeight>A.state.scrollHeight?I="SIZE_INCREASED":L<A.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":U<A.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:_}},qS),yt((A,D)=>A!==void 0&&A.atBottom===D.atBottom))),E=Zt(pe(o,aa((A,{scrollHeight:D,scrollTop:U,viewportHeight:L})=>{if(!Pv(A.scrollHeight,D)){const F=D-(U+L)<1;return A.scrollTop!==U&&F?{changed:!0,jump:A.scrollTop-U,scrollHeight:D,scrollTop:U}:{changed:!0,jump:0,scrollHeight:D,scrollTop:U}}return{changed:!1,jump:0,scrollHeight:D,scrollTop:U}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ze(A=>A.changed),je(A=>A.jump)),0);Ce(pe(k,je(A=>A.atBottom)),f),Ce(pe(f,Na(50)),g);const w=ge(zs);Ce(pe(o,je(({scrollTop:A})=>A),yt(),aa((A,D)=>kt(S)?{direction:A.direction,prevScrollTop:D}:{direction:D<A.prevScrollTop?$s:zs,prevScrollTop:D},{direction:zs,prevScrollTop:0}),je(A=>A.direction)),w),Ce(pe(o,Na(50),na(YS)),w);const N=ge(0);return Ce(pe(j,ze(A=>!A),na(0)),N),Ce(pe(c,Na(100),Ve(j),ze(([A,D])=>D),aa(([A,D],[U])=>[D,U],[0,0]),je(([A,D])=>D-A)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:f,isAtTop:h,isScrolling:j,lastJumpDueToItemResize:E,scrollDirection:w,scrollVelocity:N}},bt(on)),Vs="top",Ps="bottom",og="none";function cg(t,r,s){return typeof t=="number"?s===$s&&r===Vs||s===zs&&r===Ps?t:0:s===$s?r===Vs?t.main:t.reverse:r===Ps?t.main:t.reverse}function ug(t,r){return typeof t=="number"?t:t[r]??0}const jf=et(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),f=ge(0),h=ge(0),g=ge(0),p=Zt(pe(Dt(Le(o),Le(c),Le(s),Le(u,Hs),Le(g),Le(f),Le(r),Le(t),Le(h)),je(([y,v,j,[S,k],E,w,N,A,D])=>{const U=y-A,L=w+N,F=Math.max(j-U,0);let C=og;const O=ug(D,Vs),T=ug(D,Ps);return S-=A,S+=j+N,k+=j+N,k-=A,S>y+L-O&&(C=$s),k<y-F+v+T&&(C=zs),C!==og?[Math.max(U-j-cg(E,Vs,C)-O,0),U-F-N+v+cg(E,Ps,C)+T]:null}),ze(y=>y!==null),yt(Hs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:f,visibleRange:p}},bt(on),{singleton:!0});function XS(t,r,s){if(Vo(r)){const o=Hv(t,r);return[{index:qn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const jd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Eo(t,r,s,o,c,u){const{lastIndex:f,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-f,j=h+v*g+(v-1)*o,S=p,k=j-y;return{bottom:y,firstItemIndex:u,items:dg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:dg(r,c,u),topListHeight:r.reduce((E,w)=>w.size+E,0),totalCount:s}}function Fv(t,r,s,o,c,u){let f=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-f>=t)break;f++}const h=t+f,g=bf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Eo(p,[],h,c,s,o)}function dg(t,r,s){if(t.length===0)return[];if(!Vo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],f=Cl(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=f.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function fg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Br=et(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:f,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},j,{didMount:S},{recalcInProgress:k}])=>{const E=ge([]),w=ge(0),N=Xe(),A=ge(0);Ce(u.topItemsIndexes,E);const D=Zt(pe(Dt(S,k,Le(g,Hs),Le(c),Le(o),Le(p),y,Le(E),Le(r),Le(s),Le(A),t),ze(([C,O,,T,,,,,,,,_])=>{const I=_!==void 0&&_.length!==T;return C&&!O&&!I}),je(([,,[C,O],T,_,I,K,Q,q,H,M,B])=>{var ye,Ne;const V=_,{offsetTree:W,sizeTree:de}=V,z=kt(w);if(T===0)return{...jd,totalCount:T};if(C===0&&O===0)return z===0?{...jd,totalCount:T}:Fv(z,I,_,q,H,B||[]);if(ut(de))return z>0?null:Eo(XS(bf(I,T),V,B),[],T,H,V,q);const P=[];if(Q.length>0){const Me=Q[0],re=Q[Q.length-1];let fe=0;for(const me of Cl(de,Me,re)){const he=me.value,be=Math.max(me.start,Me),_e=Math.min(me.end,re);for(let De=be;De<=_e;De++)P.push({data:B==null?void 0:B[De],index:De,offset:fe,size:he}),fe+=he}}if(!K)return Eo([],P,T,H,V,q);const te=Q.length>0?Q[Q.length-1]+1:0,le=IS(W,C,O,te);if(le.length===0)return null;const xe=T-1,ce=$o([],Me=>{for(const re of le){const fe=re.value;let me=fe.offset,he=re.start;const be=fe.size;if(fe.offset<C){he+=Math.floor((C-fe.offset+H)/(be+H));const De=he-re.start;me+=De*be+De*H}he<te&&(me+=(te-he)*be,he=te);const _e=Math.min(re.end,xe);for(let De=he;De<=_e&&!(me>=O);De++)Me.push({data:B==null?void 0:B[De],index:De,offset:me,size:be}),me+=be+H}}),ve=fg(M,Vs),ue=fg(M,Ps);if(ce.length>0&&(ve>0||ue>0)){const Me=ce[0],re=ce[ce.length-1];if(ve>0&&Me.index>te){const fe=Math.min(ve,Me.index-te),me=[];let he=Me.offset;for(let be=Me.index-1;be>=Me.index-fe;be--){const _e=((ye=Cl(de,be,be)[0])==null?void 0:ye.value)??Me.size;he-=_e+H,me.unshift({data:B==null?void 0:B[be],index:be,offset:he,size:_e})}ce.unshift(...me)}if(ue>0&&re.index<xe){const fe=Math.min(ue,xe-re.index);let me=re.offset+re.size+H;for(let he=re.index+1;he<=re.index+fe;he++){const be=((Ne=Cl(de,he,he)[0])==null?void 0:Ne.value)??re.size;ce.push({data:B==null?void 0:B[he],index:he,offset:me,size:be}),me+=be+H}}}return Eo(ce,P,T,H,V,q)}),ze(C=>C!==null),yt()),jd);Ce(pe(t,ze(mf),je(C=>C==null?void 0:C.length)),c),Ce(pe(D,je(C=>C.topListHeight)),v),Ce(v,h),Ce(pe(D,je(C=>[C.top,C.bottom])),f),Ce(pe(D,je(C=>C.items)),N);const U=En(pe(D,ze(({items:C})=>C.length>0),Ve(c,t),ze(([{items:C},O])=>C[C.length-1].originalIndex===O-1),je(([,C,O])=>[C-1,O]),yt(Hs),je(([C])=>C))),L=En(pe(D,Na(200),ze(({items:C,topItems:O})=>C.length>0&&C[0].originalIndex===O.length),je(({items:C})=>C[0].index),yt())),F=En(pe(D,ze(({items:C})=>C.length>0),je(({items:C})=>{let O=0,T=C.length-1;for(;C[O].type==="group"&&O<T;)O++;for(;C[T].type==="group"&&T>O;)T--;return{endIndex:C[T].index,startIndex:C[O].index}}),yt(Bv)));return{endReached:U,initialItemCount:w,itemsRendered:N,listState:D,minOverscanItemCount:A,rangeChanged:F,startReached:L,topItemsIndexes:E,...j}},bt(la,$v,jf,Ys,Ws,qs,ur,gf),{singleton:!0}),Gv=et(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),f=Zt(pe(Dt(s,t,o,r,c),je(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Ce(Le(f),u),{totalListHeight:f,totalListHeightChanged:u}},bt(on,Br),{singleton:!0}),QS=et(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ge(!1),o=Zt(pe(Dt(s,t,r),ze(([c])=>c),je(([,c,u])=>Math.max(0,c-u)),Na(0),yt()),0);return{alignToBottom:s,paddingTopAddition:o}},bt(on,Gv),{singleton:!0}),Wv=et(()=>({context:ge(null)})),ZS=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:f})=>r<f?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Yv=et(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:f,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Ce(pe(y,Ve(r,g,s,u,c,o,h),Ve(t),je(([[v,j,S,k,E,w,N,A],D])=>{const{calculateViewLocation:U=ZS,done:L,...F}=v,C=Uv(v,j,k-1),O=Us(C,j.offsetTree,D)+E+w,T=O+qn(j.sizeTree,C)[1],_=A+w,I=A+S-N,K=U({itemBottom:T,itemTop:O,locationParams:F,viewportBottom:I,viewportTop:_});return K!==null?L&&Wn(pe(f,ze(Q=>!Q),Dr(kt(f)?1:2)),L):L==null||L(),K}),ze(v=>v!==null)),p),{scrollIntoView:y}},bt(la,on,Ws,Br,cr),{singleton:!0});function pg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const JS=(t,r)=>typeof t=="function"?pg(t(r)):r&&pg(t),ek=et(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:f},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:j},{scrollIntoView:S}])=>{const k=ge(!1),E=Xe();let w=null;function N(L){$e(f,{align:"end",behavior:L,index:"LAST"})}at(pe(Dt(pe(Le(r),Dr(1)),g),Ve(Le(k),u,h,v),je(([[L,F],C,O,T,_])=>{let I=F&&T,K="auto";return I&&(K=JS(C,O||_),I=I&&K!==!1),{followOutputBehavior:K,shouldFollow:I,totalCount:L}}),ze(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:F})=>{w!==null&&(w(),w=null),kt(s)!==void 0?requestAnimationFrame(()=>{kt(y)("following output to ",{totalCount:F},It.DEBUG),N(L)}):w=Wn(t,()=>{kt(y)("following output to ",{totalCount:F},It.DEBUG),N(L),w=null})});function A(L){const F=Wn(c,C=>{L&&!C.atBottom&&C.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(kt(y)("scrolling to bottom due to increased size",{},It.DEBUG),N("auto"))});setTimeout(F,100)}at(pe(Dt(Le(k),r,p),ze(([L,,F])=>L!==!1&&F),aa(({value:L},[,F])=>({refreshed:L===F,value:F}),{refreshed:!1,value:0}),ze(({refreshed:L})=>L),Ve(k,r)),([,L])=>{kt(h)&&A(L!==!1)}),at(E,()=>{A(kt(k)!==!1)}),at(Dt(Le(k),c),([L,F])=>{L!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const D=ge(null),U=Xe();return Ce(Yd(pe(Le(o),je(L=>(L==null?void 0:L.length)??0)),pe(Le(r))),U),at(pe(Dt(pe(U,Dr(1)),g),Ve(Le(D),h,v,j),je(([[L,F],C,O,T,_])=>F&&O&&(C==null?void 0:C({context:_,totalCount:L,scrollingInProgress:T}))),ze(L=>!!L),Na(0)),L=>{w!==null&&(w(),w=null),kt(s)!==void 0?requestAnimationFrame(()=>{kt(y)("scrolling into view",{}),$e(S,L)}):w=Wn(t,()=>{kt(y)("scrolling into view",{}),$e(S,L),w=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:D}},bt(la,qs,Ws,Ys,ur,cr,on,Wv,Yv)),tk=et(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:f},{didMount:h}])=>(Ce(pe(h,Ve(u),ze(([,g])=>g!==0),Ve(c,o,r,s,t),je(([[,g],p,y,v,j,S=[]])=>Fv(g,p,y,v,j,S))),f),{}),bt(la,Ys,Br,ur),{singleton:!0}),nk=et(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ge(0);return at(pe(t,Ve(o),ze(([,c])=>c!==0),je(([,c])=>({top:c}))),c=>{Wn(pe(s,Dr(1),ze(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{$e(r,c)})})}),{initialScrollTop:o}},bt(ur,on,Br),{singleton:!0}),qv=et(([{scrollVelocity:t}])=>{const r=ge(!1),s=Xe(),o=ge(!1);return Ce(pe(t,Ve(o,r,s),ze(([c,u])=>u!==!1&&u!==void 0),je(([c,u,f,h])=>{const{enter:g,exit:p}=u;if(f){if(p(c,h))return!1}else if(g(c,h))return!0;return f}),yt()),r),at(pe(Dt(r,t,s),Ve(o)),([[c,u,f],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,f)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},bt(qs),{singleton:!0}),Sf=et(([{scrollContainerState:t,scrollTo:r}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ge(!1),f=ge(void 0);return Ce(pe(Dt(s,o),je(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Ce(pe(r,Ve(o),je(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:f,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},bt(on)),ak=et(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:f,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ge(void 0),v=ge(null),j=ge(null);return Ce(h,v),Ce(g,j),at(pe(p,Ve(r,o,f,v,j,s)),([S,k,E,w,N,A,D])=>{const U=US(k.sizeTree);w&&N!==null&&A!==null&&(E=N.scrollTop-A.offsetTop),E-=D,S({ranges:U,scrollTop:E})}),Ce(pe(y,ze(mf),je(rk)),c),Ce(pe(u,Ve(y),ze(([,S])=>S!==void 0),yt(),je(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},bt(la,on,Ys,ur,Sf));function rk(t){return{align:"start",index:0,offset:t.scrollTop}}const lk=et(([{topItemsIndexes:t}])=>{const r=ge(0);return Ce(pe(r,ze(s=>s>=0),je(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},bt(Br));function Kv(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const sk=Kv(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),ik=et(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:f,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:j},{log:S},{recalcInProgress:k}])=>{const E=En(pe(g,Ve(f),aa(([,N,A,D],[{bottom:U,items:L,offsetBottom:F,totalCount:C},O])=>{const T=U+F;let _=0;return A===C&&N.length>0&&L.length>0&&(L[0].originalIndex===0&&N[0].originalIndex===0||(_=T-D,_!==0&&(_+=O))),[_,L,C,T]},[0,[],0,0]),ze(([N])=>N!==0),Ve(o,h,s,c,S,k),ze(([,N,A,D,,,U])=>!U&&!D&&N!==0&&A===$s),je(([[N],,,,,A])=>(A("Upward scrolling compensation",{amount:N},It.DEBUG),N))));function w(N){N>0?($e(r,{behavior:"auto",top:-N}),$e(t,0)):($e(t,0),$e(r,{behavior:"auto",top:-N}))}return at(pe(E,Ve(t,u)),([N,A,D])=>{D&&sk()?$e(t,A-N):w(-N)}),at(pe(Dt(Zt(u,!1),t,k),ze(([N,A,D])=>!N&&!D&&A!==0),je(([N,A])=>A),Na(1)),w),Ce(pe(v,je(N=>({top:-N}))),r),at(pe(p,Ve(j,y),je(([N,{groupIndices:A,lastSize:D,sizeTree:U},L])=>{function F(I){return I*(D+L)}if(A.length===0)return F(N);let C=0;const O=Is(U,0);let T=0,_=0;for(;T<N;){T++,C+=O;let I=A.length===_+1?1/0:A[_+1]-A[_]-1;T+I>N&&(C-=O,I=N-T+1),T+=I,C+=F(I),_++}return C})),N=>{$e(t,N),requestAnimationFrame(()=>{$e(r,{top:N}),requestAnimationFrame(()=>{$e(t,0),$e(k,!1)})})}),{deviation:t}},bt(on,qs,Br,la,cr,gf)),ok=et(([t,r,s,o,c,u,f,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...f,...h,...g,...p,...y}),bt(jf,tk,ur,qv,Gv,nk,QS,Sf,Yv,cr,Wv)),Xv=et(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:f,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:j,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:w},N,A,D,U,{scrollToIndex:L},F,{topItemCount:C},{groupCounts:O},T])=>{const{listState:_,minOverscanItemCount:I,topItemsIndexes:K,rangeChanged:Q,...q}=U;return Ce(Q,T.scrollSeekRangeChanged),Ce(pe(T.windowViewportRect,je(H=>H.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:w,sizeRanges:p,topItemCount:C,topItemsIndexes:K,totalCount:j,...D,groupIndices:f,itemSize:g,listState:_,minOverscanItemCount:I,scrollToIndex:L,statefulTotalCount:v,trackItemSizes:S,rangeChanged:Q,...q,...T,...N,sizes:y,...A}},bt(la,Ys,on,ak,ek,Br,Ws,ik,lk,$v,ok));function ck(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const f in r)Object.hasOwn(o,f)||(s[f]=r[f]);return s}const uo=typeof document<"u"?we.useLayoutEffect:we.useEffect;function Qv(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),f=Object.keys(r.events||{}),h=we.createContext({});function g(w,N){w.propsReady!==void 0&&$e(w.propsReady,!1);for(const A of o){const D=w[r.required[A]];$e(D,N[A])}for(const A of c)if(A in N){const D=w[r.optional[A]];$e(D,N[A])}w.propsReady!==void 0&&$e(w.propsReady,!0)}function p(w){return u.reduce((N,A)=>(N[A]=D=>{const U=w[r.methods[A]];$e(U,D)},N),{})}function y(w){return f.reduce((N,A)=>(N[A]=ES(w[r.events[A]]),N),{})}const v=we.forwardRef(function(w,N){const{children:A,...D}=w,[U]=we.useState(()=>$o(NS(t),C=>{g(C,D)})),[L]=we.useState(ag(y,U));uo(()=>{for(const C of f)C in D&&at(L[C],D[C]);return()=>{Object.values(L).map(hf)}},[D,L,U]),uo(()=>{g(U,D)}),we.useImperativeHandle(N,ng(p(U)));const F=s;return a.jsx(h.Provider,{value:U,children:s!==void 0?a.jsx(F,{...ck([...o,...c,...f],D),children:A}):A})}),j=w=>{const N=we.useContext(h);return we.useCallback(A=>{$e(N[w],A)},[N,w])},S=w=>{const N=we.useContext(h)[w],A=we.useCallback(D=>at(N,D),[N]);return we.useSyncExternalStore(A,()=>kt(N),()=>kt(N))},k=w=>{const N=we.useContext(h)[w],[A,D]=we.useState(ag(kt,N));return uo(()=>at(N,U=>{U!==A&&D(ng(U))}),[N,A]),A},E=parseInt(we.version)>=18?S:k;return{Component:v,useEmitter:(w,N)=>{const A=we.useContext(h)[w];uo(()=>at(A,N),[N,A])},useEmitterValue:E,usePublisher:j}}const Zv=we.createContext(void 0),Jv=we.createContext(void 0),Sd="-webkit-sticky",mg="sticky",kf=Kv(()=>{if(typeof document>"u")return mg;const t=document.createElement("div");return t.style.position=Sd,t.style.position===Sd?Sd:mg}),ey=typeof document<"u"?we.useLayoutEffect:we.useEffect;function kd(t){return"self"in t}function uk(t){return"body"in t}function ty(t,r,s,o=zl,c,u){const f=we.useRef(null),h=we.useRef(null),g=we.useRef(null),p=we.useCallback(j=>{let S,k,E;const w=j.target;if(uk(w)||kd(w)){const A=kd(w)?w:w.defaultView;E=u===!0?A.scrollX:A.scrollY,S=u===!0?A.document.documentElement.scrollWidth:A.document.documentElement.scrollHeight,k=u===!0?A.innerWidth:A.innerHeight}else E=u===!0?w.scrollLeft:w.scrollTop,S=u===!0?w.scrollWidth:w.scrollHeight,k=u===!0?w.offsetWidth:w.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};j.suppressFlushSync===!0?N():_j.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);we.useEffect(()=>{const j=c||f.current;return o(c||f.current),p({suppressFlushSync:!0,target:j}),j.addEventListener("scroll",p,{passive:!0}),()=>{o(null),j.removeEventListener("scroll",p)}},[f,p,s,o,c]);function y(j){const S=f.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=j.behavior==="smooth";let E,w,N;kd(S)?(w=Math.max(sr(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(w=S[u===!0?"scrollWidth":"scrollHeight"],E=sr(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const A=w-E;if(j.top=Math.ceil(Math.max(Math.min(A,j.top),0)),Pv(E,w)||j.top===N){t({scrollHeight:w,scrollTop:N,viewportHeight:E}),k&&r(!0);return}k?(h.current=j.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(j={...j.behavior!==void 0?{behavior:j.behavior}:{},left:j.top}),S.scrollTo(j)}function v(j){u===!0&&(j={...j.behavior!==void 0?{behavior:j.behavior}:{},...j.top!==void 0?{left:j.top}:{}}),f.current.scrollBy(j)}return{scrollByCallback:v,scrollerRef:f,scrollToCallback:y}}function wf(t){return t}const dk=et(()=>{const t=ge(h=>`Item ${h}`),r=ge(h=>`Group ${h}`),s=ge({}),o=ge(wf),c=ge("div"),u=ge(zl),f=(h,g=null)=>Zt(pe(s,je(p=>p[h]),yt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:f("EmptyPlaceholder"),FooterComponent:f("Footer"),GroupComponent:f("Group","div"),groupContent:r,HeaderComponent:f("Header"),HeaderFooterTag:c,ItemComponent:f("Item","div"),itemContent:t,ListComponent:f("List","div"),ScrollerComponent:f("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:f("ScrollSeekPlaceholder"),TopItemListComponent:f("TopItemList")}}),fk=et(([t,r])=>({...t,...r}),bt(Xv,dk)),pk=({height:t})=>a.jsx("div",{style:{height:t}}),mk={overflowAnchor:"none",position:kf(),zIndex:1},ny={overflowAnchor:"none"},hk={...ny,display:"inline-block",height:"100%"},hg=we.memo(function({showTopList:t=!1}){const r=Be("listState"),s=Un("sizeRanges"),o=Be("useWindowScroll"),c=Be("customScrollParent"),u=Un("windowScrollContainerState"),f=Un("scrollContainerState"),h=c||o?u:f,g=Be("itemContent"),p=Be("context"),y=Be("groupContent"),v=Be("trackItemSizes"),j=Be("itemSize"),S=Be("log"),k=Un("gap"),E=Be("horizontalDirection"),{callbackRef:w}=AS(s,j,v,t?zl:h,S,k,c,E,Be("skipAnimationFrameInResizeObserver")),[N,A]=we.useState(0);Ef("deviation",q=>{N!==q&&A(q)});const D=Be("EmptyPlaceholder"),U=Be("ScrollSeekPlaceholder")??pk,L=Be("ListComponent"),F=Be("ItemComponent"),C=Be("GroupComponent"),O=Be("computeItemKey"),T=Be("isSeeking"),_=Be("groupIndices").length>0,I=Be("alignToBottom"),K=Be("initialItemFinalLocationReached"),Q=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:I?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:I?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...K?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&D!==null&&D!==void 0?a.jsx(D,{...Qt(D,p)}):a.jsx(L,{...Qt(L,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:Q,children:(t?r.topItems:r.items).map(q=>{const H=q.originalIndex,M=O(H+r.firstItemIndex,q.data,p);return T?x.createElement(U,{...Qt(U,p),height:q.size,index:q.index,key:M,type:q.type||"item",...q.type==="group"?{}:{groupIndex:q.groupIndex}}):q.type==="group"?x.createElement(C,{...Qt(C,p),"data-index":H,"data-item-index":q.index,"data-known-size":q.size,key:M,style:mk},y(q.index,p)):x.createElement(F,{...Qt(F,p),...yk(F,q.data),"data-index":H,"data-item-group-index":q.groupIndex,"data-item-index":q.index,"data-known-size":q.size,key:M,style:E?hk:ny},_?g(q.index,q.groupIndex,q.data,p):g(q.index,q.data,p))})})}),xk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},gk={outline:"none",overflowX:"auto",position:"relative"},Po=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),vk={position:kf(),top:0,width:"100%",zIndex:1};function Qt(t,r){if(typeof t!="string")return{context:r}}function yk(t,r){return{item:typeof t=="string"?void 0:r}}const bk=we.memo(function(){const t=Be("HeaderComponent"),r=Un("headerHeight"),s=Be("HeaderFooterTag"),o=Or(we.useMemo(()=>u=>{r(sr(u,"height"))},[r]),!0,Be("skipAnimationFrameInResizeObserver")),c=Be("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...Qt(t,c)})}):null}),jk=we.memo(function(){const t=Be("FooterComponent"),r=Un("footerHeight"),s=Be("HeaderFooterTag"),o=Or(we.useMemo(()=>u=>{r(sr(u,"height"))},[r]),!0,Be("skipAnimationFrameInResizeObserver")),c=Be("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...Qt(t,c)})}):null});function ay({useEmitter:t,useEmitterValue:r,usePublisher:s}){return we.memo(function({children:o,style:c,context:u,...f}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:j,scrollerRef:S,scrollToCallback:k}=ty(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",j),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?gk:xk,...c},tabIndex:0,...f,...Qt(g,u),children:o})})}function ry({useEmitter:t,useEmitterValue:r,usePublisher:s}){return we.memo(function({children:o,style:c,context:u,...f}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),j=r("customScrollParent"),S=we.useRef(null),k=r("scrollerRef"),{scrollByCallback:E,scrollerRef:w,scrollToCallback:N}=ty(h,p,g,k,j);return ey(()=>{var A;return w.current=j||((A=S.current)==null?void 0:A.ownerDocument.defaultView),()=>{w.current=null}},[w,j]),t("windowScrollTo",N),t("scrollBy",E),a.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...f,...Qt(g,u),children:o})})}const Sk=({children:t})=>{const r=we.useContext(Zv),s=Un("viewportHeight"),o=Un("fixedItemHeight"),c=Be("alignToBottom"),u=Be("horizontalDirection"),f=we.useMemo(()=>Rv(s,g=>sr(g,u?"width":"height")),[s,u]),h=Or(f,!0,Be("skipAnimationFrameInResizeObserver"));return we.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Po(c),children:t})},kk=({children:t})=>{const r=we.useContext(Zv),s=Un("windowViewportRect"),o=Un("fixedItemHeight"),c=Be("customScrollParent"),u=Mv(s,c,Be("skipAnimationFrameInResizeObserver")),f=Be("alignToBottom");return we.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Po(f),children:t})},wk=({children:t})=>{const r=Be("TopItemListComponent")??"div",s=Be("headerHeight"),o={...vk,marginTop:`${s}px`},c=Be("context");return a.jsx(r,{style:o,...Qt(r,c),children:t})},Ek=we.memo(function(t){const r=Be("useWindowScroll"),s=Be("topItemsIndexes").length>0,o=Be("customScrollParent"),c=Be("context");return a.jsxs(o||r?Tk:Nk,{...t,context:c,children:[s&&a.jsx(wk,{children:a.jsx(hg,{showTopList:!0})}),a.jsxs(o||r?kk:Sk,{children:[a.jsx(bk,{}),a.jsx(hg,{}),a.jsx(jk,{})]})]})}),{Component:Ck,useEmitter:Ef,useEmitterValue:Be,usePublisher:Un}=Qv(fk,{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"}},Ek),Nk=ay({useEmitter:Ef,useEmitterValue:Be,usePublisher:Un}),Tk=ry({useEmitter:Ef,useEmitterValue:Be,usePublisher:Un}),Rk=Ck,Ak=et(()=>{const t=ge(p=>a.jsxs("td",{children:["Item $",p]})),r=ge(null),s=ge(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ge(null),c=ge(null),u=ge({}),f=ge(wf),h=ge(zl),g=(p,y=null)=>Zt(pe(u,je(v=>v[p]),yt()),y);return{components:u,computeItemKey:f,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});bt(Xv,Ak);kf();const xg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Mk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:gg,floor:Ao,max:Ds,min:wd,round:vg}=Math;function yg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Lk(t){return{...Mk,items:t}}function fo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function zk(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Dk=et(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:f,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},j,S,{didMount:k,propsReady:E},{customScrollParent:w,useWindowScroll:N,windowScrollContainerState:A,windowScrollTo:D,windowViewportRect:U},L])=>{const F=ge(0),C=ge(0),O=ge(xg),T=ge({height:0,width:0}),_=ge({height:0,width:0}),I=Xe(),K=Xe(),Q=ge(0),q=ge(null),H=ge({column:0,row:0}),M=Xe(),B=Xe(),V=ge(!1),W=ge(0),de=ge(!0),z=ge(!1),P=ge(!1);at(pe(k,Ve(W),ze(([ue,ye])=>ye!==0)),()=>{$e(de,!1)}),at(pe(Dt(k,de,_,T,W,z),ze(([ue,ye,Ne,Me,,re])=>ue&&!ye&&Ne.height!==0&&Me.height!==0&&!re)),([,,,,ue])=>{$e(z,!0),yf(1,()=>{$e(I,ue)}),Wn(pe(p),()=>{$e(r,[0,0]),$e(de,!0)})}),Ce(pe(B,ze(ue=>ue!=null&&ue.scrollTop>0),na(0)),C),at(pe(k,Ve(B),ze(([,ue])=>ue!=null)),([,ue])=>{ue&&($e(T,ue.viewport),$e(_,ue.item),$e(H,ue.gap),ue.scrollTop>0&&($e(V,!0),Wn(pe(p,Dr(1)),ye=>{$e(V,!1)}),$e(g,{top:ue.scrollTop})))}),Ce(pe(T,je(({height:ue})=>ue)),v),Ce(pe(Dt(Le(T,fo),Le(_,fo),Le(H,(ue,ye)=>ue!==void 0&&ue.column===ye.column&&ue.row===ye.row),Le(p)),je(([ue,ye,Ne,Me])=>({gap:Ne,item:ye,scrollTop:Me,viewport:ue}))),M),Ce(pe(Dt(Le(F),o,Le(H,zk),Le(_,fo),Le(T,fo),Le(q),Le(C),Le(V),Le(de),Le(W)),ze(([,,,,,,,ue])=>!ue),je(([ue,[ye,Ne],Me,re,fe,me,he,,be,_e])=>{const{column:De,row:pt}=Me,{height:_t,width:mt}=re,{width:Jt}=fe;if(he===0&&(ue===0||Jt===0))return xg;if(mt===0){const qt=bf(_e,ue),dr=qt+Math.max(he-1,0);return Lk(yg(qt,dr,me))}const ht=ly(Jt,mt,De);let Qe,xt;be?ye===0&&Ne===0&&he>0?(Qe=0,xt=he-1):(Qe=ht*Ao((ye+pt)/(_t+pt)),xt=ht*gg((Ne+pt)/(_t+pt))-1,xt=wd(ue-1,Ds(xt,ht-1)),Qe=wd(xt,Ds(0,Qe))):(Qe=0,xt=-1);const J=yg(Qe,xt,me),{bottom:Te,top:Pe}=bg(fe,Me,re,J),en=gg(ue/ht),Xn=en*_t+(en-1)*pt-Te;return{bottom:Te,itemHeight:_t,items:J,itemWidth:mt,offsetBottom:Xn,offsetTop:Pe,top:Pe}})),O),Ce(pe(q,ze(ue=>ue!==null),je(ue=>ue.length)),F),Ce(pe(Dt(T,_,O,H),ze(([ue,ye,{items:Ne}])=>Ne.length>0&&ye.height!==0&&ue.height!==0),je(([ue,ye,{items:Ne},Me])=>{const{bottom:re,top:fe}=bg(ue,Me,ye,Ne);return[fe,re]}),yt(Hs)),r);const te=ge(!1);Ce(pe(p,Ve(te),je(([ue,ye])=>ye||ue!==0)),te);const le=En(pe(Dt(O,F),ze(([{items:ue}])=>ue.length>0),Ve(te),ze(([[ue,ye],Ne])=>{const Me=ue.items[ue.items.length-1].index===ye-1;return(Ne||ue.bottom>0&&ue.itemHeight>0&&ue.offsetBottom===0&&ue.items.length===ye)&&Me}),je(([[,ue]])=>ue-1),yt())),xe=En(pe(Le(O),ze(({items:ue})=>ue.length>0&&ue[0].index===0),na(0),yt())),ce=En(pe(Le(O),Ve(V),ze(([{items:ue},ye])=>ue.length>0&&!ye),je(([{items:ue}])=>({endIndex:ue[ue.length-1].index,startIndex:ue[0].index})),yt(Bv),Na(0)));Ce(ce,S.scrollSeekRangeChanged),Ce(pe(I,Ve(T,_,F,H),je(([ue,ye,Ne,Me,re])=>{const fe=Vv(ue),{align:me,behavior:he,offset:be}=fe;let _e=fe.index;_e==="LAST"&&(_e=Me-1),_e=Ds(0,_e,wd(Me-1,_e));let De=Zd(ye,re,Ne,_e);return me==="end"?De=vg(De-ye.height+Ne.height):me==="center"&&(De=vg(De-ye.height/2+Ne.height/2)),be!==void 0&&be!==0&&(De+=be),{behavior:he,top:De}})),g);const ve=Zt(pe(O,je(ue=>ue.offsetBottom+ue.bottom)),0);return Ce(pe(U,je(ue=>({height:ue.visibleHeight,width:ue.visibleWidth}))),T),{customScrollParent:w,data:q,deviation:Q,footerHeight:c,gap:H,headerHeight:u,increaseViewportBy:t,initialItemCount:C,itemDimensions:_,overscan:s,restoreStateFrom:B,scrollBy:f,scrollContainerState:h,scrollHeight:K,scrollTo:g,scrollToIndex:I,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:T,windowScrollContainerState:A,windowScrollTo:D,windowViewportRect:U,...S,gridState:O,horizontalDirection:P,initialTopMostItemIndex:W,totalListHeight:ve,...j,endReached:le,propsReady:E,rangeChanged:ce,startReached:xe,stateChanged:M,stateRestoreInProgress:V,...L}},bt(jf,on,qs,qv,ur,Sf,cr));function ly(t,r,s){return Ds(1,Ao((t+s)/(Ao(r)+s)))}function bg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=Zd(t,r,s,o[0].index);return{bottom:Zd(t,r,s,o[o.length-1].index)+c,top:u}}function Zd(t,r,s,o){const c=ly(t.width,s.width,r.column),u=Ao(o/c),f=u*s.height+Ds(0,u-1)*r.row;return f>0?f+r.row:f}const _k=et(()=>{const t=ge(v=>`Item ${v}`),r=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(wf),f=ge("div"),h=ge(zl),g=(v,j=null)=>Zt(pe(r,je(S=>S[v]),yt()),j),p=ge(!1),y=ge(!1);return Ce(Le(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:f,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Ok=et(([t,r])=>({...t,...r}),bt(Dk,_k)),Bk=we.memo(function(){const t=St("gridState"),r=St("listClassName"),s=St("itemClassName"),o=St("itemContent"),c=St("computeItemKey"),u=St("isSeeking"),f=$n("scrollHeight"),h=St("ItemComponent"),g=St("ListComponent"),p=St("ScrollSeekPlaceholder"),y=St("context"),v=$n("itemDimensions"),j=$n("gap"),S=St("log"),k=St("stateRestoreInProgress"),E=$n("reportReadyState"),w=Or(we.useMemo(()=>N=>{const A=N.parentElement.parentElement.scrollHeight;f(A);const D=N.firstChild;if(D!==null){const{height:U,width:L}=D.getBoundingClientRect();v({height:U,width:L})}j({column:jg("column-gap",getComputedStyle(N).columnGap,S),row:jg("row-gap",getComputedStyle(N).rowGap,S)})},[f,v,j,S]),!0,!1);return ey(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:a.jsx(g,{className:r,ref:w,...Qt(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const A=c(N.index,N.data,y);return u?a.jsx(p,{...Qt(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},A):x.createElement(h,{...Qt(h,y),className:s,"data-index":N.index,key:A},o(N.index,N.data,y))})})}),Ik=we.memo(function(){const t=St("HeaderComponent"),r=$n("headerHeight"),s=St("headerFooterTag"),o=Or(we.useMemo(()=>u=>{r(sr(u,"height"))},[r]),!0,!1),c=St("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...Qt(t,c)})}):null}),Hk=we.memo(function(){const t=St("FooterComponent"),r=$n("footerHeight"),s=St("headerFooterTag"),o=Or(we.useMemo(()=>u=>{r(sr(u,"height"))},[r]),!0,!1),c=St("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...Qt(t,c)})}):null}),Uk=({children:t})=>{const r=we.useContext(Jv),s=$n("itemDimensions"),o=$n("viewportDimensions"),c=Or(we.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return we.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Po(!1),children:t})},$k=({children:t})=>{const r=we.useContext(Jv),s=$n("windowViewportRect"),o=$n("itemDimensions"),c=St("customScrollParent"),u=Mv(s,c,!1);return we.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Po(!1),children:t})},Vk=we.memo(function({...t}){const r=St("useWindowScroll"),s=St("customScrollParent"),o=s||r?Fk:Pk,c=s||r?$k:Uk,u=St("context");return a.jsx(o,{...t,...Qt(o,u),children:a.jsxs(c,{children:[a.jsx(Ik,{}),a.jsx(Bk,{}),a.jsx(Hk,{})]})})}),{useEmitter:sy,useEmitterValue:St,usePublisher:$n}=Qv(Ok,{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"}},Vk),Pk=ay({useEmitter:sy,useEmitterValue:St,usePublisher:$n}),Fk=ry({useEmitter:sy,useEmitterValue:St,usePublisher:$n});function jg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,It.WARN),r==="normal"?0:parseInt(r??"0",10)}const Gk={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},iy={source:"Own",installed:"Installed"};function Wk(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function Yk(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Sg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=Gk[t],[f,h]=x.useState(()=>Wk(u)),g=x.useCallback(()=>{h(j=>{const S=!j;return Yk(u,S),S})},[u]),p=iy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!f,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(Kk,{collapsed:f}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(qk,{origin:t,updateCount:o})]}),!f&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function qk({origin:t,updateCount:r}){const[s,o]=x.useState(!1),c=iy[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:f=>{f.stopPropagation(),window.location.hash="#/updates"},onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),f.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Kk({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Cf(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Xk({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=x.useRef(null),f=x.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return x.useEffect(()=>{function g(p){var j;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(j=u.current)==null||j.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?f:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:f,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function Qk({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Zk({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function Jk({skillId:t,trackedForUpdates:r}){let s=null;try{s=x.useContext(bv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Ks(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,f=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${f}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function ew({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(Ks,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(Qk,{target:t.symlinkTarget??null}),a.jsx(Zk,{skill:t}),a.jsx(Jk,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Mo=x.memo(ew);function tw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((f,h)=>f.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(f=>{const h=!!s&&s.plugin===f.plugin&&s.skill===f.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Mo,{skill:f,isSelected:h,onSelect:()=>o(f),onContextMenu:c})},`${f.plugin}/${f.skill}`)})})]})}function nw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function kg({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:f=!1}){var S;const h=r??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=x.useState(()=>nw(o,s)),y=f?!1:g,v=x.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),j=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:j}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>a.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}function aw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=x.useState(!1),[u,f]=x.useState(null),[h,g]=x.useState(null),p=x.useRef(null);x.useEffect(()=>{if(!o)return;function v(j){p.current&&!p.current.contains(j.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){f(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){f(null);return}const j=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await j.json().catch(()=>({}));if(!j.ok||!S.ok){g(S.error??`${v} failed (${j.status})`);return}sn("skills"),sn("plugins"),s==null||s(),c(!1)}catch(j){g(j instanceof Error?j.message:String(j))}finally{f(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(j=>!j)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Ed,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Ed,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Ed,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Ed({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:f=>{f.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:f=>{r||(f.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function wg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:f}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",j=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),f&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(rw,{label:f.label,title:f.title,icon:f.icon,onClick:f.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:j}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:j})}function rw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function lw(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function sw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,f=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}f=r[r.length-1]}return{key:f.length===1?f.toLowerCase():f,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function iw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function ow(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function Jd(t,r={}){const{enabled:s=!0,target:o}=r,c=x.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(sw),x.useEffect(()=>{if(!s)return;const f=o??(typeof window<"u"?window:void 0);if(!f)return;function h(g){const p=g,y=iw(p.target);for(const v of c.current){if(!ow(p,v))continue;const j=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!j)){v.handler(p);return}}}return f.addEventListener("keydown",h),()=>{f.removeEventListener("keydown",h)}},[s,o])}const cw=200;function uw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function dw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Cf(g,r)),f={};for(const g of u){const p=g.pluginName??g.plugin;(f[p]||(f[p]=[])).push(g)}const h=Object.entries(f).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function fw(t,r){const s=[],o=[],c=[];for(const f of t){const h=uw(f);h==="global"?c.push(f):h==="installed"?o.push(f):s.push(f)}function u(f){var y;const h=f.filter(v=>Cf(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,j)=>v[0].localeCompare(j[0]));return{total:f.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function pw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const f=u.filter(y=>Cf(y,r)),h={};for(const y of f)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:f.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function mw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:f,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:j}){const S=!!g||t.some(P=>P.scope!==void 0&&P.scope!==null),k=g??"claude-cli",[E,w]=x.useState(""),N=x.useDeferredValue(E),A=x.useMemo(()=>fw(t,N),[t,N]),D=x.useMemo(()=>dw(t,N),[t,N]),U=k==="claude-code",{data:L}=Ml("plugins",()=>fetch("/api/plugins").then(P=>P.json()),{enabled:U,ttl:6e4}),F=x.useMemo(()=>{const P=new Map;for(const te of(L==null?void 0:L.plugins)??[]){const le=P.get(te.name);P.set(te.name,!!le||!!te.enabled)}return P},[L==null?void 0:L.plugins]),[C,O]=x.useState(()=>ef(`vskill-sidebar-${k}-group-available-collapsed`)),[T,_]=x.useState(()=>ef(`vskill-sidebar-${k}-group-authoring-collapsed`)),I=x.useCallback(P=>{O(P);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(P))}catch{}},[k]),K=x.useCallback(P=>{_(P);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(P))}catch{}},[k]),{own:Q,installed:q}=x.useMemo(()=>pw(t,N),[t,N]),M=A.own.filtered+A.installed.filtered+A.global.filtered>=cw,B=x.useMemo(()=>{const P=te=>{const le=[];for(const[,xe]of te){const ce=[...xe].sort((ve,ue)=>ve.skill.localeCompare(ue.skill));le.push(...ce)}return le};return S?[...P(A.own.byPlugin),...P(A.installed.byPlugin),...P(A.global.byPlugin)]:[...P(Q.byPlugin),...P(q.byPlugin)]},[S,A.own.byPlugin,A.installed.byPlugin,A.global.byPlugin,Q.byPlugin,q.byPlugin]),V=x.useMemo(()=>r?B.findIndex(P=>P.plugin===r.plugin&&P.skill===r.skill):-1,[B,r]),W=x.useCallback(P=>{if(B.length===0)return;const te=V<0?P>0?0:B.length-1:Math.min(Math.max(V+P,0),B.length-1);s(B[te])},[B,V,s]),de=x.useMemo(()=>{if(!v)return null;const[P,te]=v.split("/");if(!P||!te)return null;const le=t.find(ve=>ve.plugin===P&&ve.skill===te);if(!le)return{plugin:P,skill:te,bucket:null,pluginName:null};const xe=le.source==="plugin"?"plugin":"project",ce=xe==="plugin"?le.pluginName??P:null;return{plugin:P,skill:te,bucket:xe,pluginName:ce}},[v,t]),z=x.useRef(null);return x.useEffect(()=>{if(!v){z.current=null;return}if(z.current===v)return;const P=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${P}"]`);te&&(z.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),j==null||j())},[v,j,t]),Jd([{key:"j",handler:()=>W(1)},{key:"k",handler:()=>W(-1)},{key:"Enter",handler:()=>{V>=0&&s(B[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(Xk,{value:E,onChange:w}),o&&a.jsx(yw,{}),!o&&c&&a.jsx(bw,{error:c,onRetry:u}),!o&&!c&&S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(wg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:C,onToggle:I,count:D.availableProject.total+D.availablePersonal.total+D.availablePlugin.total}),!C&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:D.availableProject.total,filteredCount:E?D.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:D.availableProject.filtered===0?a.jsx(Cg,{queryActive:!!E,agentId:k}):a.jsx(Ts,{items:D.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:f,useVirtual:M})}),a.jsx(Ns,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:D.availablePersonal.total,filteredCount:E?D.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:D.availablePersonal.filtered===0?a.jsx(xw,{queryActive:!!E,agentId:k}):a.jsx(Ts,{items:D.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:f,useVirtual:M})}),U&&a.jsxs(Ns,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:D.availablePlugin.total,filteredCount:E?D.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),D.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):D.availablePlugin.byPlugin.map(([P,te])=>a.jsx(kg,{pluginName:P,skills:te,persistKey:`vskill-plugin-available-${P}-collapsed`,headerActionSlot:U?a.jsx(aw,{pluginName:P,enabled:F.get(P)??!0}):void 0,renderSkill:le=>a.jsx(Mo,{skill:le,isSelected:(r==null?void 0:r.plugin)===le.plugin&&(r==null?void 0:r.skill)===le.skill,onSelect:()=>s(le),onContextMenu:f})},`available-${P}`))]})]}),a.jsx(vw,{}),a.jsx(wg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:de?!1:T,onToggle:K,count:D.authoringProject.total+D.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!T||de)&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:D.authoringProject.total,filteredCount:E?D.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(de==null?void 0:de.bucket)==="project",children:D.authoringProject.filtered===0?a.jsx(Eg,{queryActive:!!E}):a.jsx(Ts,{items:D.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:f,useVirtual:M})}),U&&a.jsx(Ns,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:D.authoringPlugin.total,filteredCount:E?D.authoringPlugin.filtered:null,forceOpen:(de==null?void 0:de.bucket)==="plugin",children:D.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):D.authoringPlugin.byPlugin.map(([P,te])=>a.jsx(kg,{pluginName:P,skills:te,persistKey:`vskill-plugin-authoring-${P}-collapsed`,forceOpen:(de==null?void 0:de.bucket)==="plugin"&&de.pluginName===P,renderSkill:le=>a.jsx(Mo,{skill:le,isSelected:(r==null?void 0:r.plugin)===le.plugin&&(r==null?void 0:r.skill)===le.skill,onSelect:()=>s(le),onContextMenu:f})},`authoring-${P}`))})]})]}),!o&&!c&&!S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Sg,{origin:"source",count:Q.total,filteredCount:E?Q.filtered:null,updateCount:h==null?void 0:h.source,children:Q.filtered===0?a.jsx(Eg,{queryActive:!!E}):a.jsx(Ts,{items:Q.byPlugin,selectedKey:r,onSelect:s,onContextMenu:f,useVirtual:M})}),a.jsx(gw,{}),a.jsx(Sg,{origin:"installed",count:q.total,filteredCount:E?q.filtered:null,updateCount:h==null?void 0:h.installed,children:q.filtered===0?a.jsx(Cg,{queryActive:!!E}):a.jsx(Ts,{items:q.byPlugin,selectedKey:r,onSelect:s,onContextMenu:f,useVirtual:M})})]})]})}function ef(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ns({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:f=!1}){const[h,g]=x.useState(()=>ef(r)),p=f?!1:h,y=x.useCallback(()=>{g(j=>{const S=!j;if(typeof window<"u")try{window.localStorage.setItem(r,String(S))}catch{}return S})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function hw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,f)=>u.skill.localeCompare(f.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ts({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=hw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Rk,{overscan:4,totalCount:u.length,itemContent:f=>{const h=u[f];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Mo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,f])=>a.jsx(tw,{plugin:u,skills:f,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Eg({queryActive:t}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Nf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Cg({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install <plugin>"})," to add one."]})})}function xw({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install --global <plugin>"})," to add one."]})})}function Nl({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Nf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function gw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function vw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function yw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(lw,{},t))})}function bw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:jw(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function jw(t){const r=t.split(`
66
+ `)[0]??t;return r.length>80?r.slice(0,77)+"…":r}const oy=240,cy=480,uy="vskill-sidebar-width",_s=320;function Tf(t){return Number.isFinite(t)?Math.round(Math.max(oy,Math.min(cy,t))):_s}function Sw(){try{const t=localStorage.getItem(uy);if(!t)return _s;const r=Number(t);return Number.isFinite(r)?Tf(r):_s}catch{return _s}}function kw(t){try{localStorage.setItem(uy,String(Tf(t)))}catch{}}function ww({initialWidth:t,onChange:r}){const s=x.useRef({startX:0,startWidth:t,pointerId:null}),o=x.useRef(t);return x.useEffect(()=>{o.current=t},[t]),x.useEffect(()=>{function c(f){if(s.current.pointerId==null||f.pointerId!==s.current.pointerId)return;const h=f.clientX-s.current.startX,g=Tf(s.current.startWidth+h);o.current=g,r(g)}function u(f){s.current.pointerId==null||f.pointerId!==s.current.pointerId||(s.current.pointerId=null,kw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[r]),a.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":oy,"aria-valuemax":cy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Ew({connected:t,hint:r,onRetry:s}){return t?null:a.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),a.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&a.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),a.jsx("div",{style:{flex:1}}),s&&a.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function dy(t,r){if(t!==401||typeof window>"u"||!r||typeof r!="object")return;const s=r;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function fy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(r){console.error("Failed to serialize request body:",r);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Cd(){const[t,r]=x.useState([]),[s,o]=x.useState(!1),[c,u]=x.useState(!1),[f,h]=x.useState(null),g=x.useRef(null),p=x.useCallback(async(v,j)=>{r([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=fy(j),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let U=`HTTP ${E.status}`,L;try{L=await E.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(U=L.error)}catch{}throw dy(E.status,L),new Error(U)}const w=E.body.getReader(),N=new TextDecoder;let A="",D="";for(;;){const{done:U,value:L}=await w.read();if(U)break;A+=N.decode(L,{stream:!0});const F=A.split(`
67
+ `);A=F.pop()||"";for(const C of F)if(C.startsWith("event: "))D=C.slice(7).trim();else if(C.startsWith("data: ")){try{const O=JSON.parse(C.slice(6)),T={event:D,data:O};D==="done"?(u(!0),r(_=>[..._,T])):r(_=>[..._,T])}catch{}D=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=x.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:f,start:p,stop:y}}function Cw(t){const r=x.useRef(t);r.current=t;const[s,o]=x.useState(new Set),c=x.useRef(new Map),u=x.useCallback(async(p,y,v)=>{var S;(S=c.current.get(p))==null||S.abort();const j=new AbortController;c.current.set(p,j),o(k=>{const E=new Set(k);return E.add(p),E});try{const k=fy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:j.signal});if(!E.ok||!E.body){let U=`HTTP ${E.status}`,L;try{L=await E.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(U=L.error)}catch{}throw dy(E.status,L),new Error(U)}const w=E.body.getReader(),N=new TextDecoder;let A="",D="";for(;;){const{done:U,value:L}=await w.read();if(U)break;A+=N.decode(L,{stream:!0});const F=A.split(`
68
+ `);A=F.pop()||"";for(const C of F)if(C.startsWith("event: "))D=C.slice(7).trim();else if(C.startsWith("data: ")){try{const O=JSON.parse(C.slice(6)),T={event:D,data:O};r.current.onEvent(p,T)}catch{}D=""}}r.current.onDone(p)}catch(k){k.name!=="AbortError"&&r.current.onError(p,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(p),E}),c.current.delete(p)}},[]),f=x.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=x.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:f,stopAll:h,isAnyCaseRunning:g}}const Nw={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Tw(t,r){var s,o;switch(r.type){case"SET_LOADING":return{...t,loading:r.loading};case"SET_ERROR":return{...t,error:r.error};case"INIT_DATA":{const c=new Map;if(r.benchmark)for(const f of r.benchmark.cases)c.set(f.eval_id,{status:f.status,passRate:f.pass_rate,errorMessage:f.error_message||void 0,durationMs:f.durationMs,tokens:f.tokens,output:f.output,assertions:f.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=r.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:r.panel};case"SET_CONTENT":return{...t,skillContent:r.content,isDirty:r.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:r.evals};case"SELECT_CASE":return{...t,selectedCaseId:r.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...t,caseRunStates:c,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"complete",mode:u==null?void 0:u.mode});const f=new Map(t.inlineResults);return f.set(r.caseId,r.result),{...t,caseRunStates:c,inlineResults:f}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"error",mode:u==null?void 0:u.mode});const f=new Map(t.inlineResults);return f.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:f}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);return c.set(r.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of r.caseIds)c.set(u,{status:"queued",mode:r.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:r.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,f]of c)(f.status==="running"||f.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(r.evalId,r.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const c=r.evalChanges??[],u=new Map;for(let f=0;f<c.length;f++)u.set(f,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(r.index,!c.get(r.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:r.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:r.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,r.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:r.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:r.runs,activationHistoryLoading:!1};default:return t}}function Rw(t){if(t==="unit"||t==="integration")return t}function Aw(t,r){const s=r.data;if(r.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),r.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),r.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}r.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const py=x.createContext(null);function Nn(){const t=x.useContext(py);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Mw({plugin:t,skill:r,origin:s,children:o}){const c=s==="installed",[u,f]=x.useReducer(Tw,{...Nw,plugin:t,skill:r}),h=x.useRef(new Set),g=x.useRef(new Set),p=x.useRef(new Map),y=x.useCallback((re,fe)=>{let me=p.current.get(re);me||(me={assertions:[]},p.current.set(re,me)),Aw(me,fe),f({type:"UPDATE_INLINE_RESULT",evalId:re,result:{...me,assertions:[...me.assertions]}})},[]),v=x.useCallback(re=>{if(g.current.has(re))return;g.current.add(re);const fe=p.current.get(re)??{assertions:[]};f({type:"CASE_RUN_COMPLETE",caseId:re,result:{...fe,assertions:[...fe.assertions]}}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ee.getLatestBenchmark(t,r).then(me=>f({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,r]),j=x.useCallback((re,fe)=>{g.current.has(re)||(g.current.add(re),f({type:"CASE_RUN_ERROR",caseId:re,error:fe}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ee.getLatestBenchmark(t,r).then(me=>f({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,r]),{startCase:S,stopCase:k,stopAll:E}=Cw({onEvent:y,onDone:v,onError:j});x.useEffect(()=>()=>{E()},[E]);const w=x.useCallback(async()=>{try{const re=await fetch(`/api/skills/${t}/${r}/activation-history`);if(!re.ok){if(re.status===404){f({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const fe=await re.json();f({type:"ACTIVATION_HISTORY_LOADED",runs:fe.runs||[]})}catch{}},[t,r]);x.useEffect(()=>{let re=!1;async function fe(){try{const[me,he,be]=await Promise.allSettled([Ee.getSkillDetail(t,r),Ee.getEvals(t,r),Ee.getLatestBenchmark(t,r)]);if(re)return;let _e=null,De=null;if(he.status==="fulfilled")_e=he.value;else{const pt=he.reason;De=(pt==null?void 0:pt.message)??"Failed to load test cases"}f({type:"INIT_DATA",skillContent:me.status==="fulfilled"?me.value.skillContent:"",evals:_e,evalsError:De,benchmark:be.status==="fulfilled"?be.value:null})}catch(me){re||f({type:"SET_ERROR",error:me.message})}}return fe(),w(),()=>{re=!0}},[t,r,w]);const N=x.useCallback(async()=>{if(!c)try{await Ee.applyImprovement(t,r,u.skillContent),f({type:"CONTENT_SAVED"})}catch(re){f({type:"SET_ERROR",error:re.message})}},[c,t,r,u.skillContent]),A=x.useCallback(async re=>{if(!c)try{const fe=await Ee.saveEvals(t,r,re);f({type:"SET_EVALS",evals:fe})}catch(fe){f({type:"SET_ERROR",error:fe.message})}},[c,t,r]),D=x.useCallback((re,fe="benchmark")=>{if(c)return;const me=u.caseRunStates.get(re);if((me==null?void 0:me.status)!=="running")if(p.current.delete(re),g.current.delete(re),f({type:"CASE_RUN_START",caseId:re,mode:fe}),fe==="comparison"){const he=`/api/skills/${t}/${r}/compare`;S(re,he,{eval_ids:[re]})}else{const he=`/api/skills/${t}/${r}/benchmark/case/${re}`;S(re,he,fe==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.caseRunStates,S]),U=x.useCallback((re="benchmark")=>{var he;if(c)return;const fe=((he=u.evals)==null?void 0:he.evals)??[];if(fe.length===0)return;const me=fe.map(be=>be.id);for(const be of me)p.current.delete(be),g.current.delete(be);f({type:"BULK_RUN_START",caseIds:me,mode:re}),h.current=new Set(me);for(const be of me)if(re==="comparison")S(be,`/api/skills/${t}/${r}/compare`,{eval_ids:[be]});else{const _e=`/api/skills/${t}/${r}/benchmark/case/${be}`;S(be,_e,re==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.evals,S]),L=x.useCallback(re=>{k(re),f({type:"CASE_RUN_CANCEL",caseId:re}),h.current.delete(re),g.current.add(re)},[k]),F=x.useCallback(()=>{E(),f({type:"CANCEL_ALL"}),h.current.clear()},[E]),C=x.useCallback(async(re,fe)=>{f({type:"OPEN_IMPROVE",evalId:re})},[]),O=x.useCallback(async(re,fe)=>{try{await Ee.applyImprovement(t,r,fe),f({type:"SET_CONTENT",content:fe}),f({type:"CONTENT_SAVED"}),f({type:"CLOSE_IMPROVE"}),D(re,"benchmark")}catch(me){f({type:"SET_ERROR",error:me.message})}},[t,r,D]),T=Cd(),_=x.useRef(null),I=x.useRef(0);x.useEffect(()=>{const re=T.events;for(let fe=I.current;fe<re.length;fe++){const me=re[fe],he=me.data;if(me.event==="progress"&&f({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:he.phase,message:he.message}}),me.event==="done"){const be=he.improved,_e=he.reasoning,De=he.evalChanges??[];f({type:"AI_EDIT_RESULT",improved:be,reasoning:_e,evalChanges:De})}if(me.event==="error"){const be=he;f({type:"AI_EDIT_ERROR",message:be.description||"Unknown error",classified:be})}}I.current=re.length},[T.events]),x.useEffect(()=>{T.error&&f({type:"AI_EDIT_ERROR",message:T.error})},[T.error]),x.useEffect(()=>()=>{T.stop()},[T.stop]);const K=x.useCallback(async(re,fe,me)=>{c||(I.current=0,f({type:"AI_EDIT_LOADING"}),_.current=T.stop,T.start(`/api/skills/${t}/${r}/improve?sse`,{mode:"instruct",instruction:re,content:u.skillContent,evals:u.evals??{skill_name:r,evals:[]},provider:fe,model:me}))},[c,t,r,u.skillContent,u.evals,T]),Q=x.useCallback(()=>{T.stop(),f({type:"AI_EDIT_ERROR",message:"Cancelled"})},[T]),q=x.useCallback(async()=>{const re=u.aiEditResult;if(re!=null&&re.improved)try{if(await Ee.applyImprovement(t,r,re.improved),f({type:"SET_CONTENT",content:re.improved}),f({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:me}=await Io(async()=>{const{mergeEvalChanges:_e}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:_e}},[]),he=u.evals??{skill_name:r,evals:[]},be=me(he,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const _e=await Ee.saveEvals(t,r,be);f({type:"SET_EVALS",evals:_e})}catch(_e){f({type:"SET_EVALS_RETRY",evalsFile:be}),f({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${_e.message}. You can retry from the AI Edit panel.`});return}}f({type:"CLOSE_AI_EDIT"})}catch(fe){f({type:"SET_ERROR",error:fe.message})}},[t,r,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),H=x.useCallback(()=>{f({type:"CLOSE_AI_EDIT"})},[]),M=x.useCallback(re=>{f({type:"TOGGLE_EVAL_CHANGE",index:re})},[]),B=x.useCallback(()=>{f({type:"SELECT_ALL_EVAL_CHANGES"})},[]),V=x.useCallback(()=>{f({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),W=x.useCallback(async()=>{const re=u.aiEditEvalsRetry;if(re)try{const fe=await Ee.saveEvals(t,r,re);f({type:"SET_EVALS",evals:fe}),f({type:"SET_ERROR",error:null}),f({type:"CLOSE_AI_EDIT"})}catch(fe){f({type:"SET_ERROR",error:`Retry failed: ${fe.message}`})}},[t,r,u.aiEditEvalsRetry]),de=x.useCallback(async()=>{try{const re=await Ee.getSkillDetail(t,r);f({type:"SET_CONTENT",content:re.skillContent}),f({type:"CONTENT_SAVED"})}catch{}},[t,r]),{config:z}=_r(),P=Cd(),te=x.useRef(0);x.useEffect(()=>{const re=P.events;for(let fe=te.current;fe<re.length;fe++){const me=re[fe],he=me.data;if(me.event==="progress"&&f({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:he.phase,message:he.message}}),me.event==="done"){const be=he;Ee.saveEvals(t,r,be).then(_e=>f({type:"GENERATE_EVALS_DONE",evals:_e})).catch(_e=>f({type:"SET_ERROR",error:_e.message}))}me.event==="error"&&f({type:"GENERATE_EVALS_ERROR",classified:he})}te.current=re.length},[P.events,t,r]),x.useEffect(()=>{P.error&&f({type:"SET_ERROR",error:P.error})},[P.error]),x.useEffect(()=>()=>{P.stop()},[P.stop]);const le=x.useCallback(async re=>{if(c)return;te.current=0,f({type:"GENERATE_EVALS_START"});const fe={};z!=null&&z.provider&&(fe.provider=z.provider),z!=null&&z.model&&(fe.model=z.model);const me=Rw(re==null?void 0:re.testType);me&&(fe.testType=me),P.start(`/api/skills/${t}/${r}/generate-evals?sse`,Object.keys(fe).length>0?fe:void 0)},[c,t,r,P,z]),xe=Cd(),ce=x.useRef(0);x.useEffect(()=>()=>{xe.stop()},[xe.stop]),x.useEffect(()=>{const re=xe.events;for(let fe=ce.current;fe<re.length;fe++){const me=re[fe];if(me.event==="classifying"){const he=me.data;f({type:"ACTIVATION_CLASSIFYING",index:he.index,total:he.total})}if(me.event==="prompt_result"&&f({type:"ACTIVATION_RESULT",result:me.data}),me.event==="done"){ve.current&&(clearTimeout(ve.current),ve.current=null);const he=me.data;if(he.error)f({type:"ACTIVATION_ERROR",error:he.error});else{f({type:"ACTIVATION_DONE",summary:he});const be={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(z==null?void 0:z.model)||"unknown",provider:(z==null?void 0:z.provider)||"unknown",promptCount:he.total,summary:{precision:he.precision,recall:he.recall,reliability:he.reliability,tp:he.tp,tn:he.tn,fp:he.fp,fn:he.fn}};f({type:"ACTIVATION_HISTORY_LOADED",runs:[be,...u.activationHistory??[]]})}}}ce.current=re.length},[xe.events,z,u.activationHistory]),x.useEffect(()=>{xe.error&&(ve.current&&(clearTimeout(ve.current),ve.current=null),f({type:"ACTIVATION_ERROR",error:xe.error}))},[xe.error]);const ve=x.useRef(null),ue=x.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),xe.stop(),f({type:"ACTIVATION_CANCEL",totalPrompts:0})},[xe]),ye=x.useCallback(re=>{const me=re.trim().split(`
69
+ `).filter(Boolean).map(be=>be.startsWith("!")?{prompt:be.slice(1).trim(),expected:"should_not_activate"}:be.startsWith("+")?{prompt:be.slice(1).trim(),expected:"should_activate"}:{prompt:be.trim(),expected:"auto"});ce.current=0,f({type:"ACTIVATION_START"}),f({type:"SET_ACTIVATION_PROMPTS",prompts:re});const he={prompts:me};z!=null&&z.provider&&(he.provider=z.provider),z!=null&&z.model&&(he.model=z.model),xe.start(`/api/skills/${t}/${r}/activation-test`,he),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{xe.stop(),f({type:"ACTIVATION_TIMEOUT"}),ve.current=null},12e4)},[t,r,xe,z]),Ne=x.useCallback(async(re=8)=>{f({type:"GENERATE_PROMPTS_START"});try{const fe={count:re};z!=null&&z.provider&&(fe.provider=z.provider),z!=null&&z.model&&(fe.model=z.model);const me=await fetch(`/api/skills/${t}/${r}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(fe)});if(!me.ok){let mt=`HTTP ${me.status}`;try{const Jt=await me.json();Jt.error&&(mt=Jt.error)}catch{}throw new Error(mt)}const he=me.body.getReader(),be=new TextDecoder;let _e="",De="",pt=[];for(;;){const{done:mt,value:Jt}=await he.read();if(mt)break;_e+=be.decode(Jt,{stream:!0});const ht=_e.split(`
70
+ `);_e=ht.pop()||"";for(const Qe of ht)if(Qe.startsWith("event: "))De=Qe.slice(7).trim();else if(Qe.startsWith("data: ")){try{const xt=JSON.parse(Qe.slice(6));if(De==="done"){if(xt.error)throw new Error(xt.error);pt=xt.prompts||[]}if(De==="error")throw new Error(xt.message||xt.description||"Generation failed")}catch(xt){if(!(xt instanceof SyntaxError))throw xt}De=""}}const _t=pt.map(mt=>`${mt.expected==="should_activate"?"+":"!"}${mt.prompt}`).join(`
71
+ `);f({type:"SET_ACTIVATION_PROMPTS",prompts:_t}),f({type:"GENERATE_PROMPTS_DONE"})}catch(fe){f({type:"GENERATE_PROMPTS_ERROR",error:fe.message})}},[t,r,z]),Me=x.useMemo(()=>({state:u,dispatch:f,isReadOnly:c,saveContent:N,saveEvals:A,runCase:D,runAll:U,cancelCase:L,cancelAll:F,improveForCase:C,applyImproveAndRerun:O,refreshSkillContent:de,generateEvals:le,runActivationTest:ye,cancelActivation:ue,generateActivationPrompts:Ne,fetchActivationHistory:w,submitAiEdit:K,cancelAiEdit:Q,applyAiEdit:q,discardAiEdit:H,toggleEvalChange:M,selectAllEvalChanges:B,deselectAllEvalChanges:V,retryEvalsSave:W}),[u,c,N,A,D,U,L,F,C,O,de,le,ye,ue,Ne,w,K,Q,q,H,M,B,V,W]);return a.jsx(py.Provider,{value:Me,children:o})}function Lw(t){if(!t)return[];const r=t.split(`
72
+ `),s=[];for(const o of r)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function Rf({contentDiff:t,fromLabel:r,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:f="inline",onRetry:h}){const[g,p]=x.useState(u),[y,v]=x.useState("unified"),j=x.useRef(null),S=x.useRef(null),k=x.useMemo(()=>Lw(t),[t]),E=x.useMemo(()=>{const L=k.filter(C=>C.type==="add").length,F=k.filter(C=>C.type==="remove").length;return{added:L,removed:F}},[k]),w=x.useMemo(()=>{let L=0,F=0;return k.filter(C=>C.type!=="header").map(C=>C.type==="remove"?(L++,{...C,origNum:L,newNum:null}):C.type==="add"?(F++,{...C,origNum:null,newNum:F}):(L++,F++,{...C,origNum:L,newNum:F}))},[k]),N=x.useMemo(()=>{const L=[],F=[];for(const C of w)if(C.type==="remove")L.push(C);else if(C.type==="add")F.push(C);else{for(;L.length<F.length;)L.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<L.length;)F.push({type:"context",content:"",origNum:null,newNum:null});L.push(C),F.push(C)}for(;L.length<F.length;)L.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<L.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:L,right:F}},[w]),A=x.useCallback(L=>{const F=L==="left"?j.current:S.current,C=L==="left"?S.current:j.current;F&&C&&(C.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return a.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&a.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const D=f==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",U=a.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[r," → ",s]}),a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",E.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",E.removed]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&a.jsx("button",{onClick:()=>p(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&a.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:w.map((L,F)=>a.jsxs("tr",{style:{background:L.type==="add"?"rgba(34,197,94,0.08)":L.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color: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??""}),a.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??""}),a.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"?"-":" "}),a.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||"​"})]},F))})})}):a.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{ref:j,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>A("left"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.left.map((L,F)=>a.jsxs("tr",{style:{background:L.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:L.origNum??""}),a.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||"​"})]},F))})})}),a.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>A("right"),children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:N.right.map((L,F)=>a.jsxs("tr",{style:{background:L.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:L.newNum??""}),a.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||"​"})]},F))})})})]}))]});return f==="modal"?a.jsx("div",{className:D,children:a.jsx("div",{style:{width:"80%",maxWidth:900},children:U})}):U}const Ng={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 zw(t,r){return t?t.length>r?t.slice(0,r)+"…":t:""}function Dw(){const{state:t}=Nn(),{plugin:r,skill:s}=t,{refreshSkills:o,updateCount:c}=Kn(),u=`versions/${r}/${s}`,f=x.useCallback(()=>Ee.getSkillVersions(r,s),[r,s]),{data:h,loading:g}=Ml(u,f),[p,y]=x.useState(null),[v,j]=x.useState(null),[S,k]=x.useState(null),[E,w]=x.useState(!1),[N,A]=x.useState("idle"),[D,U]=x.useState(null),L=x.useRef(null),F=x.useRef(null),C=x.useMemo(()=>(h==null?void 0:h.find(q=>q.isInstalled))??null,[h]),O=x.useMemo(()=>(h==null?void 0:h[0])??null,[h]),T=C&&O&&C.version!==O.version,_=x.useCallback(q=>{p?!v&&q!==p?j(q):(y(q),j(null),k(null)):(y(q),k(null))},[p,v]),I=x.useCallback(async(q,H)=>{w(!0);try{const M=await Ee.getVersionDiff(r,s,q,H);k(M)}catch{k(null)}finally{w(!1)}},[r,s]);x.useEffect(()=>{if(p&&v){const q=h||[],H=q.findIndex(W=>W.version===p),M=q.findIndex(W=>W.version===v),[B,V]=H>M?[p,v]:[v,p];I(B,V)}},[p,v,h,I]);const K=x.useCallback(()=>{!C||!O||(y(C.version),j(O.version))},[C,O]),Q=x.useCallback(()=>{A("updating"),U(null);const q=Ee.startSkillUpdate(r,s);L.current=q,q.addEventListener("progress",H=>{try{switch(JSON.parse(H.data).status){case"scanning":A("scanning");break;case"installing":A("installing");break;case"done":A("done");break}}catch{A("error"),U("Unexpected response from server")}}),q.addEventListener("done",()=>{q.close(),L.current=null,o(),sn(u),A("done")}),q.addEventListener("error",H=>{const M=H;let B="Connection lost";if(M.data)try{B=JSON.parse(M.data).error||"Update failed"}catch{}A("error"),U(B),q.close(),L.current=null})},[r,s,u,o]);return x.useEffect(()=>()=>{L.current&&(L.current.close(),L.current=null)},[]),g?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"}),a.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]}):!h||h.length===0?a.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16",children:a.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})}):a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),a.jsxs("div",{className:"flex items-center gap-2",children:[T&&a.jsx("button",{onClick:K,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),T&&N!=="done"&&(N==="error"?a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:D||"Update failed"}),a.jsx("button",{onClick:Q,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):a.jsx("button",{onClick:Q,disabled:N!=="idle",className:"btn btn-primary text-[11px]",children:N==="idle"?`Update to ${O==null?void 0:O.version}`:N==="updating"?"Starting update...":N==="scanning"?"Scanning...":"Installing..."})),c>1&&a.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",c,")"]})]})]}),p&&!v&&a.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",p]}),a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),a.jsx("div",{className:"space-y-1",children:h.map(q=>{const H=Ng[q.certTier]||Ng.COMMUNITY,M=q.version===p||q.version===v,B=q.isInstalled;return a.jsxs("button",{onClick:()=>_(q.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:V=>{M||(V.currentTarget.style.background="var(--surface-1)")},onMouseLeave:V=>{M||(V.currentTarget.style.background="transparent")},children:[a.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:B?10:8,height:B?10:8,background:B?"var(--accent)":"var(--surface-3)",border:B?"2px solid var(--accent)":"2px solid var(--border-default)"}}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:q.version}),a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:H.bg,color:H.text},children:q.certTier}),B&&a.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(q.createdAt).toLocaleDateString()})]}),q.diffSummary&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:zw(q.diffSummary,80)})]},q.version)})}),a.jsx("div",{ref:F,style:{height:1}})]}),E&&a.jsx("div",{className:"mt-4",children:a.jsx("div",{className:"skeleton h-48 rounded-xl"})}),S&&!E&&a.jsx("div",{className:"mt-4",children:a.jsx(Rf,{contentDiff:S.contentDiff,fromLabel:S.from,toLabel:S.to,diffSummary:S.diffSummary,renderContext:"inline",onRetry:()=>p&&v&&I(S.from,S.to)})})]})}function _w(t){const r=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!r)return{metadata:{},body:t};const s=r[1],o=r[2].trim(),c={},u=s.split(`
73
+ `);let f="",h=!1;for(const g of u){const p=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(p&&f&&h){const j=p[1],S=p[2].trim();let k=c[f];if((typeof k!="object"||Array.isArray(k))&&(k={},c[f]=k),!S)k[j]=[];else{const E=S.match(/^\[(.+)\]$/);E?k[j]=E[1].split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[j]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&f){h=!1;const j=c[f];Array.isArray(j)?j.push(y[1].trim().replace(/^["']|["']$/g,"")):c[f]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){f=v[1];const j=v[2].trim();if(h=!1,!j){c[f]={},h=!0;continue}const S=j.match(/^\[(.+)\]$/);if(S){c[f]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[f]=j.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Fo(t){if(!t)return"";try{let r=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=Ow(r);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function Ow(t){const r=t.split(`
74
+ `),s=[];let o=0;for(;o<r.length;)if(r[o].trim().startsWith("|")&&o+1<r.length&&r[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(r[o+1])){const c=Tg(r[o]);o+=2;const u=[];for(;o<r.length&&r[o].trim().startsWith("|");)u.push(Tg(r[o])),o++;const f='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const p of c)g+=`<th ${f}>${p}</th>`;g+="</tr></thead><tbody>";for(const p of u){g+="<tr>";for(const y of p)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(r[o]),o++;return s.join(`
75
+ `)}function Tg(t){return t.split("|").map(r=>r.trim()).filter(r=>r.length>0)}function Go(t,r){const s=t.split(`
76
+ `),o=r.split(`
77
+ `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,f=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?f[y][v]=f[y-1][v-1]+1:f[y][v]=Math.max(f[y-1][v],f[y][v-1]);const h=[];let g=c,p=u;for(;g>0||p>0;)g>0&&p>0&&s[g-1]===o[p-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,p--):p>0&&(g===0||f[g][p-1]>=f[g-1][p])?(h.push({type:"added",content:o[p-1]}),p--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function Bw(t,r){if(r&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return a.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return a.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function Xs({entries:t,isRunning:r}){const[s,o]=x.useState(!1),c=x.useRef(null);return x.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!r?null:a.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[a.jsxs("span",{className:"flex items-center gap-2",children:[r&&a.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&a.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,f)=>{const h=f===t.length-1&&r,g=f===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return a.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[Bw(u.phase,h),a.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),a.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&a.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},f)})})]})}const Rg={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 Wo({error:t,onRetry:r,onDismiss:s}){const[o,c]=x.useState(null),u=x.useRef(null);x.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),x.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const f=Rg[t.category]||Rg.unknown,h=o!=null&&o>0;return a.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${f.color} 30%, transparent)`,background:`color-mix(in srgb, ${f.color} 6%, var(--surface-1))`},children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{fontSize:14},children:f.icon}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:f.color},children:t.title})]}),s&&a.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-3.5 pb-3",children:[a.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),a.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(r||o!=null)&&a.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:r&&a.jsx("button",{onClick:r,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function Iw({plugin:t,skill:r,skillContent:s,onApplied:o}){const[c,u]=x.useState("closed"),{config:f}=_r(),[h,g]=x.useState("claude-cli"),[p,y]=x.useState("opus"),[v,j]=x.useState([]),[S,k]=x.useState(""),[E,w]=x.useState(""),[N,A]=x.useState(null),[D,U]=x.useState(null),[L,F]=x.useState([]),[C,O]=x.useState(!1),T=x.useRef(null);x.useEffect(()=>{if(!f)return;f.providers.find(B=>B.id==="claude-cli"&&B.available)&&(g("claude-cli"),y("opus"))},[f]),x.useEffect(()=>()=>{var M;(M=T.current)==null||M.abort()},[]);function _(){return f==null?void 0:f.providers.find(M=>M.id===h&&M.available)}const I=x.useCallback(()=>{var M;(M=T.current)==null||M.abort(),u("open")},[]);async function K(){u("loading"),A(null),U(null),F([]);const M=new AbortController;T.current=M;try{const B=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(r)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:p}),signal:M.signal});if(!B.ok||!B.body){let P=`HTTP ${B.status}`;try{const te=await B.json();te.error&&(P=te.error)}catch{}throw new Error(P)}const V=B.body.getReader(),W=new TextDecoder;let de="",z="";for(;;){const{done:P,value:te}=await V.read();if(P)break;de+=W.decode(te,{stream:!0});const le=de.split(`
78
+ `);de=le.pop()||"";for(const xe of le)if(xe.startsWith("event: "))z=xe.slice(7).trim();else if(xe.startsWith("data: ")){try{const ce=JSON.parse(xe.slice(6));z==="progress"?F(ve=>[...ve,{phase:ce.phase,message:ce.message,timestamp:Date.now()}]):z==="done"||z==="complete"?(k(ce.improved),w(ce.reasoning||""),j(Go(ce.original||s,ce.improved)),u("diff_shown")):z==="error"&&(A(ce.message||ce.description||"Unknown error"),ce.category&&U(ce),u("open"))}catch{}z=""}}}catch(B){B.name!=="AbortError"&&(A(B.message),u("open"))}finally{T.current=null}}async function Q(){O(!0);try{await Ee.applyImprovement(t,r,S),o(S),u("closed")}catch(M){A(M.message)}finally{O(!1)}}function q(){u("closed"),j([]),k(""),w(""),A(null)}if(c==="closed")return a.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const H=_();return a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),a.jsx("button",{onClick:q,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:M=>{M.currentTarget.style.background="var(--surface-3)"},onMouseLeave:M=>{M.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:M=>{g(M.target.value);const B=f==null?void 0:f.providers.find(V=>V.id===M.target.value);B!=null&&B.models[0]&&y(B.models[0].id)},disabled:c==="loading",children:f==null?void 0:f.providers.filter(M=>M.available).map(M=>a.jsx("option",{value:M.id,children:M.label},M.id))})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[12px] py-1.5",value:p,onChange:M=>y(M.target.value),disabled:c==="loading",children:H==null?void 0:H.models.map(M=>a.jsx("option",{value:M.id,children:M.label},M.id))})]}),c==="loading"?a.jsx("button",{onClick:I,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):a.jsx("button",{onClick:K,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&L.length>0&&a.jsx("div",{className:"mt-3",children:a.jsx(Xs,{entries:L,isRunning:!0})})]}),N&&a.jsx("div",{className:"mb-4",children:D?a.jsx(Wo,{error:D,onRetry:K,onDismiss:()=>{A(null),U(null)}}):a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&a.jsxs(a.Fragment,{children:[E&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),E]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((M,B)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:M.type==="added"?"rgba(34,197,94,0.1)":M.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:M.type==="added"?"var(--green)":M.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:M.type==="added"?"3px solid var(--green)":M.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:M.type==="added"?"+":M.type==="removed"?"-":" "}),M.content]},B))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:Q,disabled:C,className:"btn btn-primary",children:C?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),a.jsx("button",{onClick:q,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const Ag={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"}},Hw={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function Uw({change:t,index:r,selected:s,onToggle:o,originalEval:c}){var v;const[u,f]=x.useState(!1),h=Ag[t.action]??Ag.add,g=Hw[t.action]??"var(--border-subtle)",p=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=x.useCallback(()=>o(r),[o,r]);return a.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[a.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),a.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),a.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:p}),a.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),a.jsx("button",{onClick:()=>f(!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:j=>{j.currentTarget.style.background="var(--surface-3)"},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:u?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&a.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&a.jsx($w,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&a.jsx(Vw,{original:c,proposed:t.eval}),t.action==="remove"&&c&&a.jsx(Pw,{evalCase:c})]})]})}function $w({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[a.jsx(tf,{label:"Prompt",value:t.prompt}),a.jsx(tf,{label:"Expected",value:t.expected_output}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>a.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function Vw({original:t,proposed:r}){const s=[];t.name!==r.name&&s.push({label:"Name",old:t.name,new:r.name}),t.prompt!==r.prompt&&s.push({label:"Prompt",old:t.prompt,new:r.prompt}),t.expected_output!==r.expected_output&&s.push({label:"Expected",old:t.expected_output,new:r.expected_output});const o=t.assertions??[],c=r.assertions??[],u=new Set(o.map(p=>p.text)),f=new Set(c.map(p=>p.text)),h=c.filter(p=>!u.has(p.text)),g=o.filter(p=>!f.has(p.text));return a.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(p=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:p.label}),a.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[a.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",nf(p.old,120)]}),a.jsxs("div",{style:{color:"var(--green)"},children:["+ ",nf(p.new,120)]})]})]},p.label)),(h.length>0||g.length>0)&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),a.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(p=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",p.text]},p.id)),h.map(p=>a.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",p.text]},p.id))]})]}),s.length===0&&h.length===0&&g.length===0&&a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function Pw({evalCase:t}){var r;return a.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[a.jsx(tf,{label:"Prompt",value:t.prompt}),a.jsxs("div",{children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((r=t.assertions)==null?void 0:r.length)??0,")"]}),a.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>a.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function tf({label:t,value:r}){return a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a.jsx("div",{className:"mt-0.5 text-[11px] p-2 rounded font-mono",style:{background:"var(--surface-1)",color:"var(--text-secondary)",whiteSpace:"pre-wrap"},children:nf(r,300)})]})}function nf(t,r){return t.length>r?t.slice(0,r)+"...":t}const Mg={remove:0,modify:1,add:2};function Fw({changes:t,selections:r,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const f=t.map((g,p)=>({change:g,originalIndex:p}));f.sort((g,p)=>(Mg[g.change.action]??2)-(Mg[p.change.action]??2));const h=Array.from(r.values()).filter(Boolean).length;return a.jsxs("div",{className:"mt-3 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),a.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),a.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:f.map(({change:g,originalIndex:p})=>a.jsx(Uw,{change:g,index:p,selected:r.get(p)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},p))})]})}function Gw(){var M;const{state:t,dispatch:r,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:f,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:p}=Nn(),{aiEditLoading:y,aiEditResult:v,aiEditError:j,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:E,aiEditEvalSelections:w,aiEditEvalsRetry:N}=t,[A,D]=x.useState(""),{config:U}=_r(),[L,F]=x.useState("claude-cli"),[C,O]=x.useState("opus"),T=x.useRef(null);x.useEffect(()=>{var B;(B=T.current)==null||B.focus()},[]),x.useEffect(()=>{if(!U)return;U.providers.find(V=>V.id==="claude-cli"&&V.available)&&(F("claude-cli"),O("opus"))},[U]);const _=U==null?void 0:U.providers.find(B=>B.id===L&&B.available),I=x.useCallback(()=>{const B=A.trim();!B||y||s(B,L,C)},[A,y,s,L,C]),K=x.useCallback(B=>{B.key==="Enter"&&!B.shiftKey&&(B.preventDefault(),I()),B.key==="Escape"&&(B.preventDefault(),y?u():c())},[I,y,u,c]),Q=x.useCallback(()=>{r({type:"CLOSE_AI_EDIT"}),r({type:"OPEN_AI_EDIT"})},[r]),q=v?Go(t.skillContent,v.improved):[],H=((M=t.evals)==null?void 0:M.evals)??[];return a.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),a.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:B=>{B.currentTarget.style.background="var(--surface-3)"},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsxs("div",{className:"px-4 py-3",children:[!v&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{ref:T,value:A,onChange:B=>D(B.target.value),onKeyDown:K,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),a.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:L,onChange:B=>{F(B.target.value);const V=U==null?void 0:U.providers.find(W=>W.id===B.target.value);V!=null&&V.models[0]&&O(V.models[0].id)},disabled:y,style:{width:"100%"},children:U==null?void 0:U.providers.filter(B=>B.available).map(B=>a.jsx("option",{value:B.id,children:B.label},B.id))})]}),a.jsxs("div",{style:{minWidth:200},children:[a.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsx("select",{className:"input-field text-[11px] py-1",value:C,onChange:B=>O(B.target.value),disabled:y,style:{width:"100%"},children:_==null?void 0:_.models.map(B=>a.jsx("option",{value:B.id,children:B.label},B.id))})]}),a.jsx("div",{className:"flex-1"}),y?a.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):a.jsx("button",{onClick:I,disabled:!A.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&a.jsx("div",{className:"mt-2.5",children:a.jsx(Xs,{entries:k,isRunning:!0})})]}),j&&a.jsx("div",{className:"mt-3",children:S?a.jsx(Wo,{error:S,onRetry:Q,onDismiss:c}):a.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:j})}),v&&a.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&a.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),a.jsx("div",{className:"mb-1",children:a.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:q.map((B,V)=>a.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:B.type==="added"?"rgba(34,197,94,0.1)":B.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:B.type==="added"?"var(--green)":B.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:B.type==="added"?"3px solid var(--green)":B.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:B.type==="added"?"+":B.type==="removed"?"-":" "}),B.content]},V))}),a.jsx(Fw,{changes:E,selections:w,currentEvals:H,onToggle:f,onSelectAll:h,onDeselectAll:g}),N&&a.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[a.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),a.jsx("button",{onClick:p,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),a.jsx("button",{onClick:Q,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function Ww(t,r){const[s,o]=x.useState([]),[c,u]=x.useState("SKILL.md"),[f,h]=x.useState(null),[g,p]=x.useState(!1),[y,v]=x.useState(null),j=x.useCallback(async()=>{try{const E=await Ee.getSkillFiles(t,r);o(E.files)}catch{o([])}},[t,r]);x.useEffect(()=>{u("SKILL.md"),h(null),v(null),j()},[t,r,j]);const S=x.useCallback(async E=>{if(u(E),E==="SKILL.md"){h(null),v(null);return}p(!0),v(null);try{const w=await Ee.getSkillFile(t,r,E);h(w)}catch(w){v(`Unable to open file: ${w.message}`),h(null)}finally{p(!1)}},[t,r]),k=x.useCallback(()=>{j()},[j]);return{files:s,activeFile:c,secondaryContent:f,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function Yw(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qw(t){const r=[],s=new Map;for(const o of t){const c=o.path.split("/"),f={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,f)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&r.push(u)}else{const u=c.slice(0,-1).join("/"),f=s.get(u),h=s.get(o.path);f&&h&&f.children.push(h)}}return r}function my({expanded:t}){return a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function hy(){return a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function Kw(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Xw(){return a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"23 4 23 10 17 10"}),a.jsx("polyline",{points:"1 20 1 14 7 14"}),a.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function xy({node:t,depth:r,activeFile:s,onSelect:o}){const[c,u]=x.useState(!0),f=t.path===s;return t.type==="dir"?a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[a.jsx(my,{expanded:c}),a.jsx(hy,{}),a.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>a.jsx(xy,{node:h,depth:r+1,activeFile:s,onSelect:o},h.path))]}):a.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+r*14}px`,paddingTop:2,paddingBottom:2,background:f?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:f?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[a.jsx("span",{style:{width:10}}),a.jsx(Kw,{}),a.jsx("span",{style:{flex:1},children:t.name}),a.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:Yw(t.size)})]})}function Qw({files:t,activeFile:r,onSelect:s,onRefresh:o}){const[c,u]=x.useState(!1),f=x.useMemo(()=>qw(t),[t]);return a.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[a.jsx(my,{expanded:c}),a.jsx(hy,{}),a.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),a.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:a.jsx(Xw,{})})]}),c&&a.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:f.length===0?a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):f.map(h=>a.jsx(xy,{node:h,depth:0,activeFile:r,onSelect:s},h.path))})]})}function po(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Zw(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function Jw(t){const r=t.toLowerCase();return r.endsWith(".json")?"json":r.endsWith(".md")?"md":"other"}function Lg({content:t}){return a.jsx("textarea",{readOnly:!0,value:t,style:{flex:1,width:"100%",resize:"none",background:"var(--surface-1)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}})}function zg({content:t,fileType:r}){if(r==="json"){const s=Zw(t);return a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s})}return r==="md"?a.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 20px",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:13,lineHeight:1.6},dangerouslySetInnerHTML:{__html:Fo(t)}}):a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function Dg(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function eE({file:t,loading:r,error:s,viewMode:o,plugin:c,skill:u,onSaved:f,onDirtyChange:h}){const[g,p]=x.useState(o),[y,v]=x.useState(!1),[j,S]=x.useState(""),[k,E]=x.useState(!1),[w,N]=x.useState(null),A=o!==g?o:g;x.useEffect(()=>{h==null||h(y)},[y,h]);const D=x.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),U=x.useCallback(()=>{v(!1)},[]),L=x.useCallback(async()=>{if(!(!c||!u||!t)){E(!0);try{await Ee.saveSkillFile(c,u,t.path,j),N("Saved"),v(!1),f==null||f(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{E(!1)}}},[c,u,t,j,f]);if(x.useEffect(()=>{if(!y)return;const O=T=>{(T.ctrlKey||T.metaKey)&&T.key==="s"&&(T.preventDefault(),L())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[y,L]),r)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return a.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:a.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[a.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),a.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return a.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",po(t.size),") — cannot be displayed"]});const F=t.content??"",C=Jw(t.path);return a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&a.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",po(512*1024)," — ",po(t.size)," total"]}),a.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(C==="md"||C==="json")&&["raw","split","preview"].map(O=>a.jsx("button",{onClick:()=>p(O),style:{padding:"2px 8px",fontSize:11,background:A===O?"var(--accent-muted)":"none",color:A===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),a.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[po(t.size),c&&u&&!t.binary&&!y&&a.jsx("button",{onClick:D,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick: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"}),a.jsx("button",{onClick:U,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),w&&a.jsx("div",{style:{padding:"4px 12px",background:w.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:w.startsWith("Save failed")?"var(--red)":"var(--green)"},children:w}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?a.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[a.jsx("textarea",{value:j,onChange:O=>S(O.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),a.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),a.jsx("button",{onClick: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"}),a.jsx("button",{onClick:U,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):A==="split"&&C!=="other"?a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:a.jsx(Lg,{content:F})}),a.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:C==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Dg(F)}}):a.jsx(zg,{content:F,fileType:C})})]}):A==="preview"&&C!=="other"?C==="json"?a.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Dg(F)}}):a.jsx(zg,{content:F,fileType:C}):a.jsx(Lg,{content:F})})]})}function tE({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function nE({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),a.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function aE({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function rE({size:t=15}){return a.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M15 4V2"}),a.jsx("path",{d:"M15 16v-2"}),a.jsx("path",{d:"M8 9h2"}),a.jsx("path",{d:"M20 9h2"}),a.jsx("path",{d:"M17.8 11.8L19 13"}),a.jsx("path",{d:"M15 9h.01"}),a.jsx("path",{d:"M17.8 6.2L19 5"}),a.jsx("path",{d:"M11 6.2L9.7 5"}),a.jsx("path",{d:"M3 21l9-9"})]})}function Nd({size:t=15}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function lE(){const{state:t,dispatch:r,saveContent:s,isReadOnly:o}=Nn(),{plugin:c,skill:u,skillContent:f,isDirty:h,improveTarget:g,aiEditOpen:p}=t,[y,v]=x.useState("split"),[j,S]=x.useState(!1),k=x.useRef(null),[E,w]=x.useState(!1),[N,A]=x.useState(""),[D,U]=x.useState(!1),[L,F]=x.useState(null),[C,O]=x.useState([]),[T,_]=x.useState([]),[I,K]=x.useState(null),Q=x.useRef(null),{config:q}=_r(),{files:H,activeFile:M,secondaryContent:B,loading:V,error:W,selectFile:de,refresh:z,isSkillMd:P}=Ww(c??"",u??""),[te,le]=x.useState(!1),xe=x.useCallback(J=>{te&&!window.confirm("You have unsaved changes. Discard?")||de(J)},[te,de]);x.useEffect(()=>()=>{var J;(J=Q.current)==null||J.abort()},[]);const{metadata:ce,body:ve}=_w(f),ue=ce["allowed-tools"],ye=Array.isArray(ue)?ue:typeof ue=="string"?[ue]:[],Ne=ce.name,Me=ce.description,re=ce.metadata,fe=typeof re=="object"&&!Array.isArray(re)?re:null,me=ce.version||(fe==null?void 0:fe.version),he=ce.tags||(fe==null?void 0:fe.tags),be=Array.isArray(he)?he:typeof he=="string"?he.split(",").map(J=>J.trim()).filter(Boolean):[],_e=new Set(["name","description","metadata","allowed-tools","version","tags"]),De=Object.entries(ce).filter(([J])=>!_e.has(J)),pt=x.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),_t=x.useCallback(J=>{(J.ctrlKey||J.metaKey)&&J.key==="s"&&(J.preventDefault(),J.stopPropagation(),h&&pt()),(J.ctrlKey||J.metaKey)&&J.key==="k"&&(J.preventDefault(),J.stopPropagation(),r({type:p?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,pt,p,r]),mt=x.useCallback(async()=>{var Te,Pe;if(!N.trim())return;(Te=Q.current)==null||Te.abort();const J=new AbortController;Q.current=J,U(!0),K(null),_([]),F(null),O([]);try{const en=(q==null?void 0:q.provider)||"claude-cli",Xn=(q==null?void 0:q.model)||"sonnet",qt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:en,model:Xn}),signal:J.signal});if(!qt.ok||!qt.body){let dt=`HTTP ${qt.status}`;try{const sa=await qt.json();sa.error&&(dt=sa.error)}catch{}throw new Error(dt)}const dr=qt.body.getReader(),Fe=new TextDecoder;let nt="",wt="";for(;;){const{done:dt,value:sa}=await dr.read();if(dt)break;nt+=Fe.decode(sa,{stream:!0});const xn=nt.split(`
79
+ `);nt=xn.pop()||"";for(const Aa of xn)if(Aa.startsWith("event: "))wt=Aa.slice(7).trim();else if(Aa.startsWith("data: ")){try{const Rt=JSON.parse(Aa.slice(6));if(wt==="progress")_(Vt=>[...Vt,{phase:Rt.phase,message:Rt.message,timestamp:Date.now()}]);else if(wt==="done"||wt==="complete"){const Vt=["---"];Rt.name&&Vt.push(`name: ${Rt.name}`),Rt.description&&Vt.push(`description: "${Rt.description.replace(/"/g,'\\"')}"`),Rt.model&&Vt.push(`model: ${Rt.model}`),(Pe=Rt.allowedTools)!=null&&Pe.trim()&&Vt.push(`allowed-tools: ${Rt.allowedTools.trim()}`),Vt.push("---","",Rt.body||"");const tn=Vt.join(`
80
+ `);F(tn),O(Go(f,tn)),U(!1)}else wt==="error"&&(K(Rt.message||Rt.description||"Generation failed"),U(!1))}catch{}wt=""}}}catch(en){en.name!=="AbortError"&&K(en.message)}finally{U(!1),Q.current=null}},[N,q,f]),Jt=x.useCallback(()=>{L&&r({type:"SET_CONTENT",content:L}),w(!1),F(null),O([]),A(""),_([])},[L,r]),ht=x.useCallback(()=>{w(!1),F(null),O([]),A(""),_([]),K(null)},[]),Qe=x.useCallback(()=>{var J;E?((J=Q.current)==null||J.abort(),ht()):(p&&r({type:"CLOSE_AI_EDIT"}),w(!0))},[E,p,r,ht]),xt=[{mode:"raw",icon:a.jsx(tE,{}),label:"Editor"},{mode:"split",icon:a.jsx(nE,{}),label:"Split"},{mode:"preview",icon:a.jsx(aE,{}),label:"Preview"}];return a.jsxs("div",{className:"flex flex-col h-full",onKeyDown:_t,tabIndex:-1,children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:xt.map(({mode:J,icon:Te,label:Pe})=>a.jsxs("button",{onClick:()=>v(J),title:Pe,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===J?"var(--surface-4)":"transparent",color:y===J?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===J?600:400,border:"none",cursor:"pointer"},children:[Te,a.jsx("span",{style:{letterSpacing:"0.01em"},children:Pe})]},J))}),P?o?a.jsx("div",{className:"flex items-center gap-2",children:a.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>{p?r({type:"CLOSE_AI_EDIT"}):(E&&ht(),r({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:p?600:400,border:"none",cursor:"pointer",color:p?"var(--purple)":"var(--text-tertiary)",background:p?"var(--purple-muted)":"transparent"},children:[a.jsx(rE,{size:13}),a.jsx("span",{children:"AI Edit"})]}),a.jsxs("button",{onClick:Qe,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:E?600:400,border:"none",cursor:"pointer",color:E?"var(--purple)":"var(--text-tertiary)",background:E?"var(--purple-muted)":"transparent"},children:[a.jsx(Nd,{size:13}),a.jsx("span",{children:"Regenerate"})]}),a.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&a.jsx("button",{onClick:()=>r({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),a.jsx("button",{onClick:pt,disabled:!h||j,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:j?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&a.jsx(Qw,{files:H,activeFile:M,onSelect:xe,onRefresh:z}),!P&&a.jsx(eE,{file:B,loading:V,error:W,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{de(M),z()},onDirtyChange:le}),P&&a.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&a.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:a.jsx("textarea",{ref:k,value:f,onChange:J=>{o||r({type:"SET_CONTENT",content:J.target.value})},onKeyDown:_t,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&a.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:a.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Ne||me||Me)&&a.jsxs("div",{style:{marginBottom:20},children:[a.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Ne&&a.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Ne}),me&&a.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",me]})]}),Me&&a.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:Me})]}),be.length>0&&a.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:be.map(J=>a.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:J},J))}),ye.length>0&&a.jsx("div",{style:{marginBottom:16},children:a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),ye.map(J=>a.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:J},J))]})}),De.length>0&&a.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:De.map(([J,Te],Pe)=>{const en=Array.isArray(Te)?Te.join(", "):typeof Te=="object"?Object.entries(Te).map(([Xn,qt])=>`${Xn}: ${Array.isArray(qt)?qt.join(", "):qt}`).join(" | "):Te;return a.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Pe>0?"1px solid var(--border-subtle)":"none"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:J}),a.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:en})]},J)})}),(Ne||Me||be.length>0||ye.length>0||De.length>0)&&ve&&a.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ve&&a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Fo(ve)}})]})})]}),P&&p&&a.jsx(Gw,{}),P&&E&&a.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:a.jsxs("div",{className:"px-4 py-3",children:[!L&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Nd,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),a.jsx("div",{className:"flex gap-2 mb-2",children:a.jsx("textarea",{value:N,onChange:J=>A(J.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:D,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:D?.5:1},onKeyDown:J=>{J.key==="Enter"&&(J.ctrlKey||J.metaKey)&&N.trim()&&!D&&(J.preventDefault(),mt())}})}),a.jsxs("div",{className:"flex items-center gap-2",children:[D?a.jsx("button",{onClick:()=>{var J;(J=Q.current)==null||J.abort(),U(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):a.jsx("button",{onClick:mt,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),a.jsx("button",{onClick:ht,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),D&&T.length>0&&a.jsx("div",{className:"mt-2",children:a.jsx(Xs,{entries:T,isRunning:!0})}),I&&a.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[I,a.jsx("button",{onClick:mt,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),L&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsx(Nd,{size:14}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),a.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:C.map((J,Te)=>a.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:J.type==="added"?"var(--green-muted)":J.type==="removed"?"var(--red-muted)":"transparent",color:J.type==="added"?"var(--green)":J.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:J.type==="added"?"3px solid var(--green)":J.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[a.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:J.type==="added"?"+":J.type==="removed"?"-":" "}),J.content]},Te))}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:Jt,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),a.jsx("button",{onClick:ht,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),P&&g!==null&&c&&u&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(Iw,{plugin:c,skill:u,skillContent:f,onApplied:J=>{r({type:"SET_CONTENT",content:J}),r({type:"CONTENT_SAVED"}),r({type:"CLOSE_IMPROVE"})}})})]})}function kl(t){return t.testType==="integration"?"integration":"unit"}function Tl(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function gy(t){const r=new Date(t);return r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function vy(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const sE=new Set(["benchmark","comparison","baseline"]);function _g(t,r,s,o){return t.map(({rate:c,idx:u,total:f})=>{const h=o+u/(f-1)*(r-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function yy({entries:t}){const r=t.filter(v=>sE.has(v.type)).slice().reverse(),s=r.map((v,j,S)=>({rate:v.pass_rate,idx:j,total:S.length})).filter((v,j)=>{const S=r[j].type;return S==="benchmark"||S==="comparison"}),o=r.flatMap((v,j)=>v.type==="baseline"?[{rate:v.pass_rate,idx:j,total:r.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:j,total:r.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,f=2,h=s.length>=2?_g(s,c,u,f):[],g=o.length>=2?_g(o,c,u,f):[],p=h[h.length-1],y=g[g.length-1];return a.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&a.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&a.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&a.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),p&&a.jsx("circle",{cx:parseFloat(p.split(",")[0]),cy:parseFloat(p.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function by(t,r,s){const o=isNaN(r)?0:r,c=[],u=[],f=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const p=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${p}`}}if(t==="FAIL"||t==="DEGRADING"){const p=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...f.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${p}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const p=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...f.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:p}}if(t==="MARGINAL"){const p=[...f.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:p}}if(t==="EMERGING"){const p=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...f.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return p.length===0&&p.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:p}}const h=c.length>0?` Passing: ${c.map(p=>p.criterion).join(", ")}.`:"",g=f.length>0?` Needs improvement: ${f.map(p=>p.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const jy={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function iE(t){return Object.hasOwn(jy,t)}function oE(t){return iE(t)?jy[t]:t}function cE(){const{state:t}=Nn(),{plugin:r,skill:s}=t,[o,c]=x.useState([]),[u,f]=x.useState([]),[h,g]=x.useState(!0),[p,y]=x.useState(null),[v,j]=x.useState(new Set),[S,k]=x.useState({}),[E,w]=x.useState(null),[N,A]=x.useState(""),[D,U]=x.useState(!1),[L,F]=x.useState(""),[C,O]=x.useState(""),T=x.useCallback(async()=>{g(!0),y(null);try{const[H,M]=await Promise.all([Ee.getCredentials(r,s),Ee.getParams(r,s)]);c(H.credentials),f(M.params)}catch(H){y(H instanceof Error?H.message:"Failed to load parameters"),c([]),f([])}finally{g(!1)}},[r,s]);x.useEffect(()=>{T()},[T]);const _=x.useCallback(async(H,M)=>{U(!0),y(null);try{await Ee.setCredential(r,s,H,M),w(null),A(""),await T()}catch(B){y(B instanceof Error?B.message:`Failed to save ${H}`)}finally{U(!1)}},[r,s,T]),I=x.useCallback(async()=>{const H=L.trim().toUpperCase(),M=C.trim();if(!(!H||!M)){U(!0),y(null);try{await Ee.setCredential(r,s,H,M),F(""),O(""),await T()}catch(B){y(B instanceof Error?B.message:`Failed to add ${H}`)}finally{U(!1)}}},[r,s,L,C,T]),K=x.useCallback(async H=>{if(v.has(H)){j(M=>{const B=new Set(M);return B.delete(H),B}),k(M=>{const B={...M};return delete B[H],B});return}try{const B=(await Ee.getParamsRevealed(r,s,H)).params.find(V=>V.name===H);B!=null&&B.value&&(k(V=>({...V,[H]:B.value})),j(V=>new Set(V).add(H)))}catch{}},[r,s,v]),Q=new Set(o.map(H=>H.name)),q=[...o.map(H=>{const M=u.find(B=>B.name===H.name);return{name:H.name,status:H.status,maskedValue:(M==null?void 0:M.maskedValue)??""}}),...u.filter(H=>!Q.has(H.name)).map(H=>({name:H.name,status:H.status,maskedValue:H.maskedValue}))];return a.jsxs("div",{className:"py-2 px-3",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),p&&a.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:p}),h&&q.length===0&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&q.length===0&&!p&&a.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),q.map(H=>a.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:H.name}),a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:H.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:H.status==="ready"?"var(--green)":"var(--red)"},children:H.status}),(H.maskedValue||H.status==="ready")&&a.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has(H.name)?S[H.name]??H.maskedValue:H.maskedValue||"***",a.jsx("button",{onClick:()=>K(H.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has(H.name)?"Hide":"Reveal"} value for ${H.name}`,children:v.has(H.name)?"hide":"show"})]}),E===H.name?a.jsxs("div",{className:"flex gap-1",children:[a.jsx("input",{value:N,onChange:M=>A(M.target.value),onKeyDown:M=>{M.key==="Enter"&&N.trim()&&_(H.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${H.name}`,autoFocus:!0}),a.jsx("button",{onClick:()=>_(H.name,N),disabled:D||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),a.jsx("button",{onClick:()=>{w(null),A("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):a.jsx("button",{onClick:()=>{w(H.name),A("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},H.name)),a.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:L,onChange:H=>F(H.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),a.jsx("input",{value:C,onChange:H=>O(H.target.value),onKeyDown:H=>{H.key==="Enter"&&L.trim()&&C.trim()&&I()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),a.jsx("button",{onClick:I,disabled:D||!L.trim()||!C.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:D?"not-allowed":"pointer"},children:"Add"})]})]})]})}function uE(t,r,s){const[o,c]=x.useState(null),[u,f]=x.useState(!1),h=x.useRef("");x.useEffect(()=>{const p=`${t}/${r}/${s}`;h.current!==p&&(h.current=p,f(!0),Ee.getCaseHistory(t,r,s).then(y=>c(y)).catch(()=>c([])).finally(()=>f(!1)))},[t,r,s]);const g=x.useCallback(()=>{f(!0),h.current="",Ee.getCaseHistory(t,r,s).then(p=>c(p)).catch(()=>c([])).finally(()=>f(!1))},[t,r,s]);return{entries:o,loading:u,refetch:g}}function dE(t,r,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(p=>p.id===t)).filter(Boolean);if(u.length>=2){const p=u.filter(y=>y.pass).length/u.length;p>=.3&&p<=.7&&(o.flaky=!0)}const f=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(f&&h){const g=f.assertions.find(y=>y.id===t),p=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(p!=null&&p.pass)&&(o.nonDiscriminating=!0)}if(r&&!r.pass&&s.length>=1){const p=s[0].assertions.find(y=>y.id===t);p!=null&&p.pass&&(o.regression=!0)}return o}function fE(){var V;const{state:t,dispatch:r,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:f,generateEvals:h,isReadOnly:g}=Nn(),{evals:p,evalsError:y,selectedCaseId:v,inlineResults:j,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:E,generateEvalsError:w}=t,N=x.useMemo(()=>{for(const W of S.values())if(W.status==="running"||W.status==="queued")return!0;return!1},[S]),[A,D]=x.useState(!1),[U,L]=x.useState("all"),F={skill_name:t.skill,evals:[]},C=p??F,O=C.evals,T=x.useMemo(()=>U==="all"?O:O.filter(W=>kl(W)===U),[U,O]),_=T.find(W=>W.id===v)??null;x.useEffect(()=>{v!==null&&!T.find(W=>W.id===v)&&r({type:"SELECT_CASE",caseId:T.length>0?T[0].id:null})},[T,v,r]);const[I,K]=x.useState([]),Q=x.useMemo(()=>O.some(W=>kl(W)==="integration"),[O]);x.useEffect(()=>{Q&&Ee.getCredentials(t.plugin,t.skill).then(W=>K(W.credentials)).catch(()=>K([]))},[t.plugin,t.skill,Q]);const q=x.useMemo(()=>new Set(I.filter(W=>W.status==="missing").map(W=>W.name)),[I]),[H,M]=x.useState(!1),B=x.useCallback(W=>{M(!1),h(W?{testType:W}:void 0)},[h]);return!p||O.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M9 11l3 3L22 4"}),a.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),a.jsx("div",{className:"text-center",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),a.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),a.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>D(!0),disabled:g,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),a.jsxs("div",{style:{position:"relative"},children:[a.jsxs("div",{className:"flex",children:[a.jsx("button",{onClick:()=>B("unit"),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),a.jsx("button",{onClick:()=>M(!H),disabled:k||g,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),H&&a.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:a.jsx("button",{onClick:()=>B("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:W=>{W.currentTarget.style.background="var(--surface-2)"},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&E.length>0&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(Xs,{entries:E,isRunning:!0})}),w&&a.jsx("div",{className:"w-full max-w-md mt-3",children:a.jsx(Wo,{error:w,onRetry:()=>B()})}),A&&a.jsx(Og,{evals:C,onSave:W=>{s(W),D(!1)},onCancel:()=>D(!1)})]}):a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[a.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[a.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",T.length,")"]}),a.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?a.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"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>c("benchmark"),disabled:T.length===0||g,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),a.jsx("button",{onClick:()=>c("comparison"),disabled:T.length===0||g,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),a.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(W=>a.jsx("button",{onClick:()=>L(W),style:{padding:"2px 8px",fontSize:10,fontWeight:U===W?600:400,background:U===W?"var(--accent-muted)":"transparent",color:U===W?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:W==="all"?`All (${O.length})`:W==="unit"?`Unit (${O.filter(de=>kl(de)==="unit").length})`:`Integration (${O.filter(de=>kl(de)==="integration").length})`},W))}),a.jsxs("div",{className:"py-1",children:[T.length===0&&O.length>0&&a.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",U==="all"?"":U+" ","tests yet"]}),T.map(W=>{var te;const de=j.get(W.id),z=v===W.id,P=kl(W);return a.jsxs("button",{onClick:()=>r({type:"SELECT_CASE",caseId:W.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:z?"var(--accent-muted)":"transparent",borderLeft:z?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:le=>{z||(le.currentTarget.style.background="var(--surface-2)")},onMouseLeave:le=>{z||(le.currentTarget.style.background="transparent")},children:[a.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[a.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:z?"var(--text-primary)":"var(--text-secondary)"},children:["#",W.id," ",W.name,a.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:P==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:P==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:P==="unit"?"U":"I"}),P==="integration"&&((te=W.requiredCredentials)==null?void 0:te.some(le=>q.has(le)))&&a.jsx("span",{title:"Configure credentials to run",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),a.jsx(Sy,{result:de})]}),a.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[W.assertions.length," assertion",W.assertions.length!==1?"s":"",(de==null?void 0:de.passRate)!=null&&a.jsx(hE,{passRate:de.passRate})]})]},W.id)})]}),a.jsx("div",{className:"px-3 py-2",children:!g&&a.jsx("button",{onClick:()=>D(!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:W=>{W.currentTarget.style.borderColor="var(--accent)",W.currentTarget.style.color="var(--accent)"},onMouseLeave:W=>{W.currentTarget.style.borderColor="var(--border-default)",W.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:a.jsx(cE,{})})]}),a.jsx("div",{className:"overflow-auto",children:_?a.jsx(pE,{evalCase:_,result:j.get(_.id),evals:p,caseStatus:((V=S.get(_.id))==null?void 0:V.status)??"idle",onSaveEvals:s,onRun:W=>o(W,"benchmark"),onCompare:W=>o(W,"comparison"),onCancel:W=>u(W),onImprove:W=>r({type:"OPEN_IMPROVE",evalId:W})}):a.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),A&&a.jsx(Og,{evals:C,onSave:W=>{s(W),D(!1)},onCancel:()=>D(!1)})]})}function pE({evalCase:t,result:r,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:f,onCancel:h,onImprove:g}){const{state:p,isReadOnly:y}=Nn(),{plugin:v,skill:j}=p,{entries:S,loading:k}=uE(v,j,t.id),[E,w]=x.useState(!1),[N,A]=x.useState(t.prompt),[D,U]=x.useState(!1),[L,F]=x.useState(t.expected_output);x.useState(()=>{A(t.prompt),F(t.expected_output)});const C=x.useCallback(W=>{c({...s,evals:s.evals.map(de=>de.id===W.id?W:de)})},[s,c]),O=x.useCallback(()=>{C({...t,prompt:N}),w(!1)},[t,N,C]),T=x.useCallback(()=>{C({...t,expected_output:L}),U(!1)},[t,L,C]),_=x.useCallback(()=>{C({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,C]),I=x.useCallback((W,de)=>{C({...t,assertions:t.assertions.map(z=>z.id===W?{...z,text:de}:z)})},[t,C]),K=x.useCallback(W=>{C({...t,assertions:t.assertions.filter(de=>de.id!==W)})},[t,C]),Q=x.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(W=>W.id!==t.id)})},[s,t.id,c]),q=r&&r.assertions.length>0&&r.assertions.every(W=>W.pass),H=r&&r.assertions.some(W=>!W.pass),M=kl(t),B=t.requiredCredentials??[],V=M==="integration"&&B.length>0;return a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[a.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[a.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?a.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)"},children:M==="unit"?"Unit":"Integration"}):a.jsx("button",{onClick:()=>{if((M==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:de,requirements:z,cleanup:P,...te}=t;C({...te,testType:"unit"})}else C({...t,testType:"integration"})},title:`Click to switch to ${M==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:M==="unit"?"Unit":"Integration"}),a.jsx(Sy,{result:r})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?a.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),a.jsx("button",{onClick:()=>f(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),H&&!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&a.jsx("button",{onClick:Q,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),y&&M==="integration"&&a.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),a.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),a.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),q&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),V&&a.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:B.map(W=>a.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:W},W))})]}),!y&&M==="integration"&&a.jsx(vE,{evalCase:t,onUpdate:C}),a.jsx(mo,{title:"Prompt",children:E?a.jsxs("div",{children:[a.jsx("textarea",{value:N,onChange:W=>A(W.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{A(t.prompt),w(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||w(!0)},onMouseEnter:W=>{y||(W.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:W=>{W.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||a.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),a.jsx(mo,{title:"Expected Output",children:D?a.jsxs("div",{children:[a.jsx("textarea",{value:L,onChange:W=>F(W.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx("button",{onClick:T,className:"btn btn-primary text-[12px]",children:"Save"}),a.jsx("button",{onClick:()=>{F(t.expected_output),U(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):a.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||U(!0)},onMouseEnter:W=>{y||(W.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:W=>{W.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||a.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),a.jsx(mo,{title:`Assertions (${t.assertions.length})`,action:y?void 0:a.jsx("button",{onClick:_,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?a.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):a.jsx("div",{className:"space-y-2",children:t.assertions.map(W=>{const de=r==null?void 0:r.assertions.find(P=>P.assertion_id===W.id),z=dE(W.id,de,S);return a.jsx(mE,{assertion:W,result:de,badges:z,isReadOnly:y,onUpdate:P=>I(W.id,P),onDelete:()=>K(W.id)},W.id)})})}),(r==null?void 0:r.output)&&a.jsx(xE,{output:r.output,durationMs:r.durationMs,tokens:r.tokens}),r&&r.passRate!=null&&r.passRate<.2&&(()=>{const W=by("INEFFECTIVE",r.passRate);return W.recommendations&&W.recommendations.length>0?a.jsx(mo,{title:"Recommendations",children:a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),a.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),a.jsx("ul",{className:"space-y-1.5 ml-1",children:W.recommendations.map((de,z)=>a.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[a.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),de]},z))})]})}):null})(),a.jsx(gE,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function mE({assertion:t,result:r,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[f,h]=x.useState(!1),[g,p]=x.useState(t.text),[y,v]=x.useState(!1),j=()=>{c(g),h(!1)};return a.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsxs("div",{className:"flex items-start gap-2",children:[r?a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&a.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&a.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&a.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),f?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{value:g,onChange:S=>p(S.target.value),onKeyDown:S=>{S.key==="Enter"&&j(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),a.jsx("button",{onClick:j,className:"btn btn-primary text-[11px]",children:"Save"})]}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(p(t.text),h(!0))},children:t.text}),(r==null?void 0:r.reasoning)&&a.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(r==null?void 0:r.reasoning)&&a.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:r.reasoning})]}),!o&&a.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function mo({title:t,action:r,children:s}){return a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),r]}),s]})}function Sy({result:t}){const[r,s]=x.useState(!1);if(!t||t.status==null)return a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,f=by(o?"PASS":"FAIL",c);return a.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":r?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,r&&a.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:f.explanation})]})}function hE({passRate:t}){const r=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-1",children:a.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:a.jsx("div",{className:"h-full rounded-full",style:{width:`${r}%`,background:r>=80?"var(--green)":r>=50?"var(--yellow)":"var(--red)"}})})})}function xE({output:t,durationMs:r,tokens:s}){const[o,c]=x.useState(!1);return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",r!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",(r/1e3).toFixed(1),"s)"]}),s!=null&&a.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&a.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Td(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Rd({entry:t}){return a.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:gy(t.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:t.type==="benchmark"?"var(--accent-muted)":t.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:t.type==="benchmark"?"var(--accent)":t.type==="comparison"?"var(--purple)":"var(--orange)"},children:t.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Tl(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[t.durationMs!=null&&a.jsx("span",{children:vy(t.durationMs)}),t.tokens!=null&&a.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const r=t.pass_rate-t.baselinePassRate,s=r>.001?"skill":r<-.001?"baseline":"tie",o=r>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return a.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:r>=0?"var(--green)":"var(--red)"},children:[o,(r*100).toFixed(1),"%"]}),a.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),a.jsx("div",{className:"space-y-0.5",children:t.assertions.map(r=>a.jsxs("div",{className:"flex items-start gap-1.5",children:[a.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:r.pass?"var(--green-muted)":"var(--red-muted)"},children:r.pass?a.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:r.text})]},r.id))})]})}function gE({evalId:t,sharedEntries:r,sharedLoading:s}){const{state:o,dispatch:c}=Nn(),{plugin:u,skill:f}=o,[h,g]=x.useState(!0),p=r??null,y=s??!1,v=x.useCallback(()=>{g(E=>!E)},[]),j=p?p.slice(0,10):[],S=j.some(E=>{const w=Td(E.type);return w==="left"||w==="full"}),k=j.some(E=>{const w=Td(E.type);return w==="right"||w==="full"});return a.jsxs("div",{className:"mb-5",children:[a.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",p&&p.length>0&&a.jsxs("span",{style:{fontWeight:400},children:["(",p.length," run",p.length!==1?"s":"",")"]})]}),h&&a.jsx("div",{className:"animate-fade-in",children:y?a.jsxs("div",{className:"flex items-center gap-2 py-3",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!p||p.length===0?a.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):a.jsxs("div",{children:[j.length>=2&&a.jsx("div",{className:"mb-2",children:a.jsx(yy,{entries:j})}),a.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&a.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&a.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),j.map((E,w)=>{const N=Td(E.type);return N==="full"?a.jsx("div",{style:{gridColumn:"1 / -1"},children:a.jsx(Rd,{entry:E})},w):N==="left"?a.jsxs(x.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"},children:a.jsx(Rd,{entry:E})}),a.jsx("div",{style:{gridColumn:"2"}})]},w):a.jsxs(x.Fragment,{children:[a.jsx("div",{style:{gridColumn:"1"}}),a.jsx("div",{style:{gridColumn:"2"},children:a.jsx(Rd,{entry:E})})]},w)})]}),a.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:E=>{E.currentTarget.style.textDecoration="underline"},onMouseLeave:E=>{E.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function Og({evals:t,onSave:r,onCancel:s}){const[o,c]=x.useState(""),[u,f]=x.useState(""),[h,g]=x.useState(""),[p,y]=x.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,j]=x.useState("unit"),[S,k]=x.useState(""),[E,w]=x.useState([]),[N,A]=x.useState(""),[D,U]=x.useState(""),L=Math.max(0,...t.evals.map(T=>T.id))+1,F=T=>{j(T),T==="unit"&&(w([]),k(""),A(""),U(""))},C=()=>{const T=S.trim().toUpperCase();T&&!E.includes(T)&&w([...E,T]),k("")},O=()=>{if(!o.trim()||!u.trim())return;const T={id:L,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:p.filter(_=>_.text.trim()),...v==="integration"?{testType:"integration",...E.length>0?{requiredCredentials:E}:{},...N||D?{requirements:{...N?{platform:N}:{},...D?{chromeProfile:D}:{}}}:{}}:{}};r({...t,evals:[...t.evals,T]})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-overlay-in",style:{background:"rgba(0,0,0,0.6)"},children:a.jsxs("div",{className:"w-full max-w-lg rounded-xl p-6 animate-modal-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",maxHeight:"85vh",overflowY:"auto"},children:[a.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),a.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(T=>a.jsx("button",{onClick:()=>F(T),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===T?T==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===T?T==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:T},T))})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),a.jsx("input",{value:o,onChange:T=>c(T.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),a.jsx("textarea",{value:u,onChange:T=>f(T.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),a.jsx("textarea",{value:h,onChange:T=>g(T.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),a.jsxs("div",{className:"mb-4",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),p.map((T,_)=>a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:T.text,onChange:I=>y(p.map((K,Q)=>Q===_?{...K,text:I.target.value}:K)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),p.length>1&&a.jsx("button",{onClick:()=>y(p.filter((I,K)=>K!==_)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},T.id)),a.jsx("button",{onClick:()=>y([...p,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:E.map(T=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[T,a.jsx("button",{onClick:()=>w(E.filter(_=>_!==T)),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},T))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:S,onChange:T=>k(T.target.value),onKeyDown:T=>{T.key==="Enter"&&(T.preventDefault(),C())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),a.jsx("button",{onClick:C,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("label",{className:"block mb-3",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:N,onChange:T=>A(T.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("label",{className:"block",children:[a.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:D,onChange:T=>U(T.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function vE({evalCase:t,onUpdate:r}){var f,h;const[s,o]=x.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&r({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const p=(t.requiredCredentials??[]).filter(y=>y!==g);r({...t,requiredCredentials:p.length>0?p:void 0})};return a.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>a.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,a.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),a.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),a.jsxs("div",{className:"mb-2.5",children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),a.jsx("input",{value:((f=t.requirements)==null?void 0:f.platform)??"",onChange:g=>r({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),a.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>r({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Cn(t,r){return r==="free"?"Free":r==="subscription"&&t==null?"Subscription":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 ky(t,r){return t==null||r==null?"N/A":`${t.toLocaleString("en-US")} in / ${r.toLocaleString("en-US")} out`}function yE(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function bE(t,r){let s="";if(r){const c=new Date(r);isNaN(c.getTime())||(s=c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}))}return[t,s].filter(Boolean).join(" · ")}function jE(t,r,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*r);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function Bg(t,r){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(r)}}function SE(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function kE(t,r){const s=t+r,o=s*10,c=s*25,u=f=>f>=60?`${Math.round(f/60)}m`:`${f}s`;return`${u(o)}–${u(c)}`}const wE={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function EE(t,r){if(!t)return null;const s=wE[t];if(s==null||s===0)return null;const o=s*r*.5,c=s*r*2;return`${Cn(o)}–${Cn(c)}`}function CE(){const{state:t,runCase:r,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=Nn(),{evals:f,caseRunStates:h,bulkRunActive:g,latestBenchmark:p,inlineResults:y}=t,{config:v}=_r(),j=(f==null?void 0:f.evals)??[],S=x.useMemo(()=>{for(const C of h.values())if(C.status==="running"||C.status==="queued")return!0;return!1},[h]),k=j.filter(C=>{const O=h.get(C.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,E=j.filter(C=>{const O=h.get(C.id);return O&&(O.status==="running"||O.status==="queued")}).length,w=x.useRef(null),[N,A]=x.useState(0);x.useEffect(()=>{if(S&&!w.current&&(w.current=Date.now()),!S){w.current=null,A(0);return}const C=setInterval(()=>{w.current&&A(Math.round((Date.now()-w.current)/1e3))},1e3);return()=>clearInterval(C)},[S]);const D=j.reduce((C,O)=>C+O.assertions.length,0),U=j.length+D,L=x.useMemo(()=>kE(j.length,D),[j.length,D]),F=x.useMemo(()=>EE((v==null?void 0:v.provider)??null,U),[v==null?void 0:v.provider,U]);return a.jsxs("div",{className:"p-5",children:[u&&a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),a.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&a.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[E," running"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),a.jsx("button",{onClick:()=>s("comparison"),disabled:j.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),a.jsx("button",{onClick:()=>s("benchmark"),disabled:j.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),a.jsx("button",{onClick:()=>s("baseline"),disabled:j.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&j.length>0&&a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[a.jsxs("span",{children:["Est. duration: ",L]}),F&&a.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&a.jsx("span",{children:"Cost: Subscription"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&a.jsx("span",{children:"Cost: Free"})]})]}),S&&j.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",j.length," cases"]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/j.length*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/j.length*100}%`,background:"var(--accent)"}})}),a.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",L]})]})]}),a.jsx("div",{className:"space-y-3 stagger-children",children:j.map(C=>{const O=y.get(C.id),T=h.get(C.id),_=(T==null?void 0:T.status)??"idle",I=p==null?void 0:p.cases.find(K=>K.eval_id===C.id);return a.jsx(TE,{name:C.name,evalId:C.id,result:O,caseCost:I==null?void 0:I.cost,caseBillingMode:I==null?void 0:I.billingMode,caseInputTokens:I==null?void 0:I.inputTokens,caseOutputTokens:I==null?void 0:I.outputTokens,caseStatus:_,runMode:(T==null?void 0:T.mode)??null,comparisonDetail:I==null?void 0:I.comparisonDetail,isReadOnly:u,onRun:K=>r(K,"benchmark"),onBaseline:K=>r(K,"baseline"),onCompare:K=>r(K,"comparison"),onCancel:K=>o(K)},C.id)})}),!S&&p&&p.cases.length>0&&a.jsxs("div",{className:"mt-5",children:[a.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:yE(p.type)}),a.jsx("span",{className:"text-[20px] font-bold",style:{color:(p.overall_pass_rate??0)>=.8?"var(--green)":(p.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:p.overall_pass_rate!=null?`${Math.round(p.overall_pass_rate*100)}%`:"--"})]}),p.totalDurationMs!=null&&a.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(p.totalDurationMs/1e3).toFixed(1),"s",p.model&&` | Model: ${p.model}`,p.totalInputTokens!=null&&p.totalOutputTokens!=null&&` | Tokens: ${ky(p.totalInputTokens,p.totalOutputTokens)}`,p.totalCost!=null&&` | Cost: ${Cn(p.totalCost)}`]}),p.overall_pass_rate>=.9999&&!p.comparison&&a.jsx("button",{onClick:()=>s("comparison"),disabled:j.length===0||u,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:j.length===0?.5:1},children:"Run Final A/B Comparison"})]}),p.comparison&&a.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const C=bE(p.model,p.timestamp);return C?a.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:C}):a.jsx("div",{className:"mb-3"})})(),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ig,{label:"Skill",value:p.comparison.skillPassRate,color:"var(--accent)"}),a.jsx(Ig,{label:"Baseline",value:p.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),a.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:p.comparison.delta>0?"var(--green)":p.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",p.comparison.delta>0?"+":"",(p.comparison.delta*100).toFixed(1),"%",p.verdict&&` | ${oE(p.verdict)}`]}),(()=>{const C=p.cases.reduce((T,_)=>T+_.assertions.length,0),O=jE(p.comparison.delta,C,p.cases.length);return a.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const NE={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 TE({name:t,evalId:r,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:f,caseStatus:h,runMode:g,comparisonDetail:p,isReadOnly:y,onRun:v,onBaseline:j,onCompare:S,onCancel:k}){const[E,w]=x.useState(!1),N=h==="running"||h==="queued",A=h==="complete"||h==="error";return a.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&a.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&a.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),a.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",r," ",t]}),g&&(N||A)&&(()=>{const D=NE[g];return D?a.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:D.bg,color:D.color,padding:"1px 6px"},children:D.label}):null})()]}),a.jsxs("div",{className:"flex items-center gap-2",children:[N?a.jsx("button",{onClick:()=>k(r),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>S(r),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),a.jsx("button",{onClick:()=>v(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),a.jsx("button",{onClick:()=>j(r),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&a.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&f!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:ky(u,f)}),o!=null&&a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Cn(o,c)}),h==="cancelled"&&a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"space-y-1",children:s.assertions.map(D=>a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsx("span",{style:{color:D.pass?"var(--green)":"var(--red)"},children:D.pass?"PASS":"FAIL"}),a.jsx("span",{style:{color:"var(--text-secondary)"},children:D.text})]},D.assertion_id))}),s.output&&a.jsx("button",{onClick:()=>w(!E),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:E?"Hide output":"Show output"}),E&&s.output&&a.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),p&&a.jsx("div",{className:"px-4 pb-3",children:a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:a.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const D=Bg(p.skillContentScore,p.baselineContentScore),U=Bg(p.skillStructureScore,p.baselineStructureScore),L=SE(p.winner);return a.jsxs(a.Fragment,{children:[a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",D.skill,"% / Baseline ",D.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",U.skill,"% / Baseline ",U.baseline,"%"]}),a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),a.jsx("span",{style:{color:L.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:L.text})]})})()})})}),s&&s.errorMessage&&a.jsx(RE,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Ad={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function RE({errorMessage:t,classifiedError:r}){const[s,o]=x.useState(!1),c=(r==null?void 0:r.title)??"Error",u=r==null?void 0:r.hint,f=r?Ad[r.category]??Ad.unknown:Ad.unknown;return a.jsx("div",{className:"px-4 pb-3",children:a.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[a.jsx("span",{style:{fontSize:12},children:f}),a.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),a.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&a.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&a.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Ig({label:t,value:r,color:s}){return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(r*100),"%"]})]}),a.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${r*100}%`,background:s}})})]})}const Hg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function AE(){var B;const{state:t,dispatch:r,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=Nn(),{plugin:u,skill:f,activationPrompts:h,activationResults:g,activationSummary:p,activationRunning:y,activationError:v,activationStartedAt:j,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:E,activationHistory:w}=t,{state:N}=Kn(),A=((B=N.skills.find(V=>V.plugin===u&&V.skill===f))==null?void 0:B.version)??null,[D,U]=x.useState(h),[L,F]=x.useState(null),[C,O]=x.useState(!1);x.useEffect(()=>{h&&h!==D&&U(h)},[h]),x.useEffect(()=>{r({type:"SET_ACTIVATION_PROMPTS",prompts:D})},[D,r]),x.useEffect(()=>{fetch(`/api/skills/${u}/${f}/description`).then(V=>V.json()).then(V=>F(V.rawContent||V.description||null)).catch(()=>F(null))},[u,f]);function T(){s(D)}function _(){c(8)}const I=D.trim().split(`
81
+ `).filter(Boolean).length,K=g.filter(V=>V.classification==="TP"||V.classification==="TN"),Q=g.filter(V=>V.classification==="FP"||V.classification==="FN"),q=(L==null?void 0:L.replace(/^---[\s\S]*?---\s*/,"").trim())??null,H=D.trim().length>0,M=q?Fo(q):"";return a.jsxs("div",{className:"p-5 space-y-5",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),a.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),a.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[a.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),a.jsx("div",{className:"flex gap-1.5",children:a.jsx("button",{onClick:_,disabled:k||!q||y,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:q?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:q?1:.5,cursor:q?"pointer":"not-allowed"},title:q?void 0:"No skill description available",onMouseEnter:V=>{q&&!k&&(V.currentTarget.style.background="var(--surface-3)")},onMouseLeave:V=>{k||(V.currentTarget.style.background="var(--surface-2)")},children:k?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),H?"Regenerate":"Generate"," Test Prompts"]})})})]}),!q&&!y&&a.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),E&&a.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:E}),a.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:D,onChange:V=>U(V.target.value),placeholder:`How do I write a unit test?
82
+ What edge cases should I test?
83
+ +Deploy this to production
84
+ !What's the weather like today?
85
+ !Write me a poem about flowers`}),a.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:"One prompt per line"}),a.jsx(ho,{}),a.jsx("span",{children:"No prefix = auto-classify"}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),a.jsx(ho,{}),a.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[I," prompt",I!==1?"s":""]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:T,disabled:y||!D.trim(),className:"btn btn-primary",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("circle",{cx:"12",cy:"12",r:"6"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${I} prompts tested`,j&&a.jsx(DE,{startedAt:j})]})]})]})]}),a.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:q?a.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:M}}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&a.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[a.jsx("div",{className:"spinner-lg mx-auto mb-4"}),a.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&a.jsxs("div",{className:"space-y-5",children:[Q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),a.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",Q.length,")"]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:Q.map((V,W)=>a.jsx(Ug,{result:V},`incorrect-${W}`))})]}),K.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"16 10 11 15 8 12"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",K.length,")"]})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:K.map((V,W)=>a.jsx(Ug,{result:V},`correct-${W}`))})]})]}),p&&a.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),p.autoClassifiedCount!=null&&p.autoClassifiedCount>0&&a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[p.autoClassifiedCount," of ",p.total," prompts auto-classified from skill name and tags"]}),a.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[a.jsx(Md,{label:"Precision",value:p.precision,description:"Of all activations, how many were correct?",detail:`${p.tp} true / ${p.tp+p.fp} total activations`}),a.jsx(Md,{label:"Recall",value:p.recall,description:"Of expected activations, how many fired?",detail:`${p.tp} activated / ${p.tp+p.fn} expected`}),a.jsx(Md,{label:"Reliability",value:p.reliability,description:"Overall correct classification rate",detail:`${p.tp+p.tn} correct / ${p.total} total`})]}),a.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[a.jsx(xo,{label:"True Positive",abbr:"TP",count:p.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),a.jsx(xo,{label:"False Positive",abbr:"FP",count:p.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),a.jsx(xo,{label:"False Negative",abbr:"FN",count:p.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),a.jsx(xo,{label:"True Negative",abbr:"TN",count:p.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),a.jsx(ME,{history:w,expanded:C,onToggle:()=>O(!C),skillVersion:A})]})}function ME({history:t,expanded:r,onToggle:s,skillVersion:o}){return t===null?null:a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:s,children:[a.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&a.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&a.jsx("div",{className:"px-4 py-3",children:t.length===0?a.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):a.jsx("div",{className:"space-y-2",children:t.map(c=>a.jsx(LE,{run:c,skillVersion:o},c.id))})})]})}function LE({run:t,skillVersion:r}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:zE(t.timestamp)}),a.jsx(Ks,{version:r??null,size:"sm","data-testid":"activation-row-version"}),a.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),a.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function zE(t){const r=Date.now(),s=new Date(t).getTime(),o=Math.floor((r-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const f=Math.floor(u/24);return f<7?`${f}d ago`:new Date(t).toLocaleDateString()}function ho(){return a.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function Ug({result:t}){const r=Hg[t.classification]||Hg.FN,s=t.classification==="TP"||t.classification==="TN";return a.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:r.bg,border:"1px solid transparent"},children:[a.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${r.text} 20%, transparent)`},children:s?a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),a.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[a.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:r.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),a.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&a.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&a.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Md({label:t,value:r,description:s,detail:o}){const c=Math.round(r*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),a.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),a.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),a.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function xo({abbr:t,count:r,bg:s,color:o,description:c}){return a.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[a.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:r}),a.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),a.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function DE({startedAt:t}){const[r,s]=x.useState(0);return x.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),a.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}const Ld={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},$g={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},af=600,rf=180,rn=40,zd=af-rn*2,ar=rf-rn*2,_E=[25,50,75,100];function Vg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function OE(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function BE({entries:t,onPointClick:r}){const[s,o]=x.useState(null),c=x.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,f=c.map((p,y)=>{const v=rn+y/(u-1)*zd,j=p.passRate*100,S=rn+ar-j/100*ar;return{x:v,y:S,pct:j,entry:p}}),h=f.map(p=>`${p.x},${p.y}`).join(" "),g=Array.from(new Set(c.map(p=>p.type)));return a.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[a.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),a.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(p=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Ld[p]??"var(--text-tertiary)"}}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:$g[p]??p})]},p))}),a.jsxs("svg",{width:af,height:rf,viewBox:`0 0 ${af} ${rf}`,style:{display:"block",overflow:"visible"},children:[_E.map(p=>{const y=rn+ar-p/100*ar;return a.jsxs("g",{children:[a.jsx("line",{x1:rn,y1:y,x2:rn+zd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),a.jsxs("text",{x:rn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[p,"%"]})]},p)}),a.jsx("line",{x1:rn,y1:rn+ar,x2:rn+zd,y2:rn+ar,stroke:"var(--border-subtle)",strokeWidth:1}),a.jsx("text",{x:rn-8,y:rn+ar+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),a.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),f.map((p,y)=>a.jsx("circle",{cx:p.x,cy:p.y,r:5,fill:Ld[p.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:p.x,y:p.y,entry:p.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>r==null?void 0:r(p.entry)},y)),IE(u).map(p=>a.jsx("text",{x:f[p].x,y:rn+ar+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Vg(c[p].timestamp)},p))]}),s&&a.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Vg(s.entry.timestamp)}),a.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:Ld[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:$g[s.entry.type]??s.entry.type}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),a.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:OE(s.entry.totalDurationMs)}),a.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function IE(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const r=Math.ceil(t/10),s=[0];for(let o=r;o<t-1;o+=r)s.push(o);return s.push(t-1),s}const Ms=new Map;let ln=null,Co=null,go=1e3,wl=0;function wy(){if(ln)return;ln=new EventSource("/api/events");const t=r=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Ms.get(r);if(c)for(const u of c)u(o)};ln.addEventListener("benchmark:complete",t("benchmark:complete")),ln.addEventListener("history:written",t("history:written")),ln.addEventListener("leaderboard:updated",t("leaderboard:updated")),ln.onerror=()=>{ln==null||ln.close(),ln=null,wl>0&&(Co=setTimeout(()=>{go=Math.min(go*2,3e4),wy()},go))},ln.onopen=()=>{go=1e3}}function HE(){Co!=null&&(clearTimeout(Co),Co=null),ln==null||ln.close(),ln=null}function UE(t,r){return Ms.has(t)||Ms.set(t,new Set),Ms.get(t).add(r),wl++,wy(),()=>{var s;(s=Ms.get(t))==null||s.delete(r),wl--,wl<=0&&(wl=0,queueMicrotask(()=>{wl<=0&&HE()}))}}function Lo(t,r){const s=x.useRef(r);s.current=r,x.useEffect(()=>UE(t,c=>s.current(c)),[t])}function zo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function $E(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function VE({rate:t,label:r}){const s=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:zo(t)},children:[s,"%"]})]}),a.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:zo(t)}})})]})})}function PE({points:t}){if(t.length<2)return null;const r=200,s=48,o=4,c=t.length,u=t.map((g,p)=>{const y=o+p/(c-1)*(r-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),f=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,p)=>`${p===0?"M":"L"} ${g.x},${g.y}`).join(" ");return a.jsxs("svg",{width:r,height:s,style:{display:"block"},children:[a.jsx("path",{d:f,fill:"var(--accent-muted)"}),a.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),a.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function FE({plugin:t,skill:r}){const s=`stats/${t}/${r}`,o=x.useCallback(()=>Ee.getStats(t,r),[t,r]),{data:c,loading:u}=Ml(s,o),f=x.useCallback(()=>sn(s),[s]);if(Lo("benchmark:complete",f),Lo("history:written",f),u)return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"skeleton h-24 rounded-xl"}),a.jsx("div",{className:"skeleton h-48 rounded-xl"}),a.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),a.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,p=h-g,y=c.assertionStats.slice(0,10);return a.jsxs("div",{className:"space-y-4 stagger-children",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:zo(h)},children:[Math.round(h*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:p>=0?"var(--green)":"var(--red)"},children:[p>=0?"+":"",Math.round(p*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Cn(c.totalCost)})]}),c.costPerRun!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Cn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),a.jsx(PE,{points:c.trendPoints})]}),c.modelStats.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),a.jsx("tbody",{children:c.modelStats.map(v=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),a.jsx("td",{style:{padding:"8px",textAlign:"center"},children:a.jsxs("span",{className:"font-semibold",style:{color:zo(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:$E(v.avgDurationMs)}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Cn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),a.jsx("div",{className:"space-y-3",children:y.map(v=>a.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:j=>{j.currentTarget.style.background="var(--surface-2)"},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},onClick:()=>{},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),a.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),a.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),a.jsx(VE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function GE({plugin:t,skill:r}){const[s,o]=x.useState(null),[c,u]=x.useState(null),[f,h]=x.useState({}),[g,p]=x.useState({});x.useEffect(()=>{Ee.getEvals(t,r).then(o).catch(()=>o(null))},[t,r]);async function y(v){if(c===v){u(null);return}if(u(v),!f[v]){p(j=>({...j,[v]:!0}));try{const j=await Ee.getCaseHistory(t,r,v);h(S=>({...S,[v]:j}))}catch{h(j=>({...j,[v]:[]}))}finally{p(j=>({...j,[v]:!1}))}}}return s?a.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const j=f[v.id]||[],S=c===v.id,k=g[v.id],E=j.length>0?j[0].pass_rate:null;return a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:w=>{S||(w.currentTarget.style.background="var(--surface-2)")},onMouseLeave:w=>{S||(w.currentTarget.style.background="transparent")},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),a.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),a.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),j.length>=2&&a.jsx(yy,{entries:j}),E!=null&&a.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Tl(E)},children:[Math.round(E*100),"%"]}),j.length>0&&a.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[j.length," runs"]})]}),S&&a.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?a.jsxs("div",{className:"p-4 flex items-center gap-2",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):j.length===0?a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):a.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:j.map((w,N)=>a.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:gy(w.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:w.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:w.type==="benchmark"?"rgba(99,131,255,0.15)":w.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:w.type==="benchmark"?"#6383ff":w.type==="comparison"?"var(--purple)":"#fb923c"},children:w.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Tl(w.pass_rate)},children:[Math.round(w.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[w.durationMs!=null&&a.jsx("span",{children:vy(w.durationMs)}),w.tokens!=null&&a.jsxs("span",{children:[w.tokens>=1e3?`${(w.tokens/1e3).toFixed(1)}k`:w.tokens," tok"]})]}),a.jsx("div",{className:"space-y-1",children:w.assertions.map(A=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:A.pass?"var(--green)":"var(--red)"},children:a.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:A.pass?a.jsx("polyline",{points:"20 6 9 17 4 12"}):a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:A.text}),A.reasoning&&a.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:A.reasoning})]})]},A.id))})]},N))})})]},v.id)})}):a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function WE(){const{state:t,dispatch:r}=Nn(),{plugin:s,skill:o}=t,{state:c}=Kn(),u=c.skills.find(V=>V.plugin===s&&V.skill===o),f=(u==null?void 0:u.version)??null,[h,g]=x.useState("timeline"),[p,y]=x.useState(""),[v,j]=x.useState(""),[S,k]=x.useState(!1),[E,w]=x.useState([]),[N,A]=x.useState(null),[D,U]=x.useState(!1),[L,F]=x.useState(null),[C,O]=x.useState(!1),T=`history/${s}/${o}?model=${p}&type=${v}`,_=x.useCallback(()=>Ee.getHistory(s,o,{model:p||void 0,type:v||void 0}),[s,o,p,v]),{data:I,loading:K}=Ml(T,_),Q=I??[];x.useEffect(()=>{!I||I.length<2||Ee.compareRuns(s,o,I[0].timestamp,I[1].timestamp).then(V=>{const W=V.regressions.filter(de=>de.change==="regression");r({type:"SET_REGRESSIONS",regressions:W})}).catch(()=>{})},[I,s,o,r]);const q=x.useCallback(()=>sn(T),[T]);Lo("history:written",q);const H=x.useCallback(async V=>{if(S){w(W=>W.includes(V)?W.filter(de=>de!==V):W.length>=2?[W[1],V]:[...W,V]);return}O(!0);try{const W=await Ee.getHistoryEntry(s,o,V);F(W)}catch{}finally{O(!1)}},[s,o,S]),M=x.useCallback(async()=>{if(E.length===2){U(!0);try{const V=await Ee.compareRuns(s,o,E[0],E[1]);A(V)}catch{}finally{U(!1)}}},[s,o,E]),B=[...new Set(Q.map(V=>V.model))];return K?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"skeleton h-12 rounded-lg"}),a.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(V=>a.jsx("button",{onClick:()=>g(V),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===V?"var(--accent-muted)":"transparent",color:h===V?"var(--accent)":"var(--text-tertiary)"},children:V==="timeline"?"Timeline":V==="per-eval"?"Per Eval":"Statistics"},V))}),h==="timeline"&&a.jsxs("div",{children:[Q.length>0&&a.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:a.jsx(BE,{entries:Q,onPointClick:V=>H(V.timestamp)})}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("select",{value:p,onChange:V=>y(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Models"}),B.map(V=>a.jsx("option",{value:V,children:V},V))]}),a.jsxs("select",{value:v,onChange:V=>j(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Types"}),a.jsx("option",{value:"benchmark",children:"Benchmark"}),a.jsx("option",{value:"comparison",children:"Comparison"}),a.jsx("option",{value:"baseline",children:"Baseline"}),a.jsx("option",{value:"model-compare",children:"Model Compare"}),a.jsx("option",{value:"improve",children:"AI Improve"}),a.jsx("option",{value:"instruct",children:"AI Edit"}),a.jsx("option",{value:"ai-generate",children:"AI Generate"}),a.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{onClick:()=>{k(!S),w([]),A(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&E.length===2&&a.jsx("button",{onClick:M,disabled:D,className:"btn btn-primary text-[12px]",children:D?"Comparing...":"Compare"})]}),a.jsx("div",{className:"space-y-2",children:Q.length===0?a.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):Q.map(V=>{const W=E.includes(V.timestamp);return a.jsx("button",{onClick:()=>H(V.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:W?"var(--accent-muted)":"var(--surface-1)",border:W?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:de=>{W||(de.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:de=>{W||(de.currentTarget.style.borderColor="var(--border-subtle)")},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[S&&a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:W?"var(--accent)":"var(--border-default)",background:W?"var(--accent)":"transparent"},children:W&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(V.timestamp).toLocaleString()}),a.jsx("span",{className:"pill text-[9px]",style:{background:V.type==="comparison"?"var(--purple-muted)":V.type==="baseline"?"var(--surface-3)":V.type==="model-compare"?"var(--accent-muted)":V.type==="improve"||V.type==="instruct"?"var(--purple-muted)":V.type==="ai-generate"?"var(--green-muted)":V.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:V.type==="comparison"?"var(--purple)":V.type==="baseline"?"var(--text-tertiary)":V.type==="model-compare"?"var(--accent)":V.type==="improve"||V.type==="instruct"?"var(--purple)":V.type==="ai-generate"?"var(--green)":V.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:V.type==="model-compare"?"model compare":V.type==="improve"?"ai improve":V.type==="instruct"?"ai edit":V.type==="ai-generate"?"ai generate":V.type==="eval-generate"?"eval generate":V.type})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ks,{version:f,size:"sm","data-testid":"history-row-version"}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:V.model}),V.totalCost!=null&&V.totalCost>0&&a.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Cn(V.totalCost)}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:V.passRate>=.8?"var(--green)":V.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(V.passRate*100),"%"]})]})]})},V.timestamp)})}),N&&a.jsx(YE,{result:N}),L&&!S&&a.jsx(qE,{run:L,onClose:()=>F(null)})]}),h==="per-eval"&&a.jsx(GE,{plugin:s,skill:o}),h==="statistics"&&a.jsx(FE,{plugin:s,skill:o})]})}function YE({result:t}){const r=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[a.jsxs("span",{children:["Run A cost: ",Cn(t.runA.totalCost??null)]}),a.jsxs("span",{children:["Run B cost: ",Cn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&a.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Cn(t.runB.totalCost-t.runA.totalCost)]})]}),r.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),a.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:a.jsxs("table",{className:"w-full text-[12px]",children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"var(--surface-2)"},children:[a.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),a.jsx("tbody",{children:t.caseDiffs.map(o=>a.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function qE({run:t,onClose:r}){return(t.type==="improve"||t.type==="instruct")&&t.improve?a.jsx(KE,{run:t,onClose:r}):a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),a.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Cn(t.totalCost)}`]}),a.jsx("div",{className:"space-y-2",children:t.cases.map(s=>a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&a.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Cn(s.cost)}),a.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function KE({run:t,onClose:r}){var u;const s=x.useMemo(()=>t.improve?Go(t.improve.original,t.improve.improved):[],[t.improve]),o=x.useMemo(()=>{const f=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:f,removed:h}},[s]),c=x.useMemo(()=>{let f=0,h=0;return s.map(g=>g.type==="removed"?(f++,{...g,origNum:f,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(f++,h++,{...g,origNum:f,newNum:h}))},[s]);return a.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),a.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),a.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:f=>{f.currentTarget.style.background="var(--surface-3)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&a.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:c.map((f,h)=>a.jsxs("tr",{style:{background:f.type==="added"?"var(--green-muted)":f.type==="removed"?"var(--red-muted)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:f.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:f.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:f.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:f.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:f.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:f.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:f.type==="added"?"var(--green)":f.type==="removed"?"var(--red)":"transparent",borderRight:f.type==="added"?"2px solid var(--green)":f.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:f.type==="added"?"+":f.type==="removed"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:f.type==="added"?"var(--green)":f.type==="removed"?"var(--red)":"var(--text-secondary)"},children:f.content||"​"})]},h))})})})]})}function Ey({data:t}){if(t.length<2)return a.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=t.slice(-10),s=80,o=24,c=2,u=s-c*2,f=o-c*2,h=r.length,g=Math.min(...r),y=Math.max(...r)-g||1,v=r.map((k,E)=>{const w=c+E/(h-1)*u,N=c+f-(k-g)/y*f;return`${w.toFixed(1)},${N.toFixed(1)}`}),j=r[r.length-1],S=Tl(j);return a.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[a.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,E]=v[v.length-1].split(",");return a.jsx("circle",{cx:k,cy:E,r:2.5,fill:S})})()]})}function XE(){return a.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function QE({pct:t}){const r=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return a.jsxs("span",{className:"pill",style:{background:s,color:r,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function ZE({score:t,rating:r}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[r]??s.minimal,c=t>=0?"+":"";return a.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),a.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function JE({warning:t}){return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function eC({active:t,onChange:r,hasBaseline:s}){return a.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[a.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),a.jsx("button",{onClick:()=>r("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function tC(t){var o,c,u;if(t.length===0)return[];const r=new Map;for(const f of t)for(const h of f.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;r.has(g)||r.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const p=r.get(g);p.passRates.push(h.passRate.mean),p.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,p.lastDuration=h.duration.mean,p.lastCost=((c=h.cost)==null?void 0:c.total)??null,p.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(p.lastBaselinePassRate=h.baselinePassRate.mean,p.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,p.lastAmplificationPct=h.amplificationPct,p.hasBaseline=!0)}const s=[];for(const[f,h]of r){const[g,...p]=f.split("/");s.push({rank:0,model:p.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((f,h)=>{const g=f.compositeScore??f.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((f,h)=>{f.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Cy=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function nC({entries:t}){return a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>a.jsx("th",{style:Cy(r==="#"?"center":"left"),children:r},r))})}),a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&a.jsx(XE,{})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ey,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function aC({entries:t}){const r=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return r.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",a.jsx("code",{children:"--baseline"})," flag."]})})}):a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>a.jsx("th",{style:Cy(s==="#"?"center":"left"),children:s},s))})}),a.jsx("tbody",{children:r.map((s,o)=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?a.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?a.jsx(QE,{pct:s.amplificationPct}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ey,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function rC(){const{state:t}=Nn(),{plugin:r,skill:s}=t,[o,c]=x.useState("rankings"),u=`leaderboard/${r}/${s}`,f=x.useCallback(()=>Ee.getLeaderboard(r,s),[r,s]),{data:h,loading:g}=Ml(u,f),p=(h==null?void 0:h.entries)??[];x.useEffect(()=>{c("rankings")},[r,s]);const y=x.useCallback(()=>sn(u),[u]);Lo("leaderboard:updated",y);const v=x.useMemo(()=>tC(p),[p]),j=v.some(E=>E.hasBaseline),S=p[0],k=S==null?void 0:S.judgeBiasWarning;return g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),a.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),a.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),a.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",a.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),a.jsx(eC,{active:o,onChange:c,hasBaseline:j})]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&a.jsx(JE,{warning:k}),o==="rankings"?a.jsx(nC,{entries:v}):a.jsx(aC,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&a.jsx(ZE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function lC({plugin:t,skill:r}){const[s,o]=x.useState([]),[c,u]=x.useState([]),[f,h]=x.useState(!0),[g,p]=x.useState(null);x.useEffect(()=>{Ee.getDependencies(t,r).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,r]);async function y(v,j){try{await navigator.clipboard.writeText(j),p(v),setTimeout(()=>p(null),2e3)}catch{}}return f?null:s.length===0&&c.length===0?a.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),a.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>a.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),a.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),a.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(j=>a.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:j},j))})]},v.server))]}),c.length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),a.jsx("div",{className:"space-y-1.5",children:c.map(v=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Pg({plugin:t,skill:r}){const[s,o]=x.useState([]),[c,u]=x.useState(!0),[f,h]=x.useState(null),[g,p]=x.useState(""),[y,v]=x.useState(!1),[j,S]=x.useState(null),[k,E]=x.useState(""),[w,N]=x.useState(""),[A,D]=x.useState(!1),[U,L]=x.useState(new Set),F=x.useCallback(async()=>{u(!0);try{const[_,I]=await Promise.all([Ee.getCredentials(t,r).catch(()=>({credentials:[]})),Ee.getParams(t,r).catch(()=>({params:[]}))]),K=new Map(I.params.map(H=>[H.name,H])),Q=new Set,q=[];for(const H of _.credentials){Q.add(H.name);const M=K.get(H.name);q.push({name:H.name,status:H.status==="ready"||H.status==="resolved"?"ready":"missing",source:H.source,maskedValue:M==null?void 0:M.maskedValue})}for(const H of I.params)Q.has(H.name)||q.push({name:H.name,status:H.status,maskedValue:H.maskedValue});o(q)}finally{u(!1)}},[t,r]);x.useEffect(()=>{F()},[F]);const C=x.useCallback(async _=>{if(U.has(_)){L(I=>{const K=new Set(I);return K.delete(_),K}),o(I=>I.map(K=>K.name===_?{...K,revealedValue:void 0}:K));return}try{const K=(await Ee.getParamsRevealed(t,r,_)).params.find(Q=>Q.name===_);K&&(o(Q=>Q.map(q=>q.name===_?{...q,revealedValue:K.value}:q)),L(Q=>new Set(Q).add(_)))}catch{}},[t,r,U]),O=async(_,I)=>{if(!(!_.trim()||!I.trim())){v(!0),S(null);try{await Ee.setCredential(t,r,_,I),h(null),p(""),L(new Set),F()}catch(K){S(K.message)}finally{v(!1)}}},T=async()=>{if(!(!k.trim()||!w.trim())){v(!0),S(null);try{await Ee.setCredential(t,r,k.trim().toUpperCase(),w),E(""),N(""),D(!1),F()}catch(_){S(_.message)}finally{v(!1)}}};return c?a.jsxs("div",{className:"mt-6",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):a.jsxs("div",{className:"mt-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("button",{onClick:()=>D(!A),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),j&&a.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:j}),s.length===0&&!A?a.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):a.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(_=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:_.name}),_.maskedValue&&a.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:U.has(_.name)&&_.revealedValue!=null?_.revealedValue:_.maskedValue}),_.maskedValue&&a.jsx("button",{onClick:()=>C(_.name),className:"btn btn-ghost px-1",title:U.has(_.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:U.has(_.name)?a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),a.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:_.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:_.status==="ready"?"var(--green)":"var(--orange)"},children:_.status==="ready"?"ready":"missing"}),_.source&&a.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:_.source}),f===_.name?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("input",{value:g,onChange:I=>p(I.target.value),onKeyDown:I=>{I.key==="Enter"&&O(_.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),a.jsx("button",{onClick:()=>O(_.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),a.jsx("button",{onClick:()=>{h(null),p("")},className:"btn btn-ghost text-[10px] px-1",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):a.jsx("button",{onClick:()=>{h(_.name),p("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},_.name))}),A&&a.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:k,onChange:_=>E(_.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),a.jsx("input",{value:w,onChange:_=>N(_.target.value),onKeyDown:_=>{_.key==="Enter"&&T()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx("button",{onClick:()=>{D(!1),E(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),a.jsx("button",{onClick:T,disabled:y||!k.trim()||!w.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function sC(){const{state:t}=Nn(),{plugin:r,skill:s}=t,[o,c]=x.useState(null),[u,f]=x.useState(!0);return x.useEffect(()=>{Ee.getDependencies(r,s).then(c).catch(()=>{}).finally(()=>f(!1))},[r,s]),u?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx(lC,{plugin:r,skill:s}),a.jsx(Pg,{plugin:r,skill:s})]}):a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),a.jsx(Pg,{plugin:r,skill:s})]})}function iC(t){const r={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(r.targetAgents=t.targetAgents),r}function oC(t){var o;const r=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0;return{applyName:r?null:t.aiName??null,applySuggestedPlugin:!s&&!!((o=t.aiSuggestedPlugin)!=null&&o.plugin),suggestedPluginValue:s?null:t.aiSuggestedPlugin??null}}function lf(t,r=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(s=s.replace(/^-+|-+$/g,"")),s}function cC(t,r,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function uC({onCreated:t,resolveAiConfigOverride:r,forceLayout:s}){const[o,c]=x.useState("ai"),[u,f]=x.useState(null),[h,g]=x.useState(!0),{config:p}=_r(),[y,v]=x.useState(""),[j,S]=x.useState(s??3),[k,E]=x.useState(""),[w,N]=x.useState(""),[A,D]=x.useState(""),[U,L]=x.useState(""),[F,C]=x.useState(""),[O,T]=x.useState(""),[_,I]=x.useState("write"),[K,Q]=x.useState([]),[q,H]=x.useState(!1),[M,B]=x.useState(null),[V,W]=x.useState(""),[de,z]=x.useState(!1),[P,te]=x.useState(!1),[le,xe]=x.useState(null),[ce,ve]=x.useState(null),[ue,ye]=x.useState([]),Ne=x.useRef(null),Me=x.useRef(null),re=x.useRef(null),fe=x.useRef(null),me=x.useRef(null),[he,be]=x.useState(!1),[_e,De]=x.useState(!1),pt=x.useRef(y),_t=x.useRef(k),mt=x.useRef(w);x.useEffect(()=>{pt.current=y},[y]),x.useEffect(()=>{_t.current=k},[k]),x.useEffect(()=>{mt.current=w},[w]),x.useEffect(()=>{Ee.getProjectLayout().then(Fe=>{if(f(Fe),s)return;S(Fe.suggestedLayout);const nt=Fe.detectedLayouts.find(wt=>wt.layout===Fe.suggestedLayout);nt!=null&&nt.existingPlugins.length&&E(nt.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),x.useEffect(()=>{var Fe;o==="ai"&&((Fe=Ne.current)==null||Fe.focus())},[o]),x.useEffect(()=>()=>{var Fe;(Fe=Me.current)==null||Fe.abort()},[]);const Jt=x.useMemo(()=>{var Fe;return u?((Fe=u.detectedLayouts.find(nt=>nt.layout===j))==null?void 0:Fe.existingPlugins)||[]:[]},[u,j]),ht=k==="__new__"?w:k,Qe=u?cC(u.root,j,ht||"{plugin}",y||"{skill}"):"",xt=x.useMemo(()=>u?u.detectedLayouts.filter(Fe=>Fe.layout!==4):[],[u]),J=x.useMemo(()=>{if(!u)return null;const Fe=u.detectedLayouts.find(dt=>dt.layout===2&&dt.existingPlugins.length>0),nt=u.detectedLayouts.find(dt=>dt.layout===1&&dt.existingPlugins.length>0),wt=Fe||nt;return wt?{layout:wt.layout,plugins:wt.existingPlugins}:null},[u]),Te=x.useCallback(()=>{if(r)return r();if(!p)return{provider:"claude-cli",model:"sonnet"};const Fe=p.provider||"claude-cli",nt=p.model||"sonnet";return{provider:Fe,model:nt}},[p,r]),Pe=x.useCallback(()=>{var Fe;(Fe=Me.current)==null||Fe.abort(),z(!1)},[]),en=x.useCallback(()=>{xe(null),ve(null)},[]),Xn=x.useCallback(async()=>{var dt,sa;if(xe(null),ve(null),ye([]),re.current=null,fe.current=null,!V.trim()){xe("Describe what your skill should do");return}z(!0);const Fe=new AbortController;Me.current=Fe;const{provider:nt,model:wt}=Te();try{const xn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(iC({prompt:V.trim(),provider:nt,model:wt,targetAgents:K})),signal:Fe.signal});if(!xn.ok||!xn.body){let Tn=`HTTP ${xn.status}`;try{const ia=await xn.json();ia.error&&(Tn=ia.error)}catch{}throw new Error(Tn)}const Aa=xn.body.getReader(),Rt=new TextDecoder;let Vt="",tn="";for(;;){const{done:Tn,value:ia}=await Aa.read();if(Tn)break;Vt+=Rt.decode(ia,{stream:!0});const Ma=Vt.split(`
86
+ `);Vt=Ma.pop()||"";for(const Ir of Ma)if(Ir.startsWith("event: "))tn=Ir.slice(7).trim();else if(Ir.startsWith("data: ")){try{const st=JSON.parse(Ir.slice(6));if(tn==="progress")ye(La=>[...La,{phase:st.phase,message:st.message,timestamp:Date.now()}]);else if(tn==="provenance")fe.current={resolvedModelId:typeof st.resolvedModelId=="string"?st.resolvedModelId:null,snapshotDate:typeof st.snapshotDate=="string"?st.snapshotDate:null};else if(tn==="done"||tn==="complete"){const La={prompt:V.trim(),provider:Te().provider,model:Te().model,resolvedModelId:((dt=fe.current)==null?void 0:dt.resolvedModelId)??null,snapshotDate:((sa=fe.current)==null?void 0:sa.snapshotDate)??null,reasoning:st.reasoning||""},Rn=oC({userName:pt.current,userPlugin:_t.current,userNewPlugin:mt.current,aiName:st.name,aiSuggestedPlugin:st.suggestedPlugin&&st.suggestedPlugin.plugin?{plugin:st.suggestedPlugin.plugin,layout:st.suggestedPlugin.layout}:null});if(Rn.applyName!==null&&v(Rn.applyName),D(st.description),L(st.model||""),C(st.allowedTools||""),T(st.body),te(!0),re.current=La,c("manual"),s===3)S(3),E(""),N("");else if(Rn.applySuggestedPlugin&&Rn.suggestedPluginValue){const Kt=Rn.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(oa=>oa.existingPlugins))??[]).includes(Kt.plugin))if(E(Kt.plugin),Kt.layout&&(Kt.layout===1||Kt.layout===2))S(Kt.layout);else{const oa=u==null?void 0:u.detectedLayouts.find(Dl=>Dl.existingPlugins.includes(Kt.plugin));oa&&(oa.layout===1||oa.layout===2)&&S(oa.layout)}else E("__new__"),N(Kt.plugin)}else!Rn.applySuggestedPlugin&&_t.current.trim().length===0&&mt.current.trim().length===0&&j===3&&J&&De(!0);const qo={name:st.name,plugin:ht||"",layout:j,description:st.description,model:st.model||void 0,allowedTools:st.allowedTools||void 0,body:st.body,aiMeta:La};Ee.saveDraft(qo).then(Kt=>{be(!0),Kt!=null&&Kt.dir&&(me.current=Kt.dir)}).catch(()=>{})}else tn==="error"&&(xe(st.message||st.description||"Unknown error"),st.category&&ve(st))}catch{}tn=""}}}catch(xn){xn.name!=="AbortError"&&xe(xn.message)}finally{z(!1),Me.current=null}},[V,Te,j,J,ht,u,K,s]),qt=x.useCallback(async()=>{if(B(null),!y.trim()){B("Skill name is required");return}if(!A.trim()){B("Description is required");return}if(j!==3&&!ht.trim()){B("Plugin name is required");return}H(!0);try{const Fe=await Ee.createSkill({name:lf(y),plugin:ht||"",layout:j,description:A,model:U||void 0,allowedTools:F||void 0,body:O,aiMeta:re.current||void 0,draftDir:me.current||void 0});me.current=null,t(Fe.plugin,Fe.skill)}catch(Fe){B(Fe.message)}finally{H(!1)}},[y,A,j,ht,U,F,O,t]),dr=x.useCallback(()=>{J&&(S(J.layout),E(J.plugins[0]),De(!1))},[J]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:j,setSelectedLayout:S,creatableLayouts:xt,availablePlugins:Jt,pathPreview:Qe,plugin:k,setPlugin:E,newPlugin:w,setNewPlugin:N,effectivePlugin:ht,name:y,setName:v,description:A,setDescription:D,model:U,setModel:L,allowedTools:F,setAllowedTools:C,body:O,setBody:T,bodyViewMode:_,setBodyViewMode:I,aiPrompt:V,setAiPrompt:W,generating:de,aiGenerated:P,aiError:le,aiClassifiedError:ce,aiProgress:ue,promptRef:Ne,handleGenerate:Xn,handleCancelGenerate:Pe,clearAiError:en,targetAgents:K,setTargetAgents:Q,draftSaved:he,showPluginRecommendation:_e,setShowPluginRecommendation:De,pluginLayoutInfo:J,applyPluginRecommendation:dr,creating:q,error:M,handleCreate:qt}}function Ny(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function dC(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Ty({node:t,depth:r=0}){var s;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?a.jsx(Ny,{}):a.jsx(dC,{}),a.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>a.jsx(Ty,{node:o,depth:r+1},o.name))]})}function fC(t,r,s){const o=[];r&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function pC({skillName:t,hasEvals:r,isDraft:s}){const o=fC(t,r,s);return a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsx(Ny,{})}),"Skill Structure"]}),a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:a.jsx(Ty,{node:o})})]})}const rr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Dd({size:t=14,color:r="currentColor"}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function mC({onCreated:t,onCancel:r}){const s=uC({onCreated:t});return a.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[a.jsxs("div",{className:"mb-5",children:[a.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),a.jsx("div",{className:"flex items-center justify-between mt-2",children:a.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Dd,{size:12}),"AI-Assisted"]})}),a.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsx(Dd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),a.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
87
+
88
+ Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...rr,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),a.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&a.jsx(Xs,{entries:s.aiProgress,isRunning:!0}),s.aiError&&a.jsx("div",{children:s.aiClassifiedError?a.jsx(Wo,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):a.jsxs("div",{children:[a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),a.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?a.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):a.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[a.jsx(Dd,{size:14}),"Generate"]}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",a.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),a.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>a.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),a.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:rr,children:[s.availablePlugins.map(o=>a.jsx("option",{value:o,children:o},o)),a.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&a.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(lf(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:rr})]}),a.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&a.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),a.jsxs("span",{children:["Plugins detected (",a.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),a.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(lf(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:rr})]}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...rr,minHeight:"72px"}})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:rr,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"opus",children:"Opus"}),a.jsx("option",{value:"sonnet",children:"Sonnet"}),a.jsx("option",{value:"haiku",children:"Haiku"})]})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),a.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:rr})]})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),a.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>a.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]}):a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?a.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
89
+
90
+ You are an expert at...
91
+ `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...rr,minHeight:"150px"}}):s.body.trim()?a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Fo(s.body)}}):a.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:a.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),a.jsx(pC,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function hC(){return a.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),a.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),a.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function No({variant:t,message:r,onRetry:s}){const{setMode:o,setSearch:c}=Kn(),[u,f]=x.useState(!1);return t==="no-selection"?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[a.jsx("div",{className:"mb-5",children:u?a.jsx(hC,{}):a.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>f(!0),style:{objectFit:"contain"}})}),a.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?a.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[a.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:a.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),a.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),a.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",a.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),a.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?a.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:a.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[a.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:r||"Failed to load skill data"}),s&&a.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):a.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[a.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),a.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function xC(t,r){const[s,o]=t.split(".").map(Number),[c,u]=r.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const gC={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 vC(){const[t,r]=x.useState([]),[s,o]=x.useState(!0),[c,u]=x.useState(new Set),[f,h]=x.useState(new Map),[g,p]=x.useState(!1),[y,v]=x.useState(new Set),[j,S]=x.useState(null),[k,E]=x.useState(null),[w,N]=x.useState(!1),A=x.useCallback(async()=>{o(!0);try{const T=await Ee.getSkillUpdates();r(T.filter(_=>_.updateAvailable))}catch{r([])}finally{o(!1)}},[]);x.useEffect(()=>{A()},[A]);const D=x.useMemo(()=>t.filter(T=>!T.pinned),[t]),U=x.useCallback(T=>{u(_=>{const I=new Set(_);return I.has(T)?I.delete(T):I.add(T),I})},[]),L=x.useCallback(()=>{c.size===D.length?u(new Set):u(new Set(D.map(T=>T.name)))},[c,D]),F=x.useCallback(()=>{const T=[...c];if(!T.length)return;p(!0),h(new Map(T.map(I=>[I,{skill:I,status:"pending"}])));const _=Ee.startBatchUpdate(T);_.addEventListener("progress",I=>{try{const K=JSON.parse(I.data);h(Q=>new Map(Q).set(K.skill,K))}catch{}}),_.addEventListener("done",I=>{_.close(),p(!1);try{const K=JSON.parse(I.data);S(`Updated ${K.updated??0} skills, ${K.failed??0} failed`),setTimeout(()=>S(null),5e3)}catch{}A()}),_.addEventListener("error",()=>{_.close(),p(!1),S("Batch update failed"),setTimeout(()=>S(null),5e3)})},[c,A]),C=x.useCallback(T=>{T.name.split("/").pop()||T.name;const _=T.name.split("/"),I=_.length>=3?_[_.length-2]:_[0],K=_[_.length-1];v(q=>new Set(q).add(T.name));const Q=Ee.startSkillUpdate(I,K);Q.addEventListener("done",()=>{Q.close(),v(q=>{const H=new Set(q);return H.delete(T.name),H}),A()}),Q.addEventListener("error",()=>{Q.close(),v(q=>{const H=new Set(q);return H.delete(T.name),H})})},[A]),O=x.useCallback(async T=>{if(!T.latest)return;const _=T.name.split("/"),I=_.length>=3?_[_.length-2]:_[0],K=_[_.length-1];N(!0);try{const Q=await Ee.getVersionDiff(I,K,T.installed,T.latest);E({skill:T,diff:Q})}catch{E(null)}finally{N(!1)}},[]);return s?a.jsxs("div",{className:"p-6",children:[a.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-16 rounded-lg"}),a.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16",children:[a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[a.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),a.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),a.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),a.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),a.jsx("button",{onClick:A,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):a.jsxs("div",{className:"p-6",children:[j&&a.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:j}),a.jsxs("div",{className:"flex items-center justify-between mb-5",children:[a.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",D.length,")"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:A,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),a.jsx("button",{onClick:F,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),a.jsx("div",{className:"flex items-center gap-2 mb-3",children:a.jsxs("button",{onClick:L,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===D.length&&D.length>0?"var(--accent)":"var(--border-default)",background:c.size===D.length&&D.length>0?"var(--accent)":"transparent"},children:c.size===D.length&&D.length>0&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),a.jsx("div",{className:"space-y-2",children:t.map(T=>{const _=T.name.split("/").pop()||T.name,I=T.latest?xC(T.installed,T.latest):"patch",K=gC[I],Q=!!T.pinned,q=y.has(T.name),H=f.get(T.name),M=c.has(T.name);return a.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:Q?.7:1},children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:()=>!Q&&U(T.name),disabled:Q,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:Q?"not-allowed":"pointer"},children:a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:M?"var(--accent)":"var(--border-default)",background:M?"var(--accent)":"transparent",opacity:Q?.4:1},children:M&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:_}),Q&&a.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),a.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:K.bg,color:K.text},children:I})]}),a.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[T.installed," → ",T.latest||"?",Q&&` (pinned at ${T.pinnedVersion||T.installed})`]})]}),H&&a.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:H.status==="done"?"var(--green-muted)":H.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:H.status==="done"?"var(--green)":H.status==="error"?"var(--red)":"var(--yellow)"},children:[H.status,H.error&&`: ${H.error}`]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:()=>O(T),className:"btn btn-ghost text-[11px]",disabled:w,children:"View Changes"}),a.jsx("button",{onClick:()=>C(T),disabled:Q||q||g,title:Q?"Pinned — unpin from CLI to update":"",className:`btn ${Q?"btn-ghost":"btn-primary"} text-[11px]`,children:q?a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(H==null?void 0:H.status)==="done"?a.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},T.name)})}),k&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>E(null),children:a.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:T=>T.stopPropagation(),children:[a.jsx("div",{className:"mb-2 flex justify-end",children:a.jsx("button",{onClick:()=>E(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),a.jsx(Rf,{contentDiff:k.diff.contentDiff,fromLabel:k.diff.from,toLabel:k.diff.to,diffSummary:k.diff.diffSummary,renderContext:"inline"})]})})]})}function yC(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function bC(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function jC(t){if(!t||typeof t!="string")return null;const r=t.trim();if(!r)return null;if(!r.includes("://")){const[s]=r.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(r),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function Ry(t){const{author:r,repoUrl:s}=t,o=jC(s??null),c=r&&r.trim()!==""?r:o??"—",[u,f]=x.useState(!1),h=x.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),f(!0),setTimeout(()=>f(!1),1500)}catch{}},[c]);return o?a.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!r||r.trim()===""?a.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function SC(t){let r=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return r=r.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),r}function kC(t,r){const s=SC(t),o=(r??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Fg(t){if(!t)return"source";const r=t.replace(/\/+$/,""),s=r.lastIndexOf("/");return s===-1?r:r.slice(s+1)}function Ay(t){const{repoUrl:r,skillPath:s,absolutePath:o}=t,[c,u]=x.useState(!1),f=typeof r=="string"&&r.trim()!==""&&/^https?:\/\//.test(r.trim()),h=s?Fg(s):o?Fg(o):"source",g=x.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(f){const y=kC(r,s);return a.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return a.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const p=o??s??"";return a.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${p}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.jsx("span",{children:h}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Gg(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function My(t){return t.skill?EC({skill:t.skill}):NC({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function wC(t,r=48){if(t.length<=r)return t;const s=t.slice(0,12),o=t.slice(t.length-(r-12-1));return`${s}…${o}`}function EC({skill:t}){const[r,s]=x.useState(!1),o=x.useCallback(async()=>{var f;try{await((f=navigator.clipboard)==null?void 0:f.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Gg(ne.toasts.pathCopied,"info")}catch{Gg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[a.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),a.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[a.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[a.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),a.jsx("span",{"data-testid":"detail-header-version",children:a.jsx(Ks,{version:t.version??null})})]}),a.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(Ry,{author:t.author??null,repoUrl:t.homepage??null}),a.jsx(Ay,{repoUrl:t.homepage??null,skillPath:null,absolutePath:t.dir})]}),a.jsx(CC,{skill:t}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[a.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:wC(t.dir||"—")}),a.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[a.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),r?"Copied":"Copy"]})]})]})}function CC({skill:t}){const r=t.installMethod,s=t.symlinkTarget;if(!r)return null;let o="";switch(r){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return a.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[a.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),a.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function NC({state:t,isReadOnly:r,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:f,isDirty:h,caseRunStates:g,regressions:p,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),j=f==null?void 0:f.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,A)=>N+A.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,E=yC(j),w=bC(j);return a.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[a.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[a.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),a.jsx(TC,{}),a.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),r&&a.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),a.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&a.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&a.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[a.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[!r&&s&&a.jsx("button",{disabled:v,onClick:()=>{window.confirm(`Delete skill "${c}"? This cannot be undone.`)&&s()},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:a.jsx(RC,{})}),p.length>0&&a.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[a.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),p.length," regression",p.length>1?"s":""]}),y>0&&a.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),a.jsx("span",{className:"pill",style:{background:w,color:E},children:j!=null?`${Math.round(j*100)}%`:"--"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function TC(){return a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function RC(){return a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),a.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),a.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function lr(t){const{title:r,label:s,value:o,subtitle:c,description:u,linkLabel:f,children:h,onClick:g}=t,p=r??s??"",y=typeof g=="function",v=j=>{y&&(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),g==null||g())};return a.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[p?a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:p}):null,a.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?a.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?a.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,f?a.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:f}):null]})}const AC="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 MC(t){const{onNavigate:r}=t,[s,o]=x.useState(t.open??!1),c=x.useCallback(()=>o(!1),[]);x.useEffect(()=>{if(!s)return;const f=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[s,c]);const u=x.useCallback(f=>{r==null||r(f),o(!1)},[r]);return a.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(f=>!f),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&a.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[a.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:AC}),a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[a.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:_d,children:"Tests →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:_d,children:"Run →"}),a.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{..._d,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const _d={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function LC(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const r=t/1024;if(r<1024)return r>=10?`${Math.round(r)} KB`:`${r.toFixed(1).replace(/\.0$/,"")} KB`;const s=r/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Rs(t){if(!t)return"—";const r=new Date(t);if(Number.isNaN(r.getTime()))return t;const s=Date.now()-r.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const f=Math.floor(u/24);if(f<30)return`${f} day${f===1?"":"s"} ago`;const h=Math.floor(f/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function zC(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function DC(t){const r=t.installMethod;if(!r)return null;const s=r==="authored"?"Authored":r==="copied"?"Copied":"Symlinked";return a.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function _C(t){var y,v;const{skill:r,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:f}=t,h=u??(OC(r.homepage)?r.homepage??null:null),g=((y=r.mcpDeps)==null?void 0:y.length)??0,p=((v=r.deps)==null?void 0:v.length)??0;return a.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[a.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[a.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:r.skill}),a.jsx(Ks,{version:r.version??null}),DC(r)]}),a.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[a.jsx(Ry,{author:r.author??null,repoUrl:h}),r.category?a.jsxs("span",{children:["· ",r.category]}):null,a.jsx(Ay,{repoUrl:h,skillPath:f??null,absolutePath:r.dir}),r.lastModified?a.jsxs("span",{title:r.lastModified,children:["· Updated ",Rs(r.lastModified)]}):null]})]}),a.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[a.jsx(lr,{title:"Benchmark",value:zC(r),subtitle:r.lastBenchmark?Rs(r.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:a.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:a.jsx(MC,{onNavigate:s})})}),a.jsx(lr,{title:"Tests",value:r.evalCount??0,subtitle:`${r.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),a.jsx(lr,{title:"Activations",value:o,subtitle:c?`Last: ${Rs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),a.jsx(lr,{title:"Last run",value:Rs(c??r.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),a.jsx(lr,{title:"MCP deps",value:g,subtitle:g>0&&r.mcpDeps?r.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(lr,{title:"Skill deps",value:p,subtitle:p>0&&r.deps?r.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),a.jsx(lr,{title:"Size",value:LC(r.sizeBytes),"data-testid":"metric-size"}),a.jsx(lr,{title:"Last modified",value:Rs(r.lastModified),subtitle:r.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function OC(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}const Wg=x.memo(function({message:r,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return a.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:r})});function BC({toast:t,onDismiss:r}){const[s,o]=x.useState(!0),c=x.useRef(null);x.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return a.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&a.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),r(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),a.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function IC({toasts:t,onDismiss:r,liveMessage:s,liveAssertiveMessage:o}){return a.jsxs(a.Fragment,{children:[a.jsx(Wg,{politeness:"polite",message:s}),a.jsx(Wg,{politeness:"assertive",message:o}),t.length>0&&a.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>a.jsx("div",{style:{pointerEvents:"auto"},children:a.jsx(BC,{toast:c,onDismiss:r})},c.id))})]})}const Ly=x.createContext(null);function Yo(){const t=x.useContext(Ly);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function HC({children:t,maxVisible:r=4,defaultDurationMs:s=4e3}){const[o,c]=x.useState([]),[u,f]=x.useState(""),[h,g]=x.useState(""),p=x.useRef(new Map),y=x.useCallback(w=>{const N=p.current.get(w);N&&(clearTimeout(N),p.current.delete(w)),c(A=>A.filter(D=>D.id!==w))},[]),v=x.useCallback((w,N)=>{if(N<=0)return;const A=setTimeout(()=>{y(w)},N);p.current.set(w,A)},[y]),j=x.useCallback(w=>{const N=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,A={id:N,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(D=>[...D,A]),A.severity==="error"?g(A.message):f(A.message),v(N,A.durationMs),N},[s,v]),S=x.useCallback(()=>{for(const w of p.current.values())clearTimeout(w);p.current.clear(),c([])},[]);x.useEffect(()=>{function w(N){N.key==="Escape"&&c(A=>{if(A.length===0)return A;const D=A.slice(0,r),U=D[D.length-1],L=p.current.get(U.id);return L&&(clearTimeout(L),p.current.delete(U.id)),A.filter(F=>F.id!==U.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[r]),x.useEffect(()=>()=>{for(const w of p.current.values())clearTimeout(w);p.current.clear()},[]);const k=o.slice(0,r),E=x.useMemo(()=>({toast:j,dismiss:y,clear:S}),[j,y,S]);return a.jsxs(Ly.Provider,{value:E,children:[t,a.jsx(IC,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function UC(t){const{toast:r}=Yo(),s=x.useRef(t);s.current=t;const o=x.useCallback(async(...c)=>{const u=s.current,f=u.snapshot();u.apply(...c),u.confirmGraceMs;const h=u.timeoutMs??5e3;let g=!1,p,y=!1;const v=u.commit(...c).then(()=>{g=!0,y=!0},k=>{g=!0,p=k??new Error("Commit failed")}),j=new Promise(k=>{setTimeout(k,h)});if(await Promise.race([v,j]),!g)p=new Error("TIMEOUT");else if(y)return;u.rollback(f);const S=typeof u.failureMessage=="function"?u.failureMessage(p):u.failureMessage??"Couldn't complete that action.";r({message:S,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{o(...c)}}})},[r]);return{run:o}}const Yg=6e4;function $C({skill:t}){const{refreshUpdates:r,dismissPushUpdate:s}=Kn(),{toast:o}=Yo(),[c,u]=x.useState("idle"),[f,h]=x.useState(null),[g,p]=x.useState(!1),[y,v]=x.useState(null),[j,S]=x.useState(!1),k=x.useRef(null),E=x.useRef(null),w=x.useCallback(()=>new Promise((L,F)=>{if(!t){F(new Error("No skill selected"));return}const C=Ee.startSkillUpdate(t.plugin,t.skill);k.current=C;const O=()=>{E.current&&(clearTimeout(E.current),E.current=null);try{C.close()}catch{}k.current=null};E.current=setTimeout(()=>{O(),F(new Error("TIMEOUT"))},Yg),C.addEventListener("progress",T=>{try{const _=JSON.parse(T.data);typeof(_==null?void 0:_.status)=="string"&&h(_.status)}catch{}}),C.addEventListener("done",()=>{O(),u("done"),h(null),r(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3}),L()}),C.addEventListener("error",T=>{O();let _="Stream error";try{const I=typeof T.data=="string"?JSON.parse(T.data):null;I!=null&&I.error&&(_=String(I.error))}catch{}F(new Error(_))})}),[t,r,s,o]),N=UC({snapshot:()=>({status:c}),apply:()=>{u("updating"),h("updating")},commit:()=>w(),rollback:L=>{u(L.status==="updating"?"idle":L.status),h(null)},failureMessage:L=>`Couldn't update ${(t==null?void 0:t.skill)??"skill"} — ${L.message}`,timeoutMs:Yg+1e3});if(x.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let L=!1;return S(!0),Ee.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(F=>{L||v(F)}).catch(()=>{L||v(null)}).finally(()=>{L||S(!1)}),()=>{L=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),x.useEffect(()=>()=>{if(E.current&&clearTimeout(E.current),k.current)try{k.current.close()}catch{}},[]),!t||t.updateAvailable!==!0)return null;const A=t.latestVersion,D=c==="updating"?"Updating…":A?`Update to ${A}`:"Update",U=c==="updating";return a.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{N.run()},disabled:U,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:U?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:D}),a.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>p(L=>!L),disabled:U||!A,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),f&&a.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:f}),g&&A&&a.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[j&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!j&&y&&a.jsx(Rf,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!j&&!y&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const VC=3e4;function PC({plugin:t,skill:r,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=Kn(),[u,f]=x.useState(!1),[h,g]=x.useState(!1),[,p]=x.useState(0),y=x.useRef(null),v=x.useRef(null),j=`${t}/${r}`,S=c.updatesById.get(j);if(x.useEffect(()=>{if(!u)return;const E=setInterval(()=>p(w=>(w+1)%1e6),250);return()=>clearInterval(E)},[u]),x.useEffect(()=>{if(!u||!S)return;const E=v.current??0;S.receivedAt<E||(y.current&&(clearTimeout(y.current),y.current=null),f(!1),g(!1),v.current=null)},[u,S]),x.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),f(!0),v.current=Date.now(),y.current=setTimeout(()=>{f(!1),g(!0),y.current=null,v.current=null},VC);try{await Ee.rescanSkill(t,r)}catch{y.current&&(clearTimeout(y.current),y.current=null),f(!1),v.current=null}}};return a.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&a.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&a.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const zy=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],FC={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function GC(t){return typeof t=="string"&&zy.includes(t)}function WC(){if(typeof window>"u")return"overview";const r=new URLSearchParams(window.location.search).get("panel");return GC(r)?r:"overview"}function Od(){const{state:t,setMobileView:r}=Kn();return t.isMobile?a.jsxs("button",{onClick:()=>r("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function YC(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return qC(t);const{state:r,selectSkill:s,setMode:o,refreshSkills:c}=Kn(),[u,f]=x.useState(typeof window<"u"?window.location.hash:"");if(x.useEffect(()=>{const p=()=>f(window.location.hash);return window.addEventListener("hashchange",p),()=>window.removeEventListener("hashchange",p)},[]),u==="#/updates")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Od,{}),a.jsx(vC,{})]});if(r.mode==="create")return a.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[a.jsx(Od,{}),a.jsx(mC,{onCreated:(p,y)=>{o("browse"),c(),s({plugin:p,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!r.selectedSkill)return r.skillsError?a.jsx(No,{variant:"error",message:r.skillsError,onRetry:c}):!r.skillsLoading&&r.skills.length===0?a.jsx(No,{variant:"no-skills"}):a.jsx(No,{variant:"no-selection"});const h=r.selectedSkill,g=r.skills.find(p=>p.plugin===h.plugin&&p.skill===h.skill)??null;return a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx(Od,{}),a.jsx(KC,{skillInfo:g,allSkills:r.skills,onSelectSkill:p=>s(p)})]})}function qC(t){const r=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(r==null)return QC();if(t.loadError)return ZC(r,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Dy(r,s,t.onDetailTabChange,o)}function KC({skillInfo:t,allSkills:r,onSelectSkill:s}){const[o,c]=x.useState(WC());x.useEffect(()=>{if(typeof window>"u")return;const f=new URLSearchParams(window.location.search);o==="overview"?f.delete("panel"):f.set("panel",o);const h=f.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=x.useMemo(()=>t?Dy(t,o,c,{}):a.jsx(No,{variant:"no-selection"}),[t,o,r,s]);return a.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function XC(t,r){return a.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:zy.map(s=>{const o=s===t;return a.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>r==null?void 0:r(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:FC[s]},s)})})}function QC(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function ZC(t,r){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[My({skill:t}),a.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[a.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),a.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:r})]})]})}function JC({active:t}){return t==="editor"?a.jsx(lE,{}):t==="tests"?a.jsx(fE,{}):t==="run"?a.jsx(CE,{}):t==="activation"?a.jsx(AE,{}):t==="history"?a.jsx(WE,{}):t==="leaderboard"?a.jsx(rC,{}):t==="deps"?a.jsx(sC,{}):t==="versions"?a.jsx(Dw,{}):null}function eN({active:t}){const{state:r,dispatch:s}=Nn();return x.useEffect(()=>{t!=="overview"&&r.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,r.activePanel,s]),null}function Dy(t,r,s,o){const c=h=>{s==null||s(h)},u=a.jsx(_C,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),f=o!=null?a.jsxs(Mw,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[a.jsx(eN,{active:r}),a.jsx(JC,{active:r})]},`${t.plugin}/${t.skill}`):a.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",r," view."]});return a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[a.jsx("div",{style:{padding:16,paddingBottom:12},children:My({skill:t})}),a.jsx($C,{skill:t}),t.origin==="installed"&&a.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:a.jsx(PC,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),XC(r,s),a.jsx("div",{role:"tabpanel",id:`detail-panel-${r}`,"aria-labelledby":`detail-tab-${r}`,"data-testid":`detail-panel-${r}`,style:{flex:1,minHeight:0,overflow:"auto"},children:r==="overview"?u:f})]})}function tN(){const{updateCount:t,state:r,dismissUpdateNotification:s}=Kn(),o=t>0&&!r.updateNotificationDismissed;return x.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?a.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[a.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),a.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),a.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const nN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function aN({open:t,onClose:r,groups:s=nN,title:o=ne.shortcuts.title}){const c=x.useRef(null),u=x.useRef(null);return x.useEffect(()=>{var f;if(t)return c.current=document.activeElement??null,(f=u.current)==null||f.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),x.useEffect(()=>{if(!t)return;function f(h){var g;if(h.key==="Escape"){h.preventDefault(),r();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",f,!0),()=>window.removeEventListener("keydown",f,!0)},[t,r]),t?a.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:f=>{f.target===f.currentTarget&&r()},children:a.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[a.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),a.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:r,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(f=>a.jsxs("section",{style:{marginBottom:12},children:[a.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:f.name}),a.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:f.items.map(h=>a.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[a.jsx("span",{children:h.label}),a.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${f.name}:${h.keys}`))})]},f.name))]})}):null}function rN(t){const r=ne.actions,s=[{action:"open",label:r.open},{action:"copy-path",label:r.copyPath},{action:"reveal",label:r.revealInEditor},{action:"run-benchmark",label:r.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:r.edit},{action:"duplicate",label:r.duplicate},{action:"delete",label:r.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:r.update}),o.push({action:"uninstall",label:r.uninstall}),o.push({action:"delete",label:r.delete,disabled:!0,title:r.deletePluginTooltip}),o}function lN({state:t,onClose:r,onAction:s,itemsOverride:o}){const c=x.useRef(null),u=x.useRef(null),[f,h]=x.useState(0),g=x.useMemo(()=>t.skill?o??rN(t.skill):[],[t.skill,o]),p=x.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,j=220,S=44+g.length*28;let k=t.x,E=t.y;return k+j+v>window.innerWidth&&(k=Math.max(v,t.x-j)),E+S+v>window.innerHeight&&(E=Math.max(v,t.y-S)),{left:k,top:E}},[t.x,t.y,g.length]);x.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,j;(j=(v=u.current)==null?void 0:v.focus)==null||j.call(v),u.current=null}},[t.open]);const y=x.useCallback(()=>{if(!t.skill)return;const v=g[f];!v||v.disabled||(s(v.action,t.skill),r())},[g,f,t.skill,s,r]);return x.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),r();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function j(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||r())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",j,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",j,!0)}},[t.open,r,g.length,y]),!t.open||!t.skill?null:a.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:p.left,top:p.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,j)=>a.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":j===f||void 0,onMouseEnter:()=>h(j),onClick:()=>{v.disabled||(s(v.action,t.skill),r())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:j===f?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}const sN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function iN(t){return t?sN[t]??null:null}function oN({open:t,providerKey:r,onClose:s}){const o=x.useRef(null);if(x.useEffect(()=>{if(!t)return;const f=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[t,s]),x.useEffect(()=>{if(!t)return;const f=o.current;if(!f)return;const h=f.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=iN(r),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Bo.createPortal(a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),a.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsx(cN,{title:u,onClose:s}),a.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?a.jsx(uN,{content:c}):a.jsx(dN,{})}),a.jsx("style",{children:`@keyframes vskillDrawerIn {
92
+ from { transform: translateX(100%); }
93
+ to { transform: translateX(0); }
94
+ }
95
+ @keyframes vskillDrawerBackdropIn {
96
+ from { opacity: 0; }
97
+ to { opacity: 1; }
98
+ }`})]})]}),document.body)}function cN({title:t,onClose:r}){return a.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[a.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),a.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:r,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function uN({content:t}){var r,s;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[a.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>a.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),a.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>a.jsx("li",{children:a.jsx(fN,{name:o})},o))})]}),t.keyUrl&&a.jsx(pN,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&a.jsxs("section",{children:[a.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(r=t.install)==null?void 0:r.map((o,c)=>a.jsx(Bd,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>a.jsx(Bd,{code:o},`start-${c}`)),t.pullExample&&a.jsx(Bd,{code:t.pullExample})]})]}),a.jsx("footer",{style:{marginTop:8},children:a.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function dN(){return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[a.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),a.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function fN({name:t}){const r=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),a.jsx("button",{type:"button",onClick:r,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function Bd({code:t}){return a.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function pN({href:t,label:r,testId:s}){return a.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer","data-testid":s,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[r," →"]})}function mN(){const[t,r]=x.useState(!1),[s,o]=x.useState(null),c=x.useRef(null),u=x.useCallback((h,g)=>{var p;c.current=typeof document<"u"?document.activeElement:null,(p=g==null?void 0:g.beforeOpen)==null||p.call(g),o(h),r(!0)},[]),f=x.useCallback(()=>{r(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return{open:u,close:f,isOpen:t,providerKey:s}}function hN(t){const r=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const f=t.filter(h=>c.sharedFolderGroup.includes(h.id));r.push({kind:"aggregate",key:`shared:${u}`,consumers:f,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:f.reduce((h,g)=>h+g.globalCount,0)});continue}r.push({kind:"individual",key:c.id,agent:c})}return{detected:r,notDetected:s}}function xN({agents:t,activeAgentId:r,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:f}){const h=x.useRef(null);x.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),f())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[f]),x.useEffect(()=>{const y=j=>{h.current&&!h.current.contains(j.target)&&f()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[f]);const g=x.useMemo(()=>hN(t),[t]),p=t.find(y=>y.id===s)??t.find(y=>y.id===r)??t[0];return typeof document>"u"?null:Bo.createPortal(a.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[a.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[a.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&a.jsx(qg,{}),g.detected.map(y=>y.kind==="aggregate"?a.jsx(vN,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??r??"")}},y.key):a.jsx(gN,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===r,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>a.jsx(yN,{agent:y.agent},y.key))]})]}),a.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:p?a.jsx(bN,{agent:p,activeAgentId:r,onSwitch:()=>c(p.id)}):a.jsx(qg,{})})]}),a.jsx("style",{children:`@keyframes scopePickerFadeIn {
99
+ from { opacity: 0; transform: translateX(-50%) translateY(2px); }
100
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
101
+ }`})]}),document.body)}function gN({agent:t,focused:r,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return a.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),a.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function vN({row:t,onFocus:r}){return a.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),a.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function yN({agent:t}){const r=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return a.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),a.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&a.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function bN({agent:t,activeAgentId:r,onSwitch:s}){const o=t.id===r,c=t.isRemoteOnly===!0,u=o||c,f=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":SN(t.health)})]}),a.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[a.jsx(Id,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),a.jsx(Id,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),a.jsx(Id,{label:ne.scopePicker.statsLastSync,value:t.lastSync?jN(t.lastSync):"—"})]}),a.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:f})]})}function Id({label:t,value:r}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function qg(){return a.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function jN(t){try{const r=new Date(t).getTime(),s=Date.now()-r;if(Number.isNaN(r))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function SN(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function kN(t){const r=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)r.set(o,s);return t.agents.map(s=>{const o=r.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function wN({agents:t,activeAgentId:r,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=x.useState(!1),[f,h]=x.useState(null),g=x.useRef(null),p=x.useMemo(()=>t.find(S=>S.id===r)??t[0]??null,[t,r]),y=x.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=x.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),j=x.useCallback(S=>{s(S),u(!1)},[s]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),a.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&a.jsx(xN,{agents:t,activeAgentId:r,focusedAgentId:f??r,onFocusAgent:h,onSwitch:j,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const _y="vskill-ccode-banner-dismissed",EN=new Set(["claude-cli","claude-code"]);function CN(){try{return sessionStorage.getItem(_y)==="true"}catch{return!1}}function NN(){try{sessionStorage.setItem(_y,"true")}catch{}}function TN({activeAgentId:t}){const[r,s]=x.useState(()=>CN()),o=x.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=x.useCallback(()=>{NN(),s(!0)},[]);return!t||!EN.has(t)||r?null:a.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code subscription info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function RN(){const[t,r]=x.useState(null),[s,o]=x.useState("loading"),[c,u]=x.useState(null),f=x.useCallback(async()=>{try{const h=await Ee.getAgents();r(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return x.useEffect(()=>{f()},[f]),x.useEffect(()=>{const h=()=>void f();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[f]),{status:s,response:t,error:c,refresh:()=>void f()}}const vo="workspace",AN=["skills","agents"];async function MN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function LN(t){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${r.status}`)}return await r.json()}async function zN(t){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function DN(t){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${r.status}`)}return await r.json()}function Hd(){for(const t of AN)sn(t)}function _N(){const{data:t,loading:r,error:s,revalidate:o}=Ml(vo,MN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),f=x.useCallback(async p=>{await LN(p),sn(vo),Hd()},[]),h=x.useCallback(async p=>{await zN(p),sn(vo),Hd()},[]),g=x.useCallback(async p=>{await DN(p),sn(vo),Hd()},[]);return{workspace:c,activeProject:u,loading:r,error:s,switchProject:f,addProject:h,removeProject:g,revalidate:o}}function ON({workspace:t,onSwitch:r,onAdd:s,onRemove:o,isPathStale:c}){const[u,f]=x.useState(!1),[h,g]=x.useState(!1),[p,y]=x.useState(""),[v,j]=x.useState(null),[S,k]=x.useState(null),[E,w]=x.useState(null),[N,A]=x.useState(!1),D=x.useRef(null),U=(t==null?void 0:t.projects)??[],L=U.find(T=>T.id===(t==null?void 0:t.activeProjectId));x.useEffect(()=>{if(!u)return;function T(_){D.current&&!D.current.contains(_.target)&&(f(!1),g(!1),j(null))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[u]);async function F(){j(null);const T=p.trim();if(!T){j("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!T.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(T)){j("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:T}),y(""),g(!1)}catch(_){const I=_ instanceof Error?_.message:String(_);/does not exist/i.test(I)?j(`Path not found on disk: ${T}`):/Duplicate/i.test(I)?j("That project is already registered."):j(I)}}async function C(){if(j(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const T=await window.showDirectoryPicker();y(T.name),g(!0)}catch{}else g(!0)}function O(T){if(T.length<=50)return T;const _=T.split("/");return _.length<=4?T:`${_.slice(0,3).join("/")}/…/${_.slice(-2).join("/")}`}return a.jsxs("div",{ref:D,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[a.jsxs("button",{type:"button",onClick:()=>f(T=>!T),"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:[a.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)"}}),a.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L?L.name:"No project"}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&a.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[U.length===0&&a.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),U.length>0&&a.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:U.map(T=>{const _=c?c(T.path):!1,I=T.id===(t==null?void 0:t.activeProjectId),K=S===T.id;return a.jsxs("li",{role:"menuitem","data-stale":_?"true":"false",onMouseEnter:()=>k(T.id),onMouseLeave:()=>k(Q=>Q===T.id?null:Q),onClick:()=>{if(!_){if(I){f(!1);return}w(T)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:K&&!_?"var(--surface-2, rgba(0,0,0,0.04))":I?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:_?.5:1,transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:T.colorDot,boxShadow:I?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:I?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.name}),I&&a.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),a.jsx("div",{title:T.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(T.path)}),_&&a.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),a.jsx("button",{type:"button","aria-label":`Remove ${T.name}`,onClick:Q=>{Q.stopPropagation(),o(T.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:K?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:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"}),a.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},T.id)})}),a.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&a.jsxs("button",{type:"button",onClick:()=>void C(),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:T=>{T.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:T=>{T.currentTarget.style.backgroundColor="transparent"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("input",{type:"text",value:p,onChange:T=>y(T.target.value),onKeyDown:T=>{T.key==="Enter"&&F(),T.key==="Escape"&&(g(!1),j(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:()=>{g(!1),j(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>w(null),children:[a.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),a.jsxs("div",{onClick:T=>T.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),a.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),a.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),A(!0),setTimeout(()=>A(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),a.jsx("button",{type:"button",onClick:()=>w(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function BN(t,r){const s=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function IN({open:t,projects:r,onSwitch:s,onClose:o}){const[c,u]=x.useState(""),[f,h]=x.useState(0),g=x.useMemo(()=>BN(r,c),[r,c]);x.useEffect(()=>{t||(u(""),h(0))},[t]),x.useEffect(()=>{f>=g.length&&h(0)},[g.length,f]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[f];v&&(s(v.id),o())}};return t?a.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[a.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),a.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[a.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),a.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&a.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>a.jsxs("li",{role:"option","aria-selected":v===f,"data-highlighted":v===f,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===f?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[a.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),a.jsxs("span",{className:"flex-1",children:[a.jsx("span",{className:"vskill-palette-name",children:y.name}),a.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const Kg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function HN({open:t,onClose:r,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[f,h]=x.useState("destination"),[g,p]=x.useState(s),[y,v]=x.useState(""),[j,S]=x.useState(""),[k,E]=x.useState(""),[w,N]=x.useState([]),[A,D]=x.useState(!1),[U,L]=x.useState(null);if(x.useEffect(()=>{t&&(h("destination"),p(s),v(""),S(""),E(""),L(null))},[t,s]),x.useEffect(()=>{if(!t)return;let H=!0;return fetch("/api/authoring/plugins").then(M=>M.json()).then(M=>{H&&N(M.plugins??[])}).catch(()=>{}),()=>{H=!1}},[t]),x.useEffect(()=>{if(!t)return;function H(M){M.key==="Escape"&&(M.preventDefault(),r())}return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[t,r]),!t)return null;const F=w.length>0,C=o&&F,O=o,T=Kg.test(y),_=g==="existing-plugin"?j.length>0:Kg.test(j),I=!A&&T&&(g==="standalone"||_),K=UN(c,g,j,y);async function Q(){L(null),D(!0);try{const B=new URLSearchParams;B.set("mode",g),B.set("skillName",y),j&&B.set("pluginName",j);const V=await fetch(`/api/authoring/skill-exists?${B.toString()}`),W=await V.json();if(!V.ok){L(W.error??`Check failed: ${V.status}`);return}if(W.exists){L(`Skill '${y}' already exists${W.path?` at ${W.path}`:""}`);return}}catch(B){L(B instanceof Error?B.message:String(B));return}finally{D(!1)}const H=new URLSearchParams;H.set("mode",g),H.set("skillName",y),k.trim()&&H.set("description",k.trim()),j&&H.set("pluginName",j);const M=`#/create?${H.toString()}`;typeof window<"u"&&(window.location.hash=M),r()}async function q(){L(null),D(!0);try{const H=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:j})}),M=await H.json();if(!H.ok||!M.ok){L(M.error??`Create failed: ${H.status}`);return}sn("skills"),u==null||u({mode:g,skillName:y,pluginName:M.pluginName??null,skillMdPath:M.skillMdPath}),r()}catch(H){L(H instanceof Error?H.message:String(H))}finally{D(!1)}}return a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),a.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[a.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:f==="destination"?"Create a skill":"Name and describe"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",f==="destination"?"1":"2"," of 2"]})]}),f==="destination"&&a.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx(Ud,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),a.jsx(Ud,{title:"Add to existing plugin",subtitle:C?`${w.length} plugin source${w.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!C,selected:g==="existing-plugin",onClick:()=>C&&p("existing-plugin")}),a.jsx(Ud,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),f==="details"&&a.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&a.jsx(yo,{label:"Plugin name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:j,onChange:H=>S(H.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:bo(!j||_)})}),g==="existing-plugin"&&a.jsx(yo,{label:"Plugin",children:a.jsxs("select",{value:j,onChange:H=>S(H.target.value),style:{...bo(!0),fontFamily:"var(--font-mono)"},children:[a.jsx("option",{value:"",children:"Select a plugin…"}),w.map(H=>a.jsx("option",{value:H.name,children:H.name},H.path))]})}),a.jsx(yo,{label:"Skill name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:y,onChange:H=>v(H.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:bo(!y||T)})}),a.jsx(yo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:a.jsx("textarea",{value:k,onChange:H=>E(H.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...bo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),K&&a.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),K.map((H,M)=>a.jsx("div",{children:H},M))]}),U&&a.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:U})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[a.jsx("button",{type:"button",onClick:r,style:$d,children:"Cancel"}),f==="destination"&&a.jsx("button",{type:"button",onClick:()=>h("details"),style:Xg,children:"Continue →"}),f==="details"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>h("destination"),style:$d,children:"← Back"}),a.jsx("button",{type:"button",onClick:()=>void Q(),disabled:!I,style:{...$d,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"✨ Generate with AI"}),a.jsx("button",{type:"button",onClick:()=>void q(),disabled:!I,style:{...Xg,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:A?"Creating…":"Create empty scaffold"})]})]})]})]})}function Ud({title:t,subtitle:r,description:s,icon:o,selected:c,disabled:u,onClick:f}){return a.jsxs("button",{type:"button",onClick:f,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function yo({label:t,hint:r,children:s}){return a.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),r&&a.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),s]})}function bo(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 Xg={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"},$d={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 UN(t,r,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",f=t||"<project>";return r==="standalone"?[`${f}/skills/${c}/SKILL.md`]:r==="existing-plugin"?[`${f}/${u}/skills/${c}/SKILL.md`]:r==="new-plugin"?[`${f}/${u}/.claude-plugin/plugin.json`,`${f}/${u}/skills/${c}/SKILL.md`]:null}function $N({open:t,onClose:r,onInstall:s,installedNames:o}){const[c,u]=x.useState([]),[f,h]=x.useState(null),[g,p]=x.useState(null),[y,v]=x.useState(!1),[j,S]=x.useState(null);return x.useEffect(()=>{t&&(v(!0),S(null),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);u(k.marketplaces??[])}).catch(k=>S(k instanceof Error?k.message:String(k))).finally(()=>v(!1)))},[t]),x.useEffect(()=>{if(!f){p(null);return}v(!0),S(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(f)}`).then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);p(k)}).catch(k=>S(k instanceof Error?k.message:String(k))).finally(()=>v(!1))},[f]),x.useEffect(()=>{if(!t)return;function k(E){E.key==="Escape"&&r()}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[t,r]),t?a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),a.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[f&&a.jsx("button",{type:"button",onClick:()=>h(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),a.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:f?(g==null?void 0:g.name)??f:"Browse plugins"}),a.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[y&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),j&&a.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:j}),!f&&!y&&c.length===0&&!j&&a.jsx(VN,{}),!f&&c.map(k=>a.jsxs("button",{type:"button",onClick:()=>h(k.name),style:FN,onMouseEnter:E=>{E.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:E=>{E.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:k.name}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.source})]},k.name)),f&&g&&a.jsxs(a.Fragment,{children:[g.description&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:g.description}),g.plugins.length===0&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),g.plugins.map(k=>{const E=o.has(k.name);return a.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:a.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[k.name,k.version&&a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:k.version}),k.category&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:k.category})]}),k.description&&a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:k.description})]}),a.jsx("button",{type:"button",disabled:E,onClick:()=>s(k.name,f),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:E?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:E?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:E?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:E?"default":"pointer",fontFamily:"inherit",boxShadow:E?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:E?"Installed":"Install"})]})},k.name)})]})]}),!f&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:a.jsx(PN,{onAdded:()=>{sn("marketplaces"),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>u(k.marketplaces??[]))}})})]})]}):null}function VN(){return a.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",a.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[a.jsx("li",{children:a.jsx("code",{children:"anthropics/claude-plugins-official"})}),a.jsx("li",{children:a.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function PN({onAdded:t}){const[r,s]=x.useState(""),[o,c]=x.useState(!1),[u,f]=x.useState(null);async function h(){const g=r.trim();if(g){c(!0),f(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){f(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){f(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{type:"text",value:r,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!r.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!r.trim()?"not-allowed":"pointer",opacity:o||!r.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const FN={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Vd=12;function GN({job:t,onDone:r}){const[s,o]=x.useState([]),[c,u]=x.useState("running"),[f,h]=x.useState(!1);if(x.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let j=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),r({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),w=new TextDecoder;let N="";for(;;){const{value:A,done:D}=await E.read();if(D)break;N+=w.decode(A,{stream:!0});const U=N.split(/\n\n/);N=U.pop()??"";for(const L of U){const F=L.match(/^data:\s*(.*)$/m);if(F)try{const C=JSON.parse(F[1]);C.type==="stdout"&&C.line?(j=[...j,C.line].slice(-Vd),o(j)):C.type==="stderr"&&C.line?(j=[...j,`⚠ ${C.line}`].slice(-Vd),o(j)):C.type==="done"?(S=C.ok?"ok":"failed",u(S),sn("plugins"),sn("skills"),r({ok:C.ok??!1,code:C.code??null,lines:j})):C.type==="error"&&C.error&&(j=[...j,`✘ ${C.error}`].slice(-Vd),o(j))}catch{}}}S==="running"&&r({ok:!0,code:0,lines:j})}catch(k){if(k.name==="AbortError")return;u("failed"),r({ok:!1,code:null,lines:[...j,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return a.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[a.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?a.jsx(WN,{}):p}),a.jsxs("span",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!f&&s.length>0&&a.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:f?"▾":"▸"})]}),f&&a.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
+ `)})]})}function WN(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const YN=3e3,qN={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Qg(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function KN(){const{toast:t}=Yo(),r=x.useRef(new Map),s=x.useCallback(o=>{if(!Qg(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<YN)return;r.current.set(o.provider,c);const f=qN[o.provider];t({message:`${f} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return x.useEffect(()=>{function o(c){const u=c.detail;!u||!Qg(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Oy="vskill.studio.prefs";function By(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Iy(){const t=By();if(!t)return{};try{const r=t.getItem(Oy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function XN(t,r){const s=By();if(s)try{const c={...Iy(),[t]:r};s.setItem(Oy,JSON.stringify(c))}catch{}}function QN(t,r){const o=Iy()[t];return o===void 0?r:o}const Zg={open:!1,x:0,y:0,skill:null};function ZN(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function Ar(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function JN(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function eT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{Ar(ne.toasts.permissionDenied,"error");return}Ar(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ar(ne.actions.editPlaceholder,"info");return;case"run-benchmark":Ar(ne.toasts.benchmarkQueued,"info");return;case"duplicate":Ar(ne.toasts.skillDuplicated,"info");return;case"update":Ar(ne.toasts.skillUpdated,"info");return;case"uninstall":Ar(ne.actions.editPlaceholder,"info");return;case"delete":JN(r);return;default:return}}const tT=x.lazy(()=>Io(()=>import("./CommandPalette-COqdrmRl.js"),__vite__mapDeps([2,1]))),nT=x.lazy(()=>Io(()=>import("./CreateSkillPage-C3IjO8es.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage})));function aT(){const[t,r]=x.useState(()=>typeof window<"u"&&window.location.hash.startsWith("#/create"));return x.useEffect(()=>{function s(){r(window.location.hash.startsWith("#/create"))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),t}function rT(){return a.jsx(i2,{children:a.jsx(r2,{children:a.jsxs(HC,{children:[a.jsx(lT,{}),a.jsx(tN,{})]})})})}function lT(){var Qe,xt;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:f}=Kn(),{config:h}=_r(),{mode:g,resolvedTheme:p,setTheme:y}=Nv(),{toast:v}=Yo(),[j,S]=x.useState(()=>Sw()),[k]=x.useState(!0),[E,w]=x.useState(!1),[N,A]=x.useState(!1),[D,U]=x.useState(!1),[L,F]=x.useState("overview"),[C,O]=x.useState(Zg),T=x.useCallback((J,Te)=>{O(ZN(J,Te))},[]),_=RN(),[I,K]=x.useState(()=>QN("activeAgent",null));x.useEffect(()=>{var J;!I&&((J=_.response)!=null&&J.suggested)&&K(_.response.suggested)},[I,(Qe=_.response)==null?void 0:Qe.suggested]);const Q=x.useCallback(J=>{K(J),XN("activeAgent",J),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:J}}))},[]),q=x.useMemo(()=>_.response?kN(_.response):[],[_.response]),{workspace:H,switchProject:M,addProject:B,removeProject:V,activeProject:W}=_N(),[de,z]=x.useState(!1),[P,te]=x.useState(!1),[le,xe]=x.useState("standalone"),ce=x.useCallback((J="standalone")=>{xe(J),te(!0)},[]);x.useEffect(()=>{function J(Te){if(!(Te instanceof CustomEvent))return;const Pe=Te.detail;ce((Pe==null?void 0:Pe.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",J),()=>window.removeEventListener("studio:request-create-skill",J)},[ce]);const[ve,ue]=x.useState(!1),[ye,Ne]=x.useState(null);x.useEffect(()=>{function J(){ue(!0)}return window.addEventListener("studio:open-marketplace",J),()=>window.removeEventListener("studio:open-marketplace",J)},[]);const Me=x.useMemo(()=>{const J=new Set;for(const Te of t.skills)Te.source==="plugin"&&Te.pluginName&&J.add(Te.pluginName);return J},[t.skills]);Jd([{key:"p",meta:!0,handler:J=>{var Pe;const Te=typeof document<"u"?document.activeElement:null;Te&&Te.tagName==="INPUT"||((Pe=J==null?void 0:J.preventDefault)==null||Pe.call(J),z(en=>!en))}}],{enabled:!0});const re=mN();x.useEffect(()=>{function J(Te){if(!(Te instanceof CustomEvent))return;const Pe=Te.detail;Pe!=null&&Pe.provider&&re.open(Pe.provider)}return window.addEventListener("studio:open-setup-drawer",J),()=>window.removeEventListener("studio:open-setup-drawer",J)},[re]);const fe=x.useCallback(()=>{O(Zg)},[]);x.useEffect(()=>{function J(Te){if(!(Te instanceof CustomEvent))return;const Pe=Te.detail;Pe!=null&&Pe.message&&v({message:Pe.message,severity:Pe.severity??"info"})}return window.addEventListener("studio:toast",J),()=>window.removeEventListener("studio:toast",J)},[v]),KN();const[me,he]=x.useState(!1),[be,_e]=x.useState(void 0);x.useEffect(()=>{function J(Te){if(!(Te instanceof CustomEvent))return;const Pe=Te.detail;_e(Pe==null?void 0:Pe.provider),he(!0)}return window.addEventListener("studio:open-settings",J),()=>window.removeEventListener("studio:open-settings",J)},[]),x.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${j}px`)},[j]);const De=x.useMemo(()=>t.selectedSkill?t.skills.find(J=>J.plugin===t.selectedSkill.plugin&&J.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),pt=x.useCallback(J=>{r({plugin:J.plugin,skill:J.skill,origin:J.origin})},[r]),_t=x.useMemo(()=>{if(!t.selectedSkill)return"";const J=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${J})`},[t.selectedSkill]),mt=x.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>U(J=>!J)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>A(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);Jd([{key:"cmd+k",handler:()=>w(J=>!J)},{key:"ctrl+k",handler:()=>w(J=>!J)},{key:"?",handler:()=>A(J=>!J)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>U(J=>!J)},{key:"ctrl+b",handler:()=>U(J=>!J)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const ht=aT()?a.jsx(x.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(nT,{})}):a.jsx(YC,{selectedSkillInfo:De,activeDetailTab:L,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:pt});return a.jsxs(a.Fragment,{children:[a.jsx(o2,{sidebarWidth:j,sidebarHidden:D||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Ew,{connected:k}),liveMessage:_t,topRail:a.jsx(lS,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>w(!0),onHome:s,onRequestCreateSkill:()=>ce("standalone"),projectPickerSlot:H&&H.projects.length>0?a.jsx(ON,{workspace:H,onSwitch:M,onAdd:B,onRemove:V}):void 0}),sidebar:a.jsx(mw,{skills:t.skills,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:pt,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:T,outdatedByOrigin:c,activeAgentId:I,revealSkillId:t.revealSkillId,onRevealComplete:f,topSlot:_.status==="ready"&&q.length>0?a.jsxs(a.Fragment,{children:[a.jsx(wN,{agents:q,activeAgentId:I,onActiveAgentChange:Q,onOpenSetup:J=>re.open(J)}),a.jsx(TN,{activeAgentId:I})]}):null}),resizeHandle:a.jsx(ww,{initialWidth:j??_s,onChange:S}),main:ht,statusBar:a.jsx(xS,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(xt=h==null?void 0:h.providers)==null?void 0:xt.map(J=>{const Te=J.id;return{id:Te,label:J.label,available:J.available,kind:Te==="ollama"||Te==="lm-studio"?"start-service":Te==="anthropic"||Te==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(aN,{open:N,onClose:()=>A(!1)}),a.jsx(oN,{open:re.isOpen,providerKey:re.providerKey,onClose:re.close}),a.jsx(lN,{state:C,onClose:fe,onAction:(J,Te)=>eT(J,Te)}),E&&a.jsx(x.Suspense,{fallback:null,children:a.jsx(tT,{open:E,onClose:()=>w(!1),commands:mt})}),a.jsx(IN,{open:de,projects:(H==null?void 0:H.projects)??[],onSwitch:J=>{M(J)},onClose:()=>z(!1)}),a.jsx(HN,{open:P,onClose:()=>te(!1),initialMode:le,isClaudeCode:I==="claude-code",projectRoot:(W==null?void 0:W.path)??(h==null?void 0:h.projectName)??"",onCreated:J=>{o(),setTimeout(()=>{u(J.pluginName??"",J.skillName)},500)}}),a.jsx($N,{open:ve,onClose:()=>ue(!1),installedNames:Me,onInstall:(J,Te)=>{Ne({plugin:J,marketplace:Te,ref:`${J}@${Te}`}),ue(!1)}}),a.jsx(wv,{open:me,onClose:()=>he(!1),initialProvider:be,onToast:J=>v({message:J,severity:"info"})}),a.jsx(GN,{job:ye,onDone:J=>{J.ok&&setTimeout(()=>Ne(null),3e3)}})]})}const Jg="vskill.migrations.scope-rename.v1",sT={own:"authoring-project",installed:"available-project",global:"available-personal"},iT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function oT(t){if(t.getItem(Jg)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(iT);if(!c)continue;const[,u,f]=c,h=sT[f];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(Jg,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{oT(window.localStorage)}catch{}r0.createRoot(document.getElementById("root")).render(a.jsx(x.StrictMode,{children:a.jsx(Ej,{children:a.jsx(dS,{children:a.jsx(rT,{})})})}));export{Wo as E,vv as L,Xs as P,we as R,pC as S,_r as a,Iy as b,uC as c,Fo as d,QN as g,a as j,x as r,ne as s,lf as t,U0 as u,XN as w};