vskill 0.5.118 → 0.5.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents.json +1 -1
- package/dist/eval/skill-scanner.js +6 -2
- package/dist/eval/skill-scanner.js.map +1 -1
- package/dist/eval-ui/assets/{CommandPalette-ixp8tj0t.js → CommandPalette-BZekSSlW.js} +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-Df9oL8J-.js → CreateSkillPage-CJCr7_2R.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-CgTNXy-w.js → UpdateDropdown-C-4cwFXV.js} +1 -1
- package/dist/eval-ui/assets/{index-DU7vad_0.js → index-Ct_KvG1L.js} +4 -4
- package/dist/eval-ui/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-C-4cwFXV.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-BZekSSlW.js","assets/CreateSkillPage-CJCr7_2R.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
/* empty css */(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function lv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var od={exports:{}},Ts={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -59,10 +59,10 @@ Error generating stack: `+i.message+`
|
|
|
59
59
|
*/var _x="popstate";function Ox(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function p0(t={}){function r(c,u){let{pathname:d="/",search:h="",hash:g=""}=zl(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),Wd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,p=g.indexOf("#");h=p===-1?g:g.slice(0,p)}return h+"#"+(typeof u=="string"?u:Hs(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return h0(r,s,o,t)}function Ft(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function Zn(t,r){if(!t){typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}function m0(){return Math.random().toString(36).substring(2,10)}function Bx(t,r){return{usr:t.state,key:t.key,idx:r,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Wd(t,r,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof r=="string"?zl(r):r,state:s,key:r&&r.key||o||m0(),unstable_mask:c}}function Hs({pathname:t="/",search:r="",hash:s=""}){return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function zl(t){let r={};if(t){let s=t.indexOf("#");s>=0&&(r.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(r.search=t.substring(o),t=t.substring(0,o)),t&&(r.pathname=t)}return r}function h0(t,r,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,p=y();p==null&&(p=0,d.replaceState({...d.state,idx:p},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-p;p=C,g&&g({action:h,location:E.location,delta:N})}function b(C,N){h="PUSH";let T=Ox(C)?C:Wd(E.location,C,N);s&&s(T,C),p=y()+1;let A=Bx(T,p),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;c.location.assign(B)}u&&g&&g({action:h,location:E.location,delta:1})}function S(C,N){h="REPLACE";let T=Ox(C)?C:Wd(E.location,C,N);s&&s(T,C),p=y();let A=Bx(T,p),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&g&&g({action:h,location:E.location,delta:0})}function k(C){return x0(C)}let E={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(_x,v),g=C,()=>{c.removeEventListener(_x,v),g=null}},createHref(C){return r(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return E}function x0(t,r=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Ft(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Hs(t);return o=o.replace(/ $/,"%20"),!r&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function iv(t,r,s="/"){return g0(t,r,s,!1)}function g0(t,r,s,o){let c=typeof r=="string"?zl(r):r,u=Ma(c.pathname||"/",s);if(u==null)return null;let d=ov(t);v0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let p=R0(u);h=N0(d[g],p,o)}return h}function ov(t,r=[],s=[],o="",c=!1){let u=(d,h,g=c,p)=>{let y={relativePath:p===void 0?d.path||"":p,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Ft(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=ca([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Ft(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),ov(d.children,r,b,v,g)),!(d.path==null&&!d.index)&&r.push({path:v,score:C0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let p of cv(d.path))u(d,h,!0,p)}),r}function cv(t){let r=t.split("/");if(r.length===0)return[];let[s,...o]=r,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=cv(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function v0(t){t.sort((r,s)=>r.score!==s.score?s.score-r.score:E0(r.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var y0=/^:[\w-]+$/,b0=3,j0=2,S0=1,k0=10,w0=-2,Ix=t=>t==="*";function C0(t,r){let s=t.split("/"),o=s.length;return s.some(Ix)&&(o+=w0),r&&(o+=j0),s.filter(c=>!Ix(c)).reduce((c,u)=>c+(y0.test(u)?b0:u===""?S0:k0),o)}function E0(t,r){return t.length===r.length&&t.slice(0,-1).every((o,c)=>o===r[c])?t[t.length-1]-r[r.length-1]:0}function N0(t,r,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],p=h===o.length-1,y=u==="/"?r:r.slice(u.length)||"/",v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:p},y),b=g.route;if(!v&&p&&s&&!o[o.length-1].route.index&&(v=_o({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:ca([u,v.pathname]),pathnameBase:z0(ca([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=ca([u,v.pathnameBase]))}return d}function _o(t,r){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=T0(t.path,t.caseSensitive,t.end),c=r.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((p,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?p[y]=void 0:p[y]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:u,pathnameBase:d,pattern:t}}function T0(t,r=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,p,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(p+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,r?void 0:"i"),o]}function R0(t){try{return t.split("/").map(r=>decodeURIComponent(r).replace(/\//g,"%2F")).join("/")}catch(r){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${r}).`),t}}function Ma(t,r){if(r==="/")return t;if(!t.toLowerCase().startsWith(r.toLowerCase()))return null;let s=r.endsWith("/")?r.length-1:r.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var A0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function M0(t,r="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?zl(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Ux(s.substring(1),"/"):u=Ux(s,r)):u=r,{pathname:u,search:D0(o),hash:_0(c)}}function Ux(t,r){let s=r.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function md(t,r,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${r}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function L0(t){return t.filter((r,s)=>s===0||r.route.path&&r.route.path.length>0)}function uv(t){let r=L0(t);return r.map((s,o)=>o===r.length-1?s.pathname:s.pathnameBase)}function ff(t,r,s,o=!1){let c;typeof t=="string"?c=zl(t):(c={...t},Ft(!c.pathname||!c.pathname.includes("?"),md("?","pathname","search",c)),Ft(!c.pathname||!c.pathname.includes("#"),md("#","pathname","hash",c)),Ft(!c.search||!c.search.includes("#"),md("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=r.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?r[v]:"/"}let g=M0(c,h),p=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(p||y)&&(g.pathname+="/"),g}var ca=t=>t.join("/").replace(/\/\/+/g,"/"),z0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),D0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,_0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,O0=class{constructor(t,r,s,o=!1){this.status=t,this.statusText=r||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function B0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function I0(t){return t.map(r=>r.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var dv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function fv(t,r){let s=t;if(typeof s!="string"||!A0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(dv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Ma(d.pathname,r);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var pv=["POST","PUT","PATCH","DELETE"];new Set(pv);var U0=["GET",...pv];new Set(U0);var Dl=m.createContext(null);Dl.displayName="DataRouter";var $o=m.createContext(null);$o.displayName="DataRouterState";var H0=m.createContext(!1),mv=m.createContext({isTransitioning:!1});mv.displayName="ViewTransition";var $0=m.createContext(new Map);$0.displayName="Fetchers";var V0=m.createContext(null);V0.displayName="Await";var Gn=m.createContext(null);Gn.displayName="Navigation";var Vo=m.createContext(null);Vo.displayName="Location";var La=m.createContext({outlet:null,matches:[],isDataRoute:!1});La.displayName="Route";var pf=m.createContext(null);pf.displayName="RouteError";var hv="REACT_ROUTER_ERROR",P0="REDIRECT",F0="ROUTE_ERROR_RESPONSE";function G0(t){if(t.startsWith(`${hv}:${P0}:{`))try{let r=JSON.parse(t.slice(28));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string"&&typeof r.location=="string"&&typeof r.reloadDocument=="boolean"&&typeof r.replace=="boolean")return r}catch{}}function W0(t){if(t.startsWith(`${hv}:${F0}:{`))try{let r=JSON.parse(t.slice(40));if(typeof r=="object"&&r&&typeof r.status=="number"&&typeof r.statusText=="string")return new O0(r.status,r.statusText,r.data)}catch{}}function q0(t,{relative:r}={}){Ft(Ys(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=m.useContext(Gn),{hash:c,pathname:u,search:d}=Ks(t,{relative:r}),h=u;return s!=="/"&&(h=u==="/"?s:ca([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Ys(){return m.useContext(Vo)!=null}function or(){return Ft(Ys(),"useLocation() may be used only in the context of a <Router> component."),m.useContext(Vo).location}var xv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function gv(t){m.useContext(Gn).static||m.useLayoutEffect(t)}function Y0(){let{isDataRoute:t}=m.useContext(La);return t?ij():K0()}function K0(){Ft(Ys(),"useNavigate() may be used only in the context of a <Router> component.");let t=m.useContext(Dl),{basename:r,navigator:s}=m.useContext(Gn),{matches:o}=m.useContext(La),{pathname:c}=or(),u=JSON.stringify(uv(o)),d=m.useRef(!1);return gv(()=>{d.current=!0}),m.useCallback((g,p={})=>{if(Zn(d.current,xv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=ff(g,JSON.parse(u),c,p.relative==="path");t==null&&r!=="/"&&(y.pathname=y.pathname==="/"?r:ca([r,y.pathname])),(p.replace?s.replace:s.push)(y,p.state,p)},[r,s,u,c,t])}m.createContext(null);function Ks(t,{relative:r}={}){let{matches:s}=m.useContext(La),{pathname:o}=or(),c=JSON.stringify(uv(s));return m.useMemo(()=>ff(t,JSON.parse(c),o,r==="path"),[t,c,o,r])}function X0(t,r,s){Ft(Ys(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=m.useContext(Gn),{matches:c}=m.useContext(La),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",p=u&&u.route;{let C=p&&p.path||"";yv(h,!p||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
60
60
|
|
|
61
61
|
Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=or(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=iv(t,{pathname:S});return Zn(p||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),tj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:ca([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:ca([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function Q0(){let t=sj(),r=B0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=m.createElement(m.Fragment,null,m.createElement("p",null,"💿 Hey developer 👋"),m.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",m.createElement("code",{style:u},"ErrorBoundary")," or"," ",m.createElement("code",{style:u},"errorElement")," prop on your route.")),m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},r),s?m.createElement("pre",{style:c},s):null,d)}var Z0=m.createElement(Q0,null),vv=class extends m.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){this.props.onError?this.props.onError(t,r):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=W0(t.digest);s&&(t=s)}let r=t!==void 0?m.createElement(La.Provider,{value:this.props.routeContext},m.createElement(pf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?m.createElement(J0,{error:t},r):r}};vv.contextType=H0;var hd=new WeakMap;function J0({children:t,error:r}){let{basename:s}=m.useContext(Gn);if(typeof r=="object"&&r&&"digest"in r&&typeof r.digest=="string"){let o=G0(r.digest);if(o){let c=hd.get(r);if(c)throw c;let u=fv(o.location,s);if(dv&&!hd.get(r))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw hd.set(r,d),d}return m.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function ej({routeContext:t,match:r,children:s}){let o=m.useContext(Dl);return o&&o.static&&o.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=r.route.id),m.createElement(La.Provider,{value:t},s)}function tj(t,r=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(r.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,p=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:I0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,E=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||Z0,d&&(h<0&&b===0?(yv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=r.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:k?A=C:v.route.Component?A=m.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,m.createElement(ej,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?m.createElement(vv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:p}):T()},null)}function mf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nj(t){let r=m.useContext(Dl);return Ft(r,mf(t)),r}function aj(t){let r=m.useContext($o);return Ft(r,mf(t)),r}function rj(t){let r=m.useContext(La);return Ft(r,mf(t)),r}function hf(t){let r=rj(t),s=r.matches[r.matches.length-1];return Ft(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function lj(){return hf("useRouteId")}function sj(){var o;let t=m.useContext(pf),r=aj("useRouteError"),s=hf("useRouteError");return t!==void 0?t:(o=r.errors)==null?void 0:o[s]}function ij(){let{router:t}=nj("useNavigate"),r=hf("useNavigate"),s=m.useRef(!1);return gv(()=>{s.current=!0}),m.useCallback(async(c,u={})=>{Zn(s.current,xv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:r,...u}))},[t,r])}var Hx={};function yv(t,r,s){!r&&!Hx[t]&&(Hx[t]=!0,Zn(!1,s))}m.memo(oj);function oj({routes:t,future:r,state:s,isStatic:o,onError:c}){return X0(t,void 0,{state:s,isStatic:o,onError:c})}function cj({basename:t="/",children:r=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Ft(!Ys(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=m.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=zl(s));let{pathname:p="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,E=m.useMemo(()=>{let C=Ma(p,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,p,y,v,b,S,o,k]);return Zn(E!=null,`<Router basename="${h}"> is not able to match the URL "${p}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:m.createElement(Gn.Provider,{value:g},m.createElement(Vo.Provider,{children:r,value:E}))}var To="get",Ro="application/x-www-form-urlencoded";function Po(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function uj(t){return Po(t)&&t.tagName.toLowerCase()==="button"}function dj(t){return Po(t)&&t.tagName.toLowerCase()==="form"}function fj(t){return Po(t)&&t.tagName.toLowerCase()==="input"}function pj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function mj(t,r){return t.button===0&&(!r||r==="_self")&&!pj(t)}var go=null;function hj(){if(go===null)try{new FormData(document.createElement("form"),0),go=!1}catch{go=!0}return go}var xj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function xd(t){return t!=null&&!xj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ro}"`),null):t}function gj(t,r){let s,o,c,u,d;if(dj(t)){let h=t.getAttribute("action");o=h?Ma(h,r):null,s=t.getAttribute("method")||To,c=xd(t.getAttribute("enctype"))||Ro,u=new FormData(t)}else if(uj(t)||fj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Ma(g,r):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||To,c=xd(t.getAttribute("formenctype"))||xd(h.getAttribute("enctype"))||Ro,u=new FormData(h,t),!hj()){let{name:p,type:y,value:v}=t;if(y==="image"){let b=p?`${p}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else p&&u.append(p,v)}}else{if(Po(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=To,o=null,c=Ro,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function xf(t,r){if(t===!1||t===null||typeof t>"u")throw new Error(r)}function vj(t,r,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:r&&Ma(c.pathname,r)==="/"?c.pathname=`${r.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function yj(t,r){if(t.id in r)return r[t.id];try{let s=await import(t.module);return r[t.id]=s,s}catch(s){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function bj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function jj(t,r,s){let o=await Promise.all(t.map(async c=>{let u=r.routes[c.route.id];if(u){let d=await yj(u,s);return d.links?d.links():[]}return[]}));return Cj(o.flat(1).filter(bj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function $x(t,r,s,o,c,u){let d=(g,p)=>s[p]?g.route.id!==s[p].route.id:!0,h=(g,p)=>{var y;return s[p].pathname!==g.pathname||((y=s[p].route.path)==null?void 0:y.endsWith("*"))&&s[p].params["*"]!==g.params["*"]};return u==="assets"?r.filter((g,p)=>d(g,p)||h(g,p)):u==="data"?r.filter((g,p)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,p)||h(g,p))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Sj(t,r,{includeHydrateFallback:s}={}){return kj(t.map(o=>{let c=r.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function kj(t){return[...new Set(t)]}function wj(t){let r={},s=Object.keys(t).sort();for(let o of s)r[o]=t[o];return r}function Cj(t,r){let s=new Set;return new Set(r),t.reduce((o,c)=>{let u=JSON.stringify(wj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function bv(){let t=m.useContext(Dl);return xf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Ej(){let t=m.useContext($o);return xf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var gf=m.createContext(void 0);gf.displayName="FrameworkContext";function jv(){let t=m.useContext(gf);return xf(t,"You must render this element inside a <HydratedRouter> element"),t}function Nj(t,r){let s=m.useContext(gf),[o,c]=m.useState(!1),[u,d]=m.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:p,onMouseLeave:y,onTouchStart:v}=r,b=m.useRef(null);m.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),m.useEffect(()=>{if(o){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:As(h,S),onBlur:As(g,k),onMouseEnter:As(p,S),onMouseLeave:As(y,k),onTouchStart:As(v,S)}]:[!1,b,{}]}function As(t,r){return s=>{t&&t(s),s.defaultPrevented||r(s)}}function Tj({page:t,...r}){let{router:s}=bv(),o=m.useMemo(()=>iv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?m.createElement(Aj,{page:t,matches:o,...r}):null}function Rj(t){let{manifest:r,routeModules:s}=jv(),[o,c]=m.useState([]);return m.useEffect(()=>{let u=!1;return jj(t,r,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,r,s]),o}function Aj({page:t,matches:r,...s}){let o=or(),{future:c,manifest:u,routeModules:d}=jv(),{basename:h}=bv(),{loaderData:g,matches:p}=Ej(),y=m.useMemo(()=>$x(t,r,p,u,o,"data"),[t,r,p,u,o]),v=m.useMemo(()=>$x(t,r,p,u,o,"assets"),[t,r,p,u,o]),b=m.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,C=!1;if(r.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!y.some(D=>D.route.id===T.route.id)&&T.route.id in g&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?C=!0:E.add(T.route.id))}),E.size===0)return[];let N=vj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&E.size>0&&N.searchParams.set("_routes",r.filter(T=>E.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,r,t,d]),S=m.useMemo(()=>Sj(v,u),[v,u]),k=Rj(v);return m.createElement(m.Fragment,null,b.map(E=>m.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>m.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:C})=>m.createElement("link",{key:E,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Mj(...t){return r=>{t.forEach(s=>{typeof s=="function"?s(r):s!=null&&(s.current=r)})}}var Lj=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Lj&&(window.__reactRouterVersion="7.13.1")}catch{}function zj({basename:t,children:r,unstable_useTransitions:s,window:o}){let c=m.useRef();c.current==null&&(c.current=p0({window:o,v5Compat:!0}));let u=c.current,[d,h]=m.useState({action:u.action,location:u.location}),g=m.useCallback(p=>{s===!1?h(p):m.startTransition(()=>h(p))},[s]);return m.useLayoutEffect(()=>u.listen(g),[u,g]),m.createElement(cj,{basename:t,children:r,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Sv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,kv=m.forwardRef(function({onClick:r,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:p,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},E){let{basename:C,navigator:N,unstable_useTransitions:T}=m.useContext(Gn),A=typeof y=="string"&&Sv.test(y),B=fv(y,C);y=B.to;let D=q0(y,{relative:c}),F=or(),w=null;if(h){let $=ff(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:ca([C,$.pathname])),w=N.createHref($)}let[O,z,U]=Nj(o,k),H=Bj(y,{replace:d,unstable_mask:h,state:g,target:p,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function q($){r&&r($),$.defaultPrevented||H($)}let X=!(B.isExternal||u),J=m.createElement("a",{...k,...U,href:(X?w:void 0)||B.absoluteURL||D,onClick:X?q:r,ref:Mj(E,z),target:p,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?m.createElement(m.Fragment,null,J,m.createElement(Tj,{page:D})):J});kv.displayName="Link";var Dj=m.forwardRef(function({"aria-current":r="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...p},y){let v=Ks(d,{relative:p.relative}),b=or(),S=m.useContext($o),{navigator:k,basename:E}=m.useContext(Gn),C=S!=null&&Vj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=b.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&E&&(A=Ma(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let D=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",F=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),w={isActive:D,isPending:F,isTransitioning:C},O=D?r:void 0,z;typeof o=="function"?z=o(w):z=[o,D?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(w):u;return m.createElement(kv,{...p,"aria-current":O,className:z,ref:y,style:U,to:d,viewTransition:h},typeof g=="function"?g(w):g)});Dj.displayName="NavLink";var _j=m.forwardRef(({discover:t="render",fetcherKey:r,navigate:s,reloadDocument:o,replace:c,state:u,method:d=To,action:h,onSubmit:g,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:E}=m.useContext(Gn),C=Hj(),N=$j(h,{relative:p}),T=d.toLowerCase()==="get"?"get":"post",A=typeof h=="string"&&Sv.test(h),B=D=>{if(g&&g(D),D.defaultPrevented)return;D.preventDefault();let F=D.nativeEvent.submitter,w=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>C(F||D.currentTarget,{fetcherKey:r,method:w,navigate:s,replace:c,state:u,relative:p,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});E&&s!==!1?m.startTransition(()=>O()):O()};return m.createElement("form",{ref:k,method:T,action:N,onSubmit:o?g:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});_j.displayName="Form";function Oj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wv(t){let r=m.useContext(Dl);return Ft(r,Oj(t)),r}function Bj(t,{target:r,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:p}={}){let y=Y0(),v=or(),b=Ks(t,{relative:d});return m.useCallback(S=>{if(mj(S,r)){S.preventDefault();let k=s!==void 0?s:Hs(v)===Hs(b),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});p?m.startTransition(()=>E()):E()}},[v,y,b,s,o,c,r,t,u,d,h,g,p])}var Ij=0,Uj=()=>`__${String(++Ij)}__`;function Hj(){let{router:t}=wv("useSubmit"),{basename:r}=m.useContext(Gn),s=lj(),o=t.fetch,c=t.navigate;return m.useCallback(async(u,d={})=>{let{action:h,method:g,encType:p,formData:y,body:v}=gj(u,r);if(d.navigate===!1){let b=d.fetcherKey||Uj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||p,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,r,s])}function $j(t,{relative:r}={}){let{basename:s}=m.useContext(Gn),o=m.useContext(La);Ft(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Ks(t||".",{relative:r})},d=or();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:ca([s,u.pathname])),Hs(u)}function Vj(t,{relative:r}={}){let s=m.useContext(mv);Ft(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=wv("useViewTransitionState"),c=Ks(t,{relative:r});if(!s.isTransitioning)return!1;let u=Ma(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Ma(s.nextLocation.pathname,o)||s.nextLocation.pathname;return _o(c.pathname,d)!=null||_o(c.pathname,u)!=null}var Fo=sv();const Pj=lv(Fo),Fj="modulepreload",Gj=function(t){return"/"+t},Vx={},Xs=function(r,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(p){return Promise.all(p.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(p=>{if(p=Gj(p),p in Vx)return;Vx[p]=!0;const y=p.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":Fj,y||(b.as="script"),b.crossOrigin="",b.href=p,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${p}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})},Px={own:"authoring-project",installed:"available-project",global:"available-personal"},qd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Wj(t){if(typeof t=="string"){if(qd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Px,t))return Px[t]}return"authoring-project"}function qj(t){return t.startsWith("available-")?"available":"authoring"}function Yj(t){const r=t.indexOf("-");return t.slice(r+1)}const Vn="";class Os extends Error{constructor(r,s){super(r),this.name="ApiError",this.status=s}}async function $e(t,r){const s=await fetch(`${Vn}${t}`,r);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function Jt(t){return typeof t=="string"&&t.length>0?t:null}function Kj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function gd(t){if(!Array.isArray(t))return null;const r=t.filter(s=>typeof s=="string"&&s.length>0);return r.length>0?r:null}function Xj(t){const r=t??{};let s;r.origin==="source"||r.origin==="installed"?s=r.origin:(s="source",console.warn(`[api.getSkills] skill ${String(r.plugin)}/${String(r.skill)} has invalid origin=${JSON.stringify(r.origin)}; defaulting to 'source'`));let o;r.scope==="own"||r.scope==="installed"||r.scope==="global"?o=r.scope:o=s==="installed"?"installed":"own";let c;r.installMethod==="authored"||r.installMethod==="copied"||r.installMethod==="symlinked"?c=r.installMethod:c=o==="own"?"authored":"copied";const u=typeof r.scopeV2=="string"&&qd.has(r.scopeV2)?r.scopeV2:Wj(r.scope),d=qj(u),h=Yj(u),g=typeof r.precedenceRank=="number"?r.precedenceRank:void 0;let p;r.shadowedBy===null?p=null:typeof r.shadowedBy=="string"&&qd.has(r.shadowedBy)?p=r.shadowedBy:p=void 0;const y={plugin:typeof r.plugin=="string"?r.plugin:"",skill:typeof r.skill=="string"?r.skill:"",dir:typeof r.dir=="string"?r.dir:"",hasEvals:!!r.hasEvals,hasBenchmark:!!r.hasBenchmark,evalCount:typeof r.evalCount=="number"?r.evalCount:0,assertionCount:typeof r.assertionCount=="number"?r.assertionCount:0,benchmarkStatus:r.benchmarkStatus==="pass"||r.benchmarkStatus==="fail"||r.benchmarkStatus==="pending"||r.benchmarkStatus==="stale"||r.benchmarkStatus==="missing"?r.benchmarkStatus:"missing",lastBenchmark:typeof r.lastBenchmark=="string"?r.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof r.isSymlink=="boolean"?r.isSymlink:!1,symlinkTarget:Jt(r.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:Jt(r.pluginName),pluginNamespace:Jt(r.pluginNamespace),pluginMarketplace:Jt(r.pluginMarketplace),pluginManifestPath:Jt(r.pluginManifestPath),pluginVersion:Jt(r.pluginVersion),precedenceRank:g,shadowedBy:p,description:Jt(r.description),version:Jt(r.version),category:Jt(r.category),author:Jt(r.author),license:Jt(r.license),homepage:Jt(r.homepage),repoUrl:Jt(r.repoUrl),skillPath:Jt(r.skillPath),tags:gd(r.tags),deps:gd(r.deps),mcpDeps:gd(r.mcpDeps),entryPoint:Jt(r.entryPoint),lastModified:Jt(r.lastModified),sizeBytes:Kj(r.sizeBytes),sourceAgent:Jt(r.sourceAgent)};if(r.provenance&&typeof r.provenance=="object"){const v=r.provenance;(v.promotedFrom==="installed"||v.promotedFrom==="global")&&typeof v.sourcePath=="string"&&typeof v.promotedAt=="number"?y.provenance={promotedFrom:v.promotedFrom,sourcePath:v.sourcePath,promotedAt:v.promotedAt,sourceSkillVersion:typeof v.sourceSkillVersion=="string"?v.sourceSkillVersion:void 0}:y.provenance=null}else r.provenance===null&&(y.provenance=null);return typeof r.updateAvailable=="boolean"&&(y.updateAvailable=r.updateAvailable),typeof r.currentVersion=="string"&&(y.currentVersion=r.currentVersion),typeof r.latestVersion=="string"&&(y.latestVersion=r.latestVersion),typeof r.pinnedVersion=="string"&&(y.pinnedVersion=r.pinnedVersion),y}const Ce={getConfig(){return $e("/api/config")},setConfig(t,r){return $e("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:r})})},async getSkills(t){const r=new URLSearchParams;t!=null&&t.scope&&r.set("scope",t.scope),t!=null&&t.agent&&r.set("agent",t.agent);const s=r.toString(),o=await $e(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(Xj):[]},getAgents(){return $e("/api/agents")},getSkillDetail(t,r){return $e(`/api/skills/${t}/${r}`)},async getEvals(t,r){const s=await $e(`/api/skills/${t}/${r}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:r,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/evals`)},getActivationHistoryEnvelope(t,r){return $e(`/api/skills/${t}/${r}/activation-history`)},saveEvals(t,r,s){return $e(`/api/skills/${t}/${r}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,r){return $e(`/api/skills/${t}/${r}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,r){const s=await fetch(`${Vn}/api/skills/${t}/${r}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Os(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,r,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return $e(`/api/skills/${t}/${r}/history${c?"?"+c:""}`)},getHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`)},compareRuns(t,r,s,o){return $e(`/api/skills/${t}/${r}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,r,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return $e(`/api/skills/${t}/${r}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,r,s){return $e(`/api/skills/${t}/${r}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,r){return $e(`/api/skills/${t}/${r}`,{method:"DELETE"})},improveSkill(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,r,s){return $e(`/api/skills/${t}/${r}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,r,s){return $e(`/api/skills/${t}/${r}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,r){return $e(`/api/skills/${t}/${r}/stats`)},getDependencies(t,r){return $e(`/api/skills/${t}/${r}/dependencies`)},getProjectLayout(){return $e("/api/project-layout")},createSkill(t){return $e("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return $e("/api/studio/detect-engines")},saveDraft(t){return $e("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return $e("/api/skill-creator-status")},generateSkill(t){return $e("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,r){return $e(`/api/skills/${t}/${r}/files`)},getSkillFile(t,r,s){return $e(`/api/skills/${t}/${r}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,r,s,o){return $e(`/api/skills/${t}/${r}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,r){return $e(`/api/skills/${t}/${r}/leaderboard`)},getLeaderboardEntry(t,r,s){return $e(`/api/skills/${t}/${r}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,r){return $e(`/api/credentials/${t}/${r}`)},setCredential(t,r,s,o){return $e(`/api/credentials/${t}/${r}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,r){return $e(`/api/credentials/${t}/${r}/params`)},getParamsRevealed(t,r,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return $e(`/api/credentials/${t}/${r}/params?${o}`)},searchModels(){return $e("/api/openrouter/models")},async getSkillVersions(t,r){const s=await $e(`/api/skills/${t}/${r}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,r){return $e(`/api/skills/${t}/${r}/versions`)},getVersionDiff(t,r,s,o){return $e(`/api/skills/${t}/${r}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const r=`${Vn}/api/skills/batch-update`,s=new EventSource(r);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,r){const s=`${Vn}/api/skills/${t}/${r}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,r,s){const o=`${Vn}/api/skills/${t}/${r}/update`,c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},signal:s});let u,d="";if(c.body){const h=c.body.getReader(),g=new TextDecoder;let p=!1,y="";for(;!p;){const b=await h.read();if(p=b.done,b.value){const S=g.decode(b.value,{stream:!p});y+=S,d.length<200&&(d+=S)}}const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{u=JSON.parse(v[1]).version}catch{}d=d.slice(0,200)}else{const h=await c.text();d=h.slice(0,200);const g=h.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(g)try{u=JSON.parse(g[1]).version}catch{}}return{ok:c.ok,status:c.status,body:d,version:u}},async rescanSkill(t,r){const s=`${t}/${r}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:[...t].sort()})});if(!r.ok)return[];const s=await r.json().catch(()=>null);return Array.isArray(s)?s:s&&typeof s=="object"&&Array.isArray(s.results)?s.results.map(o=>({skillId:typeof o.skillId=="string"?o.skillId:typeof o.name=="string"?o.name:"",version:typeof o.version=="string"?o.version:typeof o.latest=="string"?o.latest:"",eventId:typeof o.eventId=="string"?o.eventId:"",publishedAt:typeof o.publishedAt=="string"?o.publishedAt:"",diffSummary:typeof o.diffSummary=="string"?o.diffSummary:void 0,trackedForUpdates:typeof o.trackedForUpdates=="boolean"?o.trackedForUpdates:void 0,updateAvailable:typeof o.updateAvailable=="boolean"?o.updateAvailable:void 0,installed:typeof o.installed=="string"?o.installed:void 0,latest:typeof o.latest=="string"?o.latest:void 0,name:typeof o.name=="string"?o.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const r=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!r.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await r.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,r,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return vd(`/api/skills/${t}/${r}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,r,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return vd(`/api/skills/${t}/${r}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,r,s){return vd(`/api/skills/${t}/${r}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const r=new URLSearchParams;(t==null?void 0:t.before)!=null&&r.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&r.set("limit",String(t.limit));const s=r.toString();return $e(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return $e(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Vn}/api/studio/ops/stream`)}};async function vd(t,r,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Os(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,p=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
|
|
62
|
-
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};r==null||r(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Os(p.message,500);throw y.code=p.code,y}if(!g)throw new Os("Transfer stream ended without 'done' event",500);return g}function Qj(t,r){if(!r.length)return t;const s=new Map,o=new Map;for(const c of r){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Zj(t){const[r,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const Jj=500,Yd="vskill.updates.seenLastId";function eS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Yd)}catch{return null}}function yd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Yd):window.localStorage.setItem(Yd,t)}catch{}}function tS(){let t=new Map;const r=new Set,s=new Set,o=[];let c=eS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>Jj){const g=o.shift();g&&s.delete(g)}c=h,yd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,yd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,yd(null),u()}}}const Dr=tS(),nS=3e5,aS=500,rS=15e3,lS=6e4,sS=6e4,iS="/api/v1/skills/stream";function Fx(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Gx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function oS(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function cS(t){const r=(t==null?void 0:t.intervalMs)??nS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??rS,c=(t==null?void 0:t.staleAfterMs)??lS,u=(t==null?void 0:t.disconnectFallbackMs)??sS,d=(t==null?void 0:t.streamUrlBase)??iS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,k]=m.useState(0),[E,C]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),D=m.useRef(null),F=m.useRef(null),w=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[U,H]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(U);q.current=U;const X=m.useSyncExternalStore(M=>Dr.subscribe(M),()=>Dr.getSnapshot(),()=>Dr.getSnapshot()),J=X.size,$=m.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const W=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(W==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(W),b(Fx(W)),k(Gx(W)),F.current=Date.now(),T(F.current),B(null)}catch(W){if(!z.current)return;B(W instanceof Error?W:new Error(String(W)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=m.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=m.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},r))},[r,L]),I=m.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);m.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const W=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",W),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",W),O.current&&clearTimeout(O.current),I()}},[]);const V=m.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const W=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:W}));te.length>0&&Dr.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,re=ye.get(_e);if(re){const he={...re};re.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Fx(Se)),k(Gx(Se)),Se})}catch{}},[]);m.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),W=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let ge;try{ge=JSON.parse(pe.data)}catch{return}if(!oS(ge)||Dr.ingest(ge)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${ge.skillId} updated to ${ge.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}},re=()=>{z.current&&(Dr.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(W),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",re))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",re)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),m.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const se=m.useCallback(M=>{Dr.dismiss(M)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:se}}function uS(t){const r=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),r.push(u)}return r}const dS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function fS(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Cv=m.createContext(null),Ev=Cv;function ea(){const t=m.useContext(Ev);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function pS({children:t}){const[r,s]=m.useReducer(fS,dS),o=Zj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=m.useState(c!==null);m.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),m.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??se),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=m.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,W]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===W);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:W,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{g()},[g]);const p=m.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=m.useRef(r.skills);m.useEffect(()=>{y.current=r.skills},[r.skills]);const v=m.useCallback((I,V)=>{const se=y.current,M=I?se.find(te=>te.plugin===I&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,W=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:W}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=m.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=m.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[D,F]=m.useState(""),w=m.useMemo(()=>r.skills.map(I=>`${I.plugin}/${I.skill}`),[r.skills]),O=m.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=cS({skillIds:O,trackingSkillIds:w}),U=m.useRef("");m.useEffect(()=>{const I=r.skills.filter(W=>W.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const W of z.updates)V.set(W.name.split("/").pop()||W.name,W);const se=I.map(W=>{const te=V.get(W.skill);return{plugin:W.plugin,skill:W.skill,name:(te==null?void 0:te.name)??W.skill,currentVersion:W.currentVersion??(te==null?void 0:te.installed)??"0.0.0"}}),M=se.map(W=>`${W.plugin}/${W.skill}@${W.currentVersion}#${W.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(W=>{if(Y)return;const ie=[...uS(W).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(W.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(W=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=W instanceof Error?W.message:String(W);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[r.skills,z.updates]);const H=m.useMemo(()=>{const I=r.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Qj(I,z.updates)},[r.skills,z.updates]),q=m.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=m.useMemo(()=>({...r,skills:H}),[r,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=m.useMemo(()=>({state:X,selectSkill:p,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,p,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return a.jsx(Ev.Provider,{value:_,children:t})}const mS={config:null,loading:!0};function hS(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Nv=m.createContext(null);function Hr(){const t=m.useContext(Nv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function xS({children:t}){const[r,s]=m.useReducer(hS,mS),o=m.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(Nv.Provider,{value:u,children:t})}function gS({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:p,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Wx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],vS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},yS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},bS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},jS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function SS(t,r){var h,g;const s=vS[t.id]??null,o=yS[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:jS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:kS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:bS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function kS(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function wS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Wx){const c=r.get(o);c&&s.push(c)}for(const o of t)Wx.includes(o.id)||s.push(o);return s}function CS(t){const[r,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=wS((A.providers||[]).map(D=>SS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{p.current=T,T==="openrouter"&&k()},[k]),C=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:r,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:N}}function bd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Kd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const ES={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <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}`},NS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},TS={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},RS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},AS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},MS={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},LS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},zS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},DS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},_S={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},OS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},BS={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},IS={subscriptionBilling:"· subscription",free:"· free"},US={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},HS={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},$S={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},VS={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},PS={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},FS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},GS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},WS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:ES,shell:NS,detail:TS,actions:RS,palette:AS,shortcuts:MS,toasts:LS,connection:zS,forms:DS,errors:_S,picker:OS,providers:BS,models:IS,settings:US,statusBar:HS,scopePicker:$S,scopeSection:VS,claudeCodeLabel:PS,setupDrawer:FS,setupProviders:WS,scopeLabels:GS},qS=new Set(["claude-cli","claude-code"]);function qx(t){return qS.has(t)}const Yx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function YS({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Yx.has(g.id)),h=t.filter(g=>!Yx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Kx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=qx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),qx(t.id)&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Kd,{unlocked:!0,size:10}):a.jsx(Kd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(bd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(bd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(bd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function KS(t,r,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/r)-4),k=Math.ceil(s/r)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,r,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*r,offsetTop:v*r,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Tv=44,XS=352,QS=60,Xx=480;function ZS(t){var u,d;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function JS(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function e2({agent:t,activeModelId:r,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),QS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Xx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>JS(t.models,h),[t.models,h]),v=KS(y.length,Tv,XS);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Xx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:p,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),a.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):a.jsx("div",{...v.containerProps,children:a.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return a.jsx(n2,{model:b,isActive:b.id===r,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function t2(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function n2({model:t,isActive:r,isFocused:s,onSelect:o,resolvedModel:c}){const u=ZS(t),d=t2(t.id,c,t.resolvedId),h=d!==null,g=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Tv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Qx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,r]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();r({...Qx,...y}),u(null)}catch(p){u(p.message),r(Qx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function r2({onMigrated:t,fetchImpl:r}){const[s,o]=m.useState({kind:"loading"}),c=r??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:jd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...jd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...jd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const jd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},l2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function s2(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function Rv({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),r();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]);const b=m.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),a.jsx(r2,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),l2.map(S=>a.jsx(i2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Or,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function i2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[S,k]=m.useState(!1),[E,C]=m.useState(!1),[N,T]=m.useState(null),A=p.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=m.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>b(!v),style:Or,children:v?ne.settings.hide:ne.settings.show}),a.jsx("button",{type:"button",onClick:w,style:Or,children:ne.settings.paste})]}),D&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Zx,children:ne.settings.prefixWarn(r)}),N&&a.jsx("div",{role:"status",style:Zx,children:N}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Or,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:E?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Or,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>C(!1),style:Or,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Or,color:"var(--text-muted)"},children:ne.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(s2(u.updatedAt)):ne.settings.noKey})]})]})}const Or={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Zx={fontSize:11,color:"var(--warning, var(--text-muted))"};function o2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function c2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=CS({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[S,k]=m.useState("agents"),[E,C]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);m.useEffect(()=>{C(0)},[v]);const B=m.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=m.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);m.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),m.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=m.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[r,s,w,O]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:z})]}),u&&typeof document<"u"&&Fo.createPortal(a.jsxs(u2,{reducedMotion:o2(),onClickOutside:D,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx(YS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&a.jsx(e2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),a.jsx(Rv,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function u2({children:t,reducedMotion:r,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
62
|
+
`);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};r==null||r(E),E.type==="done"&&(g=E),E.type==="error"&&(p=E)}h=""}}if(p){const y=new Os(p.message,500);throw y.code=p.code,y}if(!g)throw new Os("Transfer stream ended without 'done' event",500);return g}function Qj(t,r){if(!r.length)return t;const s=new Map,o=new Map;for(const c of r){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};return typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates),d})}function Zj(t){const[r,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const Jj=500,Yd="vskill.updates.seenLastId";function eS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Yd)}catch{return null}}function yd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Yd):window.localStorage.setItem(Yd,t)}catch{}}function tS(){let t=new Map;const r=new Set,s=new Set,o=[];let c=eS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>Jj){const g=o.shift();g&&s.delete(g)}c=h,yd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,yd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,yd(null),u()}}}const Dr=tS(),nS=3e5,aS=500,rS=15e3,lS=6e4,sS=6e4,iS="/api/v1/skills/stream";function Fx(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Gx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function oS(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function cS(t){const r=(t==null?void 0:t.intervalMs)??nS,s=(t==null?void 0:t.debounceMs)??aS,o=(t==null?void 0:t.timeoutMs)??rS,c=(t==null?void 0:t.staleAfterMs)??lS,u=(t==null?void 0:t.disconnectFallbackMs)??sS,d=(t==null?void 0:t.streamUrlBase)??iS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,k]=m.useState(0),[E,C]=m.useState(!1),[N,T]=m.useState(null),[A,B]=m.useState(null),D=m.useRef(null),F=m.useRef(null),w=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[U,H]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(U);q.current=U;const X=m.useSyncExternalStore(M=>Dr.subscribe(M),()=>Dr.getSnapshot(),()=>Dr.getSnapshot()),J=X.size,$=m.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const W=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(W==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(W),b(Fx(W)),k(Gx(W)),F.current=Date.now(),T(F.current),B(null)}catch(W){if(!z.current)return;B(W instanceof Error?W:new Error(String(W)))}finally{clearTimeout(Y),z.current&&C(!1)}},[o]),L=m.useCallback(()=>{if(D.current)return D.current;const M=$().finally(()=>{D.current=null});return D.current=M,M},[$]),_=m.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},r))},[r,L]),I=m.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);m.useEffect(()=>{z.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const W=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",W),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",W),O.current&&clearTimeout(O.current),I()}},[]);const V=m.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!z.current||Y.length===0)return;const W=Date.now(),te=Y.filter(ie=>ie.skillId&&ie.eventId&&ie.version).map(ie=>({skillId:ie.skillId,version:ie.version,eventId:ie.eventId,publishedAt:ie.publishedAt,diffSummary:ie.diffSummary,receivedAt:W}));te.length>0&&Dr.mergeBulk(te);const fe=Y.filter(ie=>typeof ie.trackedForUpdates=="boolean"||typeof ie.updateAvailable=="boolean").map(ie=>({name:ie.name??ie.skillId,installed:ie.installed??"",latest:ie.latest??null,updateAvailable:ie.updateAvailable??!1,trackedForUpdates:typeof ie.trackedForUpdates=="boolean"?ie.trackedForUpdates:void 0}));fe.length>0&&y(ie=>{const ye=new Map;for(const Ae of ie)ye.set(Ae.name.split("/").pop()||Ae.name,Ae);let de=0;for(const Ae of fe){const _e=Ae.name.split("/").pop()||Ae.name,re=ye.get(_e);if(re){const he={...re};re.trackedForUpdates===void 0&&Ae.trackedForUpdates!==void 0&&(he.trackedForUpdates=Ae.trackedForUpdates),ye.set(_e,he)}else ye.set(_e,{name:Ae.name,installed:Ae.installed??"",latest:Ae.latest??null,updateAvailable:Ae.updateAvailable??!1,trackedForUpdates:Ae.trackedForUpdates}),de+=1}if(de===0&&ye.size===ie.length)return ie;const Se=[...ye.values()];return b(Fx(Se)),k(Gx(Se)),Se})}catch{}},[]);m.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),W=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,ie=null;const ye=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,z.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ye();const Se=1e3,Ae=()=>{z.current&&ie==null&&(ie=setTimeout(()=>{if(ie=null,!!z.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},Se))},_e=pe=>{if(!z.current)return;let ge;try{ge=JSON.parse(pe.data)}catch{return}if(!oS(ge)||Dr.ingest(ge)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${ge.skillId} updated to ${ge.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:ge.skillId,version:ge.version,eventId:ge.eventId}}))}},re=()=>{z.current&&(Dr.clearSeen(),V(Y))},he=()=>{z.current&&(te=new EventSource(W),te.onopen=()=>{z.current&&(de(),H("connected"))},te.onerror=()=>{z.current&&(ye(),te&&te.readyState===EventSource.CLOSED&&Ae())},te.onmessage=_e,te.addEventListener("gone",re))};return he(),()=>{if(de(),ie!=null&&(clearTimeout(ie),ie=null),te){try{te.removeEventListener("gone",re)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),m.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const se=m.useCallback(M=>{Dr.dismiss(M)},[]);return{updates:p,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:se}}function uS(t){const r=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),r.push(u)}return r}const dS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function fS(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Cv=m.createContext(null),Ev=Cv;function ea(){const t=m.useContext(Ev);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function pS({children:t}){const[r,s]=m.useReducer(fS,dS),o=Zj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=m.useState(c!==null);m.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const se=V.detail;se!=null&&se.agentId&&(u(se.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),m.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const se=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??se),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=m.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,W]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===W);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:W,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{g()},[g]);const p=m.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=m.useRef(r.skills);m.useEffect(()=>{y.current=r.skills},[r.skills]);const v=m.useCallback((I,V)=>{const se=y.current,M=I?se.find(te=>te.plugin===I&&te.skill===V):se.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,W=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:W}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=m.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=m.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=m.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),B=m.useRef(!1),[D,F]=m.useState(""),w=m.useMemo(()=>r.skills.map(I=>`${I.plugin}/${I.skill}`),[r.skills]),O=m.useMemo(()=>D?D.split(",").filter(Boolean):[],[D]),z=cS({skillIds:O,trackingSkillIds:w}),U=m.useRef("");m.useEffect(()=>{const I=r.skills.filter(W=>W.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const W of z.updates)V.set(W.name.split("/").pop()||W.name,W);const se=I.map(W=>{const te=V.get(W.skill);return{plugin:W.plugin,skill:W.skill,name:(te==null?void 0:te.name)??W.skill,currentVersion:W.currentVersion??(te==null?void 0:te.installed)??"0.0.0"}}),M=se.map(W=>`${W.plugin}/${W.skill}@${W.currentVersion}#${W.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(se).then(W=>{if(Y)return;const ie=[...uS(W).flatMap(ye=>[ye.uuid,ye.slug].filter(Boolean))].sort().join(",");ie!==A.current&&(A.current=ie,T.current=new Map(W.map(ye=>[`${ye.plugin}/${ye.skill}`,{uuid:ye.uuid,slug:ye.slug}])),F(ie))}).catch(W=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=W instanceof Error?W.message:String(W);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[r.skills,z.updates]);const H=m.useMemo(()=>{const I=r.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const se={...V};return delete se.updateAvailable,delete se.currentVersion,delete se.latestVersion,delete se.trackedForUpdates,se});return Qj(I,z.updates)},[r.skills,z.updates]),q=m.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=m.useMemo(()=>({...r,skills:H}),[r,H]),J=z.updateCount,$=z.refresh,L=z.isRefreshing,_=m.useMemo(()=>({state:X,selectSkill:p,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss}),[X,p,S,k,E,C,g,J,N,z.updates,q,L,$,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss]);return a.jsx(Ev.Provider,{value:_,children:t})}const mS={config:null,loading:!0};function hS(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Nv=m.createContext(null);function Hr(){const t=m.useContext(Nv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function xS({children:t}){const[r,s]=m.useReducer(hS,mS),o=m.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(Nv.Provider,{value:u,children:t})}function gS({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:p,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Wx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],vS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},yS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},bS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},jS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function SS(t,r){var h,g;const s=vS[t.id]??null,o=yS[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:jS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:kS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:bS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function kS(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function wS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Wx){const c=r.get(o);c&&s.push(c)}for(const o of t)Wx.includes(o.id)||s.push(o);return s}function CS(t){const[r,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=m.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=wS((A.providers||[]).map(D=>SS(D,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const k=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const D=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const z=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=D.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:D.ageSec?D.ageSec*1e3:0,cacheStale:!!D.stale}});return{...O,agents:z}});const F=D.ageSec??0;(D.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=m.useCallback(T=>{p.current=T,T==="openrouter"&&k()},[k]),C=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let D=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(D=O.error)}catch{}(w=b.current)==null||w.call(b,D)},[]);return{status:o,catalog:r,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:N}}function bd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Kd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const ES={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,r)=>`${t} of ${r}`},NS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},TS={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},RS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},AS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},MS={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},LS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},zS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},DS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},_S={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},OS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},BS={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},IS={subscriptionBilling:"· subscription",free:"· free"},US={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},HS={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},$S={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},VS={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},PS={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},FS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},GS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},WS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:ES,shell:NS,detail:TS,actions:RS,palette:AS,shortcuts:MS,toasts:LS,connection:zS,forms:DS,errors:_S,picker:OS,providers:BS,models:IS,settings:US,statusBar:HS,scopePicker:$S,scopeSection:VS,claudeCodeLabel:PS,setupDrawer:FS,setupProviders:WS,scopeLabels:GS},qS=new Set(["claude-cli","claude-code"]);function qx(t){return qS.has(t)}const Yx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function YS({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Yx.has(g.id)),h=t.filter(g=>!Yx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Kx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Kx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=qx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),qx(t.id)&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Kd,{unlocked:!0,size:10}):a.jsx(Kd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(bd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(bd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(bd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function KS(t,r,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(S=>{p(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/r)-4),k=Math.ceil(s/r)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,r,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*r,offsetTop:v*r,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Tv=44,XS=352,QS=60,Xx=480;function ZS(t){var u,d;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function JS(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function e2({agent:t,activeModelId:r,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),QS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Xx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>JS(t.models,h),[t.models,h]),v=KS(y.length,Tv,XS);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Xx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:p,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),a.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):a.jsx("div",{...v.containerProps,children:a.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return a.jsx(n2,{model:b,isActive:b.id===r,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function t2(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function n2({model:t,isActive:r,isFocused:s,onSelect:o,resolvedModel:c}){const u=ZS(t),d=t2(t.id,c,t.resolvedId),h=d!==null,g=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Tv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Qx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function a2(){const[t,r]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();r({...Qx,...y}),u(null)}catch(p){u(p.message),r(Qx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function r2({onMigrated:t,fetchImpl:r}){const[s,o]=m.useState({kind:"loading"}),c=r??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:jd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...jd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...jd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const jd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},l2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function s2(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function Rv({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=a2(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),r();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]);const b=m.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),a.jsx(r2,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),l2.map(S=>a.jsx(i2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?p:void 0},S.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Or,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function i2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[S,k]=m.useState(!1),[E,C]=m.useState(!1),[N,T]=m.useState(null),A=p.trim(),B=A.length===0,D=A.length>0&&!A.startsWith(o),F=m.useCallback(async()=>{if(B)return;k(!0);const z=A;y("");try{const U=await d(z);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:z=>{y(z.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>b(!v),style:Or,children:v?ne.settings.hide:ne.settings.show}),a.jsx("button",{type:"button",onClick:w,style:Or,children:ne.settings.paste})]}),D&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Zx,children:ne.settings.prefixWarn(r)}),N&&a.jsx("div",{role:"status",style:Zx,children:N}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Or,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:E?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Or,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>C(!1),style:Or,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Or,color:"var(--text-muted)"},children:ne.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(s2(u.updatedAt)):ne.settings.noKey})]})]})}const Or={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Zx={fontSize:11,color:"var(--warning, var(--text-muted))"};function o2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function c2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=CS({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[S,k]=m.useState("agents"),[E,C]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);m.useEffect(()=>{C(0)},[v]);const B=m.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),D=m.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);m.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),m.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),D();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),D())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,D,o,c]);const F=m.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[r,s,w,O]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?D():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:z})]}),u&&typeof document<"u"&&Fo.createPortal(a.jsxs(u2,{reducedMotion:o2(),onClickOutside:D,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx(YS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&a.jsx(e2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),D()},onOpenSettings:F})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),a.jsx(Rv,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function u2({children:t,reducedMotion:r,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
|
|
63
63
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
64
64
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
65
|
-
}`})]})}function Jx(){typeof window>"u"||(window.location.hash="#/")}function d2({onHome:t}){const[r,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Jx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Jx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const f2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",p2=m.lazy(()=>Xs(()=>import("./UpdateDropdown-CgTNXy-w.js"),__vite__mapDeps([0,1])));function m2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=ea(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:f2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(m.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(p2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function eg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function h2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(d2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(tg,{segment:"origin",onClick:()=>eg({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(ng,{}),a.jsx(tg,{segment:"plugin",onClick:()=>eg({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(ng,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(c2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(m2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function tg({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Go="vskill-theme";function Av(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function x2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function g2(t){try{const r=t.getItem(Go);return Av(r)}catch{return"auto"}}function v2(t,r){try{t.setItem(Go,r)}catch{}}function y2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function b2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Mv=m.createContext(null);function j2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?g2(c):"auto"),[p,y]=m.useState(()=>b2(u)),v=m.useMemo(()=>x2(h,p),[h,p]);m.useEffect(()=>{d&&y2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Go&&g(Av(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&v2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Mv.Provider,{value:S,children:o})}function Lv(){const t=m.useContext(Mv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function S2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=r.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function k2(t){const[r,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function w2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=S2(t),c=k2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(rg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(rg,{p:g,onClick:h,compact:!0},g.id))})}function rg({p:t,onClick:r,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Kd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function C2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Go)}catch{return null}}function E2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=Lv(),v=C2()==="auto",b=N2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(lg,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(T2,{color:S}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(lg,{}),a.jsx(w2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(R2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function N2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function T2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function lg(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function R2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Xd=new Set;function zv(){for(const t of Xd)t()}const A2=5,M2=1e3,L2=6e4;function z2(){const[t,r]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,r(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},L2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>A2){o(!0);return}const A=M2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Xd.add(C),()=>{Xd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const Wo=0,cr=1,_l=2,Dv=4;function sg(t){return()=>t}function D2(t){t()}function _v(t,r){return s=>t(r(s))}function ig(t,r){return()=>t(r)}function _2(t,r){return s=>t(r,s)}function vf(t){return t!==void 0}function O2(...t){return()=>{t.map(D2)}}function Ol(){}function qo(t,r){return r(t),t}function B2(t,r){return r(t)}function jt(...t){return t}function at(t,r){return t(cr,r)}function Pe(t,r){t(Wo,r)}function yf(t){t(_l)}function wt(t){return t(Dv)}function Re(t,r){return at(t,_2(r,Wo))}function Qn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function og(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Ov(t,r){return t===r}function bt(t=Ov){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function De(t){return r=>s=>{t(s)&&r(s)}}function ke(t){return r=>_v(r,t)}function ia(t){return r=>()=>{r(t)}}function me(t,...r){const s=I2(...r);return((o,c)=>{switch(o){case _l:yf(t);return;case cr:return at(t,s(c))}})}function oa(t,r){return s=>o=>{s(r=t(r,o))}}function Ur(t){return r=>s=>{t>0?t--:r(s)}}function Aa(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Fe(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const p=s;s|=h,r[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function I2(...t){return r=>t.reduceRight(B2,r)}function U2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=at(t,u),r):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let r=t;const s=Xe();return((o,c)=>{switch(o){case Wo:r=c;break;case cr:{c(r);break}case Dv:return r}return s(o,c)})}function nn(t,r){return qo(ve(r),s=>Re(t,s))}function Xe(){const t=[];return((r,s)=>{switch(r){case Wo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return qo(Xe(),r=>Re(t,r))}function et(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:H2(),singleton:s}}const H2=()=>Symbol();function $2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Ut(...t){const r=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Pe(r,s)})}),function(u,d){switch(u){case _l:{yf(r);return}case cr:return o===c&&d(s),at(r,d)}}}function ze(t,r=Ov){return me(t,bt(r))}function Qd(...t){return function(r,s){switch(r){case _l:return;case cr:return O2(...t.map(o=>at(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},V2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},P2=()=>typeof globalThis>"u"?window:globalThis,ur=et(()=>{const t=ve(Pt.ERROR);return{log:ve((r,s,o=Pt.INFO)=>{const c=P2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[V2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function $r(t,r,s){return bf(t,r,s).callbackRef}function bf(t,r,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function F2(t,r,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=G2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?cg("column-gap",getComputedStyle(y).columnGap,c):cg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return bf(p,s,g)}function G2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}function Bv(t,r,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(r){const S=r.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+r.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=bf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=et(()=>{const t=Xe(),r=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),r),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),$s={lvl:0};function Iv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===$s}function Vs(t,r){if(!ft(t))return r===t.k?t.v:r<t.k?Vs(t.l,r):Vs(t.r,r)}function Jn(t,r,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Jn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,r,s)}function En(t,r,s){return ft(t)?$v(r,s,1):r===t.k?Vt(t,{k:r,v:s}):r<t.k?ug(Vt(t,{l:En(t.l,r,s)})):ug(Vt(t,{r:En(t.r,r,s)}))}function Rl(){return $s}function Al(t,r,s){if(ft(t))return[];const o=Jn(t,r)[0];return W2(Jd(t,o,s))}function Zd(t,r){if(ft(t))return $s;const{k:s,l:o,r:c}=t;if(r===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=Hv(o);return Ao(Vt(t,{k:u,l:Uv(o),v:d}))}return r<s?Ao(Vt(t,{l:Zd(o,r)})):Ao(Vt(t,{r:Zd(c,r)}))}function Ir(t){return ft(t)?[]:[...Ir(t.l),{k:t.k,v:t.v},...Ir(t.r)]}function Jd(t,r,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Jd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Jd(u,r,s))),h}function Ao(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(Sd(r))return Vv(Vt(t,{lvl:s-1}));if(!ft(r)&&!ft(r.r))return Vt(r.r,{l:Vt(r,{r:r.r.l}),lvl:s,r:Vt(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Sd(t))return ef(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=Sd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:ef(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,r){return $v(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function Uv(t){return ft(t.r)?t.l:Ao(Vt(t,{r:Uv(t.r)}))}function Sd(t){return ft(t)||t.lvl>t.r.lvl}function Hv(t){return ft(t.r)?[t.k,t.v]:Hv(t.r)}function $v(t,r,s,o=$s,c=$s){return{k:t,l:o,lvl:s,r:c,v:r}}function ug(t){return ef(Vv(t))}function Vv(t){const{l:r}=t;return!ft(r)&&r.lvl===t.lvl?Vt(r,{r:Vt(t,{l:r.r})}):t}function ef(t){const{lvl:r,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===r&&s.r.lvl===r?Vt(s,{l:Vt(t,{r:s.l}),lvl:r+1}):t}function W2(t){return Iv(t,({k:r,v:s})=>({index:r,value:s}))}function Pv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Ps(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const jf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Fv(t,r,s){return t[Oo(t,r,s)]}function Oo(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function q2(t,r,s,o){const c=Oo(t,r,o),u=Oo(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Yo(t){return!ft(t.groupOffsetTree)}function Sf({index:t},r){return r===t?0:r<t?-1:1}function Y2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function K2(t,r){let s=ft(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(nk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Zd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function X2(t){return typeof t.groupIndex<"u"}function Q2({offset:t},r){return r===t?0:r<t?-1:1}function Fs(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Fv(r,t,Sf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Gv(t,r){if(!Yo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Wv(t,r,s){if(X2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Gv(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function Z2(t,r,s,o=0){return o>0&&(r=Math.max(r,Fv(t,o,Sf).offset)),Iv(q2(t,r,s,Q2),tk)}function J2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&r.length===2){const b=r[0].size,S=r[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=K2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=tf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Fs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function ek(t){return Ir(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function dg(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function tf(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Oo(c,r-1,Sf),h=c[g].offset;const p=Jn(s,r-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,r,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function tk(t){return{index:t.index,value:t}}function nk(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ua=et(([{log:t},{recalcInProgress:r}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ir(w,ak[O])),k=ve(void 0),E=ve(0),C=Y2(),N=nn(me(s,Fe(g,t,E),oa(J2,C),bt()),C),T=nn(me(g,bt(),oa((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Fs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),oa(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));at(me(h,oa((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(r,!0),Pe(u,w+dg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=dg(-w,z)),Pe(d,w)}}),at(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Vs(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ir(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ir(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Fs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ir(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Vs(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...tf(O.offsetTree,0,H,z)}}const U=Ir(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...tf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ur,jf),{singleton:!0});function rk(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const qv=et(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(rk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,r,o),De(([g,p])=>Yo(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ua,cn)),dr=et(([{log:t}])=>{const r=ve(!1),s=Nn(me(r,De(o=>o),bt()));return at(r,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:r}},jt(ur),{singleton:!0}),lk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!lk)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Qs=et(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Yv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=Wv($,D,V);let M=Fs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=W=>{A(),W?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let W=!1;T=at(r,te=>{W=W||te}),C=Qn(y,()=>{Y(W)})}else C=Qn(me(r,sk(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ua,cn,ur),{singleton:!0});function sk(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function kf(t,r){t===0?r():requestAnimationFrame(()=>{kf(t-1,r)})}function wf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Zs=et(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),p),at(me(Ut(r,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||vf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),kf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ua,cn,Qs,dr),{singleton:!0});function Kv(t,r){return Math.abs(t-r)<1.01}const Gs="up",Bs="down",ik="none",ok={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ck=0,Js=et(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(ck),b=nn(me(Qd(me(ze(c),Ur(1),ia(!0)),me(ze(c),Ur(1),ia(!1),og(100))),bt()),!1),S=nn(me(Qd(me(s,ia(!0)),me(s,ia(!1),og(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Aa(50)),p);const k=Nn(me(Ut(o,ze(u),ze(r),ze(t),ze(y)),oa((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ok),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,oa((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Kv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Aa(50)),g);const C=ve(Bs);Re(me(o,ke(({scrollTop:T})=>T),bt(),oa((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Gs:Bs,prevScrollTop:A},{direction:Bs,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Aa(50),ia(ik)),C);const N=ve(0);return Re(me(b,De(T=>!T),ia(0)),N),Re(me(c,Aa(100),Fe(b),De(([T,A])=>A),oa(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),Ws="top",qs="bottom",fg="none";function pg(t,r,s){return typeof t=="number"?s===Gs&&r===Ws||s===Bs&&r===qs?t:0:s===Gs?r===Ws?t.main:t.reverse:r===qs?t.main:t.reverse}function mg(t,r){return typeof t=="number"?t:t[r]??0}const Cf=et(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Ps),ze(g),ze(d),ze(r),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=fg;const O=mg(A,Ws),z=mg(A,qs);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Gs),k<y-F+v+z&&(w=Bs),w!==fg?[Math.max(B-b-pg(E,Ws,w)-O,0),B-F-N+v+pg(E,qs,w)+z]:null}),De(y=>y!==null),bt(Ps)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function uk(t,r,s){if(Yo(r)){const o=Gv(t,r);return[{index:Jn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const kd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Mo(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:hg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:hg(r,c,u),topListHeight:r.reduce((E,C)=>C.size+E,0),totalCount:s}}function Xv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=wf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Mo(p,[],h,c,s,o)}function hg(t,r,s){if(t.length===0)return[];if(!Yo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function xg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Vr=et(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Ps),ze(c),ze(o),ze(p),y,ze(E),ze(r),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...kd,totalCount:z};if(w===0&&O===0)return M===0?{...kd,totalCount:z}:Xv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Mo(uk(wf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],re=X[X.length-1];let he=0;for(const pe of Al(se,_e,re)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,re);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Mo([],Y,z,$,I,J);const W=X.length>0?X[X.length-1]+1:0,te=Z2(V,w,O,W);if(te.length===0)return null;const fe=z-1,ie=qo([],_e=>{for(const re of te){const he=re.value;let pe=he.offset,ge=re.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-re.start;pe+=Oe*je+Oe*$}ge<W&&(pe+=(W-ge)*je,ge=W);const Be=Math.min(re.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=xg(L,Ws),de=xg(L,qs);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],re=ie[ie.length-1];if(ye>0&&_e.index>W){const he=Math.min(ye,_e.index-W),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&re.index<fe){const he=Math.min(de,fe-re.index);let pe=re.offset+re.size+$;for(let ge=re.index+1;ge<=re.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??re.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Mo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),kd);Re(me(t,De(vf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Ps),ke(([w])=>w))),D=Nn(me(A,Aa(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Pv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ua,qv,Cf,Zs,Qs,Js,dr,jf),{singleton:!0}),Qv=et(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,r,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Vr),{singleton:!0}),dk=et(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ve(!1),o=nn(me(Ut(s,t,r),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Aa(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Qv),{singleton:!0}),Zv=et(()=>({context:ve(null)})),fk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Jv=et(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(r,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=fk,done:D,...F}=v,w=Wv(v,b,k-1),O=Fs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ur(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ua,cn,Qs,Vr,ur),{singleton:!0});function gg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const pk=(t,r)=>typeof t=="function"?gg(t(r)):r&&gg(t),mk=et(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}at(me(Ut(me(ze(r),Ur(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=pk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ut(ze(k),r,p),De(([D,,F])=>D!==!1&&F),oa(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,r)),([,D])=>{wt(h)&&T(D!==!1)}),at(E,()=>{T(wt(k)!==!1)}),at(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Qd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(r))),B),at(me(Ut(me(B,Ur(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Aa(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ua,Js,Qs,Zs,dr,ur,cn,Zv,Jv)),hk=et(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,r,s,t),ke(([[,g],p,y,v,b,S=[]])=>Xv(g,p,y,v,b,S))),d),{}),jt(ua,Zs,Vr,dr),{singleton:!0}),xk=et(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ve(0);return at(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ur(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(r,c)})})}),{initialScrollTop:o}},jt(dr,cn,Vr),{singleton:!0}),ey=et(([{scrollVelocity:t}])=>{const r=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,r,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),r),at(me(Ut(r,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(Js),{singleton:!0}),Ef=et(([{scrollContainerState:t,scrollTo:r}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(r,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),gk=et(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),at(me(p,Fe(r,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=ek(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(vf),ke(vk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ua,cn,Zs,dr,Ef));function vk(t){return{align:"start",index:0,offset:t.scrollTop}}const yk=et(([{topItemsIndexes:t}])=>{const r=ve(0);return Re(me(r,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},jt(Vr));function ty(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const bk=ty(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),jk=et(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),oa(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Gs),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(r,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(r,{behavior:"auto",top:-N}))}return at(me(E,Fe(t,u)),([N,T,A])=>{A&&bk()?Pe(t,T-N):C(-N)}),at(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Aa(1)),C),Re(me(v,ke(N=>({top:-N}))),r),at(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Vs(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(r,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,Js,Vr,ua,ur,jf)),Sk=et(([t,r,s,o,c,u,d,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Cf,hk,dr,ey,Qv,xk,dk,Ef,Jv,ur,Zv)),ny=et(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ua,Zs,cn,gk,mk,Vr,Qs,jk,yk,qv,Sk));function kk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const vo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[r.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[r.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[r.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=U2(C[r.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>qo($2(t),w=>{g(w,A)})),[D]=Te.useState(ig(y,B));vo(()=>{for(const w of d)w in A&&at(D[w],A[w]);return()=>{Object.values(D).map(yf)}},[A,D,B]),vo(()=>{g(B,A)}),Te.useImperativeHandle(N,sg(p(B)));const F=s;return a.jsx(h.Provider,{value:B,children:s!==void 0?a.jsx(F,{...kk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>at(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(ig(wt,N));return vo(()=>at(N,B=>{B!==T&&A(sg(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];vo(()=>at(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ry=Te.createContext(void 0),ly=Te.createContext(void 0),wd="-webkit-sticky",vg="sticky",Nf=ty(()=>{if(typeof document>"u")return vg;const t=document.createElement("div");return t.style.position=wd,t.style.position===wd?wd:vg}),sy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Cd(t){return"self"in t}function wk(t){return"body"in t}function iy(t,r,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(wk(C)||Cd(C)){const T=Cd(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Pj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Cd(S)?(C=Math.max(ir(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ir(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Kv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&r(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Tf(t){return t}const Ck=et(()=>{const t=ve(h=>`Item ${h}`),r=ve(h=>`Group ${h}`),s=ve({}),o=ve(Tf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Ek=et(([t,r])=>({...t,...r}),jt(ny,Ck)),Nk=({height:t})=>a.jsx("div",{style:{height:t}}),Tk={overflowAnchor:"none",position:Nf(),zIndex:1},oy={overflowAnchor:"none"},Rk={...oy,display:"inline-block",height:"100%"},yg=Te.memo(function({showTopList:t=!1}){const r=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=F2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Rf("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Nk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&A!==null&&A!==void 0?a.jsx(A,{...tn(A,p)}):a.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(J=>{const $=J.originalIndex,L=O($+r.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Tk},y(J.index,p)):m.createElement(F,{...tn(F,p),...zk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Rk:oy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Ak={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Mk={outline:"none",overflowX:"auto",position:"relative"},Ko=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Lk={position:Nf(),top:0,width:"100%",zIndex:1};function tn(t,r){if(typeof t!="string")return{context:r}}function zk(t,r){return{item:typeof t=="string"?void 0:r}}const Dk=Te.memo(function(){const t=Ue("HeaderComponent"),r=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),_k=Te.memo(function(){const t=Ue("FooterComponent"),r=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null});function cy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=iy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Mk:Ak,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function uy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),S=Te.useRef(null),k=r("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=iy(h,p,g,k,b);return sy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),a.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Ok=({children:t})=>{const r=Te.useContext(ry),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>_v(s,g=>ir(g,u?"width":"height")),[s,u]),h=$r(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Ko(c),children:t})},Bk=({children:t})=>{const r=Te.useContext(ry),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Bv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Ko(d),children:t})},Ik=({children:t})=>{const r=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...Lk,marginTop:`${s}px`},c=Ue("context");return a.jsx(r,{style:o,...tn(r,c),children:t})},Uk=Te.memo(function(t){const r=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return a.jsxs(o||r?Vk:$k,{...t,context:c,children:[s&&a.jsx(Ik,{children:a.jsx(yg,{showTopList:!0})}),a.jsxs(o||r?Bk:Ok,{children:[a.jsx(Dk,{}),a.jsx(yg,{}),a.jsx(_k,{})]})]})}),{Component:Hk,useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}=ay(Ek,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Uk),$k=cy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Vk=uy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Pk=Hk,Fk=et(()=>{const t=ve(p=>a.jsxs("td",{children:["Item $",p]})),r=ve(null),s=ve(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Tf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ny,Fk);Nf();const bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Gk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jg,floor:Bo,max:Is,min:Ed,round:Sg}=Math;function kg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Wk(t){return{...Gk,items:t}}function yo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function qk(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Yk=et(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(bg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);at(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),at(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,re])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!re)),([,,,,de])=>{Pe(M,!0),kf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(r,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ia(0)),w),at(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ur(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,yo),ze(U,yo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,qk),ze(U,yo),ze(z,yo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,re,he,pe,ge,,je,Be])=>{const{column:Oe,row:rt}=_e,{height:Nt,width:ht}=re,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return bg;if(ht===0){const Gt=wf(Be,de),an=Gt+Math.max(ge-1,0);return Wk(kg(Gt,an,pe))}const Tt=dy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Bo((Se+rt)/(Nt+rt)),tt=Tt*jg((Ae+rt)/(Nt+rt))-1,tt=Ed(de-1,Is(tt,Tt-1)),Qe=Ed(tt,Is(0,Qe))):(Qe=0,tt=-1);const be=kg(Qe,tt,pe),{bottom:pt,top:Ct}=wg(he,_e,re,be),Yt=jg(de/Tt),un=Yt*Nt+(Yt-1)*rt-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:re,top:he}=wg(de,_e,Se,Ae);return[he,re]}),bt(Ps)),r);const W=ve(!1);Re(me(p,Fe(W),ke(([de,Se])=>Se||de!==0)),W);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(W),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ia(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Pv),Aa(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,re])=>{const he=Yv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Is(0,Be,Ed(_e-1,Be));let Oe=nf(Se,re,Ae,Be);return pe==="end"?Oe=Sg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=Sg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Cf,cn,Js,ey,dr,Ef,ur));function dy(t,r,s){return Is(1,Bo((t+s)/(Bo(r)+s)))}function wg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=nf(t,r,s,o[0].index);return{bottom:nf(t,r,s,o[o.length-1].index)+c,top:u}}function nf(t,r,s,o){const c=dy(t.width,s.width,r.column),u=Bo(o/c),d=u*s.height+Is(0,u-1)*r.row;return d>0?d+r.row:d}const Kk=et(()=>{const t=ve(v=>`Item ${v}`),r=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Tf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(r,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Xk=et(([t,r])=>({...t,...r}),jt(Yk,Kk)),Qk=Te.memo(function(){const t=kt("gridState"),r=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$r(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Cg("column-gap",getComputedStyle(N).columnGap,S),row:Cg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return sy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:a.jsx(g,{className:r,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?a.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Zk=Te.memo(function(){const t=kt("HeaderComponent"),r=Fn("headerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),Jk=Te.memo(function(){const t=kt("FooterComponent"),r=Fn("footerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),ew=({children:t})=>{const r=Te.useContext(ly),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$r(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Ko(!1),children:t})},tw=({children:t})=>{const r=Te.useContext(ly),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Bv(s,c,!1);return Te.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Ko(!1),children:t})},nw=Te.memo(function({...t}){const r=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||r?rw:aw,c=s||r?tw:ew,u=kt("context");return a.jsx(o,{...t,...tn(o,u),children:a.jsxs(c,{children:[a.jsx(Zk,{}),a.jsx(Qk,{}),a.jsx(Jk,{})]})})}),{useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}=ay(Xk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},nw),aw=cy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}),rw=uy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn});function Cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}const lw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},py={source:"Own",installed:"Installed"};function sw(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function iw(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Eg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=lw[t],[d,h]=m.useState(()=>sw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return iw(u,S),S})},[u]),p=py[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(cw,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(ow,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function ow({origin:t,updateCount:r}){const[s,o]=m.useState(!1),c=py[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function cw({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Af(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function uw({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function dw({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function fw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function pw({skillId:t,trackedForUpdates:r}){let s=null;try{s=m.useContext(Cv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ei(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function mw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(ei,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(dw,{target:t.symlinkTarget??null}),a.jsx(fw,{skill:t}),a.jsx(pw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Io=m.memo(mw);function hw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Io,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function xw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function Ng({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=r??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>xw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>a.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const Lo=new Map,Br=new Map,Ds=new Map;function Tn(t){Lo.delete(t),Br.delete(t);const r=Ds.get(t);if(r)for(const s of r)s()}function ti(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Ds.has(t)||Ds.set(t,new Set),Ds.get(t).add(b),()=>{var S;(S=Ds.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=Lo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Br.has(t)){const C=Br.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=r().then(C=>{Lo.set(t,{data:C,fetchedAt:Date.now()}),Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Br.set(t,k)},[t,r,o,c]);const p=Lo.get(t),y=c&&!p&&Br.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function gw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),zv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Nd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Nd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Nd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Nd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Tg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(vw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function vw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function yw(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function bw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function jw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function Sw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function af(t,r={}){const{enabled:s=!0,target:o}=r,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(bw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=jw(p.target);for(const v of c.current){if(!Sw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const kw=200;function ww(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Cw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Af(g,r)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Ew(t,r){const s=[],o=[],c=[];for(const d of t){const h=ww(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Af(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Nw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Af(y,r)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Tw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(W=>W.scope!==void 0&&W.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Ew(t,N),[t,N]),A=m.useMemo(()=>Cw(t,N),[t,N]),B=k==="claude-code",{plugins:D}=z2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const W=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=W.get(te.name);W.set(te.name,!!fe||!!te.enabled)}return W},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>rf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>rf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(W=>{z(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(W))}catch{}},[k]),X=m.useCallback(W=>{H(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(W))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Nw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=kw,I=m.useMemo(()=>{const W=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...W(T.own.byPlugin),...W(T.installed.byPlugin),...W(T.global.byPlugin)]:[...W(J.byPlugin),...W($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>r?I.findIndex(W=>W.plugin===r.plugin&&W.skill===r.skill):-1,[I,r]),se=m.useCallback(W=>{if(I.length===0)return;const te=V<0?W>0?0:I.length-1:Math.min(Math.max(V+W,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[W,te]=v.split("/");if(!W||!te)return null;const fe=t.find(de=>de.plugin===W&&de.skill===te);if(!fe)return{plugin:W,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??W:null;return{plugin:W,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const W=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${W}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(uw,{value:E,onChange:C}),o&&a.jsx(zw,{}),!o&&c&&a.jsx(Dw,{error:c,onRetry:u}),!o&&!c&&S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Tg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?a.jsx(Ag,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?a.jsx(Aw,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-available-${W}-collapsed`,headerActionSlot:B?a.jsx(gw,{pluginName:W,enabled:w.get(W)??!0}):void 0,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${W}`))]})]}),a.jsx(Lw,{}),a.jsx(Tg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-authoring-${W}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===W,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${W}`))})]})]}),!o&&!c&&!S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Eg,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:J.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Mw,{}),a.jsx(Eg,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?a.jsx(Ag,{queryActive:!!E}):a.jsx(Ls,{items:$.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function rf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>rf(r)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(S))}catch{}return S})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function Rw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ls({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Rw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Pk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Io,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(hw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Rg({queryActive:t}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Mf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ag({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install <plugin>"})," to add one."]})})}function Aw({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install --global <plugin>"})," to add one."]})})}function Ml({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Mf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Mw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Lw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function zw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(yw,{},t))})}function Dw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:_w(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function _w(t){const r=t.split(`
|
|
65
|
+
}`})]})}function Jx(){typeof window>"u"||(window.location.hash="#/")}function d2({onHome:t}){const[r,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Jx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Jx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const f2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",p2=m.lazy(()=>Xs(()=>import("./UpdateDropdown-C-4cwFXV.js"),__vite__mapDeps([0,1])));function m2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=ea(),d=m.useMemo(()=>{if(!u||u.size===0)return;const k=new Map;for(const[E,C]of u)C.diffSummary&&k.set(E,C.diffSummary);return k.size>0?k:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),S=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":S,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(k=>!k),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:f2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(m.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(p2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:k=>{const E=k.name.split("/"),C=E.length>=2?E[E.length-2]:E[0],N=E[E.length-1];c({plugin:C,skill:N,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function eg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function h2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(d2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(tg,{segment:"origin",onClick:()=>eg({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(ng,{}),a.jsx(tg,{segment:"plugin",onClick:()=>eg({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(ng,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(c2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(m2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function tg({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Go="vskill-theme";function Av(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function x2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function g2(t){try{const r=t.getItem(Go);return Av(r)}catch{return"auto"}}function v2(t,r){try{t.setItem(Go,r)}catch{}}function y2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function b2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Mv=m.createContext(null);function j2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?g2(c):"auto"),[p,y]=m.useState(()=>b2(u)),v=m.useMemo(()=>x2(h,p),[h,p]);m.useEffect(()=>{d&&y2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===Go&&g(Av(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),m.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=m.useCallback(k=>{g(k),c&&v2(c,k)},[c]),S=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Mv.Provider,{value:S,children:o})}function Lv(){const t=m.useContext(Mv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const ag=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function S2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of ag){const c=r.get(o);c&&s.push(c)}for(const o of t)ag.includes(o.id)||s.push(o);return s}function k2(t){const[r,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function w2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=S2(t),c=k2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(rg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(rg,{p:g,onClick:h,compact:!0},g.id))})}function rg({p:t,onClick:r,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Kd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function C2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Go)}catch{return null}}function E2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=Lv(),v=C2()==="auto",b=N2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(lg,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(T2,{color:S}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(lg,{}),a.jsx(w2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(R2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function N2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function T2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function lg(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function R2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Xd=new Set;function zv(){for(const t of Xd)t()}const A2=5,M2=1e3,L2=6e4;function z2(){const[t,r]=m.useState(void 0),[s,o]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),h=m.useRef(null),g=m.useRef(null),p=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=m.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=m.useCallback(async()=>{if(!p.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!p.current)return;const A=await T.json();if(!p.current)return;d.current=0,r(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{p.current&&b(B=>B+1)},L2)}catch(T){if(!p.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>A2){o(!0);return}const A=M2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{p.current&&b(B=>B+1)},A)}},[k]);m.useEffect(()=>(p.current=!0,()=>{p.current=!1,S(),k()}),[k]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=m.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(Xd.add(C),()=>{Xd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const Wo=0,cr=1,_l=2,Dv=4;function sg(t){return()=>t}function D2(t){t()}function _v(t,r){return s=>t(r(s))}function ig(t,r){return()=>t(r)}function _2(t,r){return s=>t(r,s)}function vf(t){return t!==void 0}function O2(...t){return()=>{t.map(D2)}}function Ol(){}function qo(t,r){return r(t),t}function B2(t,r){return r(t)}function jt(...t){return t}function at(t,r){return t(cr,r)}function Pe(t,r){t(Wo,r)}function yf(t){t(_l)}function wt(t){return t(Dv)}function Re(t,r){return at(t,_2(r,Wo))}function Qn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function og(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Ov(t,r){return t===r}function bt(t=Ov){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function De(t){return r=>s=>{t(s)&&r(s)}}function ke(t){return r=>_v(r,t)}function ia(t){return r=>()=>{r(t)}}function me(t,...r){const s=I2(...r);return((o,c)=>{switch(o){case _l:yf(t);return;case cr:return at(t,s(c))}})}function oa(t,r){return s=>o=>{s(r=t(r,o))}}function Ur(t){return r=>s=>{t>0?t--:r(s)}}function Aa(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Fe(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const p=s;s|=h,r[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function I2(...t){return r=>t.reduceRight(B2,r)}function U2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=at(t,u),r):(o(),Ol);case _l:o(),s=null;return}}}function ve(t){let r=t;const s=Xe();return((o,c)=>{switch(o){case Wo:r=c;break;case cr:{c(r);break}case Dv:return r}return s(o,c)})}function nn(t,r){return qo(ve(r),s=>Re(t,s))}function Xe(){const t=[];return((r,s)=>{switch(r){case Wo:t.slice().forEach(o=>{o(s)});return;case _l:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return qo(Xe(),r=>Re(t,r))}function et(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:H2(),singleton:s}}const H2=()=>Symbol();function $2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Ut(...t){const r=Xe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Pe(r,s)})}),function(u,d){switch(u){case _l:{yf(r);return}case cr:return o===c&&d(s),at(r,d)}}}function ze(t,r=Ov){return me(t,bt(r))}function Qd(...t){return function(r,s){switch(r){case _l:return;case cr:return O2(...t.map(o=>at(o,s)))}}}const Pt={DEBUG:0,INFO:1,WARN:2,ERROR:3},V2={[Pt.DEBUG]:"debug",[Pt.ERROR]:"error",[Pt.INFO]:"log",[Pt.WARN]:"warn"},P2=()=>typeof globalThis>"u"?window:globalThis,ur=et(()=>{const t=ve(Pt.ERROR);return{log:ve((r,s,o=Pt.INFO)=>{const c=P2().VIRTUOSO_LOG_LEVEL??wt(t);o>=c&&console[V2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function $r(t,r,s){return bf(t,r,s).callbackRef}function bf(t,r,s){const o=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function F2(t,r,s,o,c,u,d,h,g){const p=Te.useCallback(y=>{const v=G2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?cg("column-gap",getComputedStyle(y).columnGap,c):cg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return bf(p,s,g)}function G2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Pt.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}function Bv(t,r,s){const o=Te.useRef(null),c=Te.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(r){const S=r.getBoundingClientRect(),k=p.top-S.top;b=S.height-Math.max(0,k),v=k+r.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,p.top),v=p.top+S.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=bf(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=et(()=>{const t=Xe(),r=Xe(),s=ve(0),o=Xe(),c=ve(0),u=Xe(),d=Xe(),h=ve(0),g=ve(0),p=ve(0),y=ve(0),v=Xe(),b=Xe(),S=ve(!1),k=ve(!1),E=ve(!1);return Re(me(t,ke(({scrollTop:C})=>C)),r),Re(me(t,ke(({scrollHeight:C})=>C)),d),Re(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),$s={lvl:0};function Iv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ft(t){return t===$s}function Vs(t,r){if(!ft(t))return r===t.k?t.v:r<t.k?Vs(t.l,r):Vs(t.r,r)}function Jn(t,r,s="k"){if(ft(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Jn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,r,s)}function En(t,r,s){return ft(t)?$v(r,s,1):r===t.k?Vt(t,{k:r,v:s}):r<t.k?ug(Vt(t,{l:En(t.l,r,s)})):ug(Vt(t,{r:En(t.r,r,s)}))}function Rl(){return $s}function Al(t,r,s){if(ft(t))return[];const o=Jn(t,r)[0];return W2(Jd(t,o,s))}function Zd(t,r){if(ft(t))return $s;const{k:s,l:o,r:c}=t;if(r===s){if(ft(o))return c;if(ft(c))return o;const[u,d]=Hv(o);return Ao(Vt(t,{k:u,l:Uv(o),v:d}))}return r<s?Ao(Vt(t,{l:Zd(o,r)})):Ao(Vt(t,{r:Zd(c,r)}))}function Ir(t){return ft(t)?[]:[...Ir(t.l),{k:t.k,v:t.v},...Ir(t.r)]}function Jd(t,r,s){if(ft(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Jd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Jd(u,r,s))),h}function Ao(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(Sd(r))return Vv(Vt(t,{lvl:s-1}));if(!ft(r)&&!ft(r.r))return Vt(r.r,{l:Vt(r,{r:r.r.l}),lvl:s,r:Vt(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Sd(t))return ef(Vt(t,{lvl:s-1}));if(!ft(o)&&!ft(o.l)){const c=o.l,u=Sd(c)?o.lvl-1:o.lvl;return Vt(c,{l:Vt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:ef(Vt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Vt(t,r){return $v(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function Uv(t){return ft(t.r)?t.l:Ao(Vt(t,{r:Uv(t.r)}))}function Sd(t){return ft(t)||t.lvl>t.r.lvl}function Hv(t){return ft(t.r)?[t.k,t.v]:Hv(t.r)}function $v(t,r,s,o=$s,c=$s){return{k:t,l:o,lvl:s,r:c,v:r}}function ug(t){return ef(Vv(t))}function Vv(t){const{l:r}=t;return!ft(r)&&r.lvl===t.lvl?Vt(r,{r:Vt(t,{l:r.r})}):t}function ef(t){const{lvl:r,r:s}=t;return!ft(s)&&!ft(s.r)&&s.lvl===r&&s.r.lvl===r?Vt(s,{l:Vt(t,{r:s.l}),lvl:r+1}):t}function W2(t){return Iv(t,({k:r,v:s})=>({index:r,value:s}))}function Pv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Ps(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const jf=et(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function Fv(t,r,s){return t[Oo(t,r,s)]}function Oo(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function q2(t,r,s,o){const c=Oo(t,r,o),u=Oo(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Yo(t){return!ft(t.groupOffsetTree)}function Sf({index:t},r){return r===t?0:r<t?-1:1}function Y2(){return{groupIndices:[],groupOffsetTree:Rl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Rl()}}function K2(t,r){let s=ft(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ft(t)){t=En(t,0,u);continue}const h=Al(t,d-1,c+1);if(h.some(nk(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Zd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));p&&(t=En(t,d,u))}return[t,s]}function X2(t){return typeof t.groupIndex<"u"}function Q2({offset:t},r){return r===t?0:r<t?-1:1}function Fs(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Fv(r,t,Sf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Gv(t,r){if(!Yo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Wv(t,r,s){if(X2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Gv(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function Z2(t,r,s,o=0){return o>0&&(r=Math.max(r,Fv(t,o,Sf).offset)),Iv(q2(t,r,s,Q2),tk)}function J2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Pt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ft(u)&&r.length===2){const b=r[0].size,S=r[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=K2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=tf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,Fs(S,v,c)),Rl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function ek(t){return Ir(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function dg(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function tf(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Oo(c,r-1,Sf),h=c[g].offset;const p=Jn(s,r-1);u=p[0],d=p[1],c.length&&c[g].size===Jn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of Al(s,r,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function tk(t){return{index:t.index,value:t}}function nk(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const ak={offsetHeight:"height",offsetWidth:"width"},ua=et(([{log:t},{recalcInProgress:r}])=>{const s=Xe(),o=Xe(),c=nn(o,0),u=Xe(),d=Xe(),h=ve(0),g=ve([]),p=ve(void 0),y=ve(void 0),v=ve(void 0),b=ve(void 0),S=ve((w,O)=>ir(w,ak[O])),k=ve(void 0),E=ve(0),C=Y2(),N=nn(me(s,Fe(g,t,E),oa(J2,C),bt()),C),T=nn(me(g,bt(),oa((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Re(me(g,De(w=>w.length>0),Fe(N,E),ke(([w,O,z])=>{const U=w.reduce((H,q,X)=>En(H,q,Fs(q,O.offsetTree,z)||X),Rl());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Re(me(o,Fe(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:w}])),s),Re(p,y);const A=nn(me(p,ke(w=>w===void 0)),!0);Re(me(y,De(w=>w!==void 0&&ft(wt(N).sizeTree)),ke(w=>{const O=wt(v),z=wt(g).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Re(me(b,De(w=>w!==void 0&&w.length>0&&ft(wt(N).sizeTree)),ke(w=>{const O=[];let z=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==z&&(O.push({endIndex:H-1,size:z,startIndex:U}),z=q,U=H)}return O.push({endIndex:w.length-1,size:z,startIndex:U}),O})),s),Re(me(g,Fe(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,z])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:z})}return U})),s);const B=Nn(me(s,Fe(N),oa(({sizes:w},[O,z])=>({changed:z!==w,sizes:z}),{changed:!1,sizes:C}),ke(w=>w.changed)));at(me(h,oa((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=wt(N);if(w>0)Pe(r,!0),Pe(u,w+dg(w,O));else if(w<0){const z=wt(T);z.length>0&&(w-=dg(-w,z)),Pe(d,w)}}),at(me(h,Fe(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Pt.ERROR)});const D=Nn(u);Re(me(u,Fe(N),ke(([w,O])=>{const z=O.groupIndices.length>0,U=[],H=O.lastSize;if(z){const q=Vs(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ir(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ir(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Fe(N,E),ke(([w,{offsetTree:O},z])=>{const U=-w;return Fs(U,O,z)})));return Re(me(d,Fe(N,E),ke(([w,O,z])=>{if(O.groupIndices.length>0){if(ft(O.sizeTree))return O;let H=Rl();const q=wt(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ir(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Vs(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...tf(O.offsetTree,0,H,z)}}const U=Ir(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Rl());return{...O,sizeTree:U,...tf(O.offsetTree,0,U,z)}})),N),{beforeUnshiftWith:D,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},jt(ur,jf),{singleton:!0});function rk(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const qv=et(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Xe(),d=Xe(),h=Nn(me(u,ke(rk)));return Re(me(h,ke(g=>g.totalCount)),s),Re(me(h,ke(g=>g.groupIndices)),t),Re(me(Ut(c,r,o),De(([g,p])=>Yo(p)),ke(([g,p,y])=>Jn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),bt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},jt(ua,cn)),dr=et(([{log:t}])=>{const r=ve(!1),s=Nn(me(r,De(o=>o),bt()));return at(r,o=>{o&&wt(t)("props updated",{},Pt.DEBUG)}),{didMount:s,propsReady:r}},jt(ur),{singleton:!0}),lk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Yv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!lk)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Qs=et(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Xe(),k=Xe(),E=ve(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Pe(g,!1)}return Re(me(S,Fe(s,v,o,E,h,d,b),Fe(t,u,c),ke(([[B,D,F,w,O,z,U,H],q,X,J])=>{const $=Yv(B),{align:L,behavior:_,offset:I}=$,V=w-1,se=Wv($,D,V);let M=Fs(se,D.offsetTree,q)+z;L==="end"?(M+=X+Jn(D.sizeTree,se)[1]-F+J,se===V&&(M+=U)):L==="center"?M+=(X+Jn(D.sizeTree,se)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=W=>{A(),W?(H("retrying to scroll to",{location:B},Pt.DEBUG),Pe(S,B)):(Pe(k,!0),H("list did not change, scroll successful",{},Pt.DEBUG))};if(A(),_==="smooth"){let W=!1;T=at(r,te=>{W=W||te}),C=Qn(y,()=>{Y(W)})}else C=Qn(me(r,sk(150)),Y);return N=setTimeout(()=>{A()},1200),Pe(g,!0),H("scrolling from index to",{behavior:_,index:se,top:M},Pt.DEBUG),{behavior:_,top:M}})),p),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},jt(ua,cn,ur),{singleton:!0});function sk(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function kf(t,r){t===0?r():requestAnimationFrame(()=>{kf(t-1,r)})}function wf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const Zs=et(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ve(!0),g=ve(0),p=ve(!0);return Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),h),Re(me(d,Fe(g),De(([y,v])=>v!==0),ia(!1)),p),at(me(Ut(r,d),Fe(h,s,t,p),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!ft(b)||vf(S))&&!v&&!k),Fe(g)),([,y])=>{Qn(c,()=>{Pe(p,!0)}),kf(4,()=>{Qn(o,()=>{Pe(h,!0)}),Pe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},jt(ua,cn,Qs,dr),{singleton:!0});function Kv(t,r){return Math.abs(t-r)<1.01}const Gs="up",Bs="down",ik="none",ok={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},ck=0,Js=et(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ve(!1),h=ve(!0),g=Xe(),p=Xe(),y=ve(4),v=ve(ck),b=nn(me(Qd(me(ze(c),Ur(1),ia(!0)),me(ze(c),Ur(1),ia(!1),og(100))),bt()),!1),S=nn(me(Qd(me(s,ia(!0)),me(s,ia(!1),og(200))),bt()),!1);Re(me(Ut(ze(c),ze(v)),ke(([T,A])=>T<=A),bt()),h),Re(me(h,Aa(50)),p);const k=Nn(me(Ut(o,ze(u),ze(r),ze(t),ze(y)),oa((T,[{scrollHeight:A,scrollTop:B},D,F,w,O])=>{const z=B+D-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:D};if(z){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":D<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},ok),bt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=nn(me(o,oa((T,{scrollHeight:A,scrollTop:B,viewportHeight:D})=>{if(!Kv(T.scrollHeight,A)){const F=A-(B+D)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Re(me(k,ke(T=>T.atBottom)),d),Re(me(d,Aa(50)),g);const C=ve(Bs);Re(me(o,ke(({scrollTop:T})=>T),bt(),oa((T,A)=>wt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Gs:Bs,prevScrollTop:A},{direction:Bs,prevScrollTop:0}),ke(T=>T.direction)),C),Re(me(o,Aa(50),ia(ik)),C);const N=ve(0);return Re(me(b,De(T=>!T),ia(0)),N),Re(me(c,Aa(100),Fe(b),De(([T,A])=>A),oa(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},jt(cn)),Ws="top",qs="bottom",fg="none";function pg(t,r,s){return typeof t=="number"?s===Gs&&r===Ws||s===Bs&&r===qs?t:0:s===Gs?r===Ws?t.main:t.reverse:r===qs?t.main:t.reverse}function mg(t,r){return typeof t=="number"?t:t[r]??0}const Cf=et(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Xe(),d=ve(0),h=ve(0),g=ve(0),p=nn(me(Ut(ze(o),ze(c),ze(s),ze(u,Ps),ze(g),ze(d),ze(r),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,D=C+N,F=Math.max(b-B,0);let w=fg;const O=mg(A,Ws),z=mg(A,qs);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+D-O&&(w=Gs),k<y-F+v+z&&(w=Bs),w!==fg?[Math.max(B-b-pg(E,Ws,w)-O,0),B-F-N+v+pg(E,qs,w)+z]:null}),De(y=>y!==null),bt(Ps)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},jt(cn),{singleton:!0});function uk(t,r,s){if(Yo(r)){const o=Gv(t,r);return[{index:Jn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const kd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Mo(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=p,k=b-y;return{bottom:y,firstItemIndex:u,items:hg(t,c,u),offsetBottom:k,offsetTop:p,top:S,topItems:hg(r,c,u),topListHeight:r.reduce((E,C)=>C.size+E,0),totalCount:s}}function Xv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=wf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Mo(p,[],h,c,s,o)}function hg(t,r,s){if(t.length===0)return[];if(!Yo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Al(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function xg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Vr=et(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ve([]),C=ve(0),N=Xe(),T=ve(0);Re(u.topItemsIndexes,E);const A=nn(me(Ut(S,k,ze(g,Ps),ze(c),ze(o),ze(p),y,ze(E),ze(r),ze(s),ze(T),t),De(([w,O,,z,,,,,,,,U])=>{const H=U!==void 0&&U.length!==z;return w&&!O&&!H}),ke(([,,[w,O],z,U,H,q,X,J,$,L,_])=>{var Se,Ae;const I=U,{offsetTree:V,sizeTree:se}=I,M=wt(C);if(z===0)return{...kd,totalCount:z};if(w===0&&O===0)return M===0?{...kd,totalCount:z}:Xv(M,H,U,J,$,_||[]);if(ft(se))return M>0?null:Mo(uk(wf(H,z),I,_),[],z,$,I,J);const Y=[];if(X.length>0){const _e=X[0],re=X[X.length-1];let he=0;for(const pe of Al(se,_e,re)){const ge=pe.value,je=Math.max(pe.start,_e),Be=Math.min(pe.end,re);for(let Oe=je;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:ge}),he+=ge}}if(!q)return Mo([],Y,z,$,I,J);const W=X.length>0?X[X.length-1]+1:0,te=Z2(V,w,O,W);if(te.length===0)return null;const fe=z-1,ie=qo([],_e=>{for(const re of te){const he=re.value;let pe=he.offset,ge=re.start;const je=he.size;if(he.offset<w){ge+=Math.floor((w-he.offset+$)/(je+$));const Oe=ge-re.start;pe+=Oe*je+Oe*$}ge<W&&(pe+=(W-ge)*je,ge=W);const Be=Math.min(re.end,fe);for(let Oe=ge;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:je}),pe+=je+$}}),ye=xg(L,Ws),de=xg(L,qs);if(ie.length>0&&(ye>0||de>0)){const _e=ie[0],re=ie[ie.length-1];if(ye>0&&_e.index>W){const he=Math.min(ye,_e.index-W),pe=[];let ge=_e.offset;for(let je=_e.index-1;je>=_e.index-he;je--){const Be=((Se=Al(se,je,je)[0])==null?void 0:Se.value)??_e.size;ge-=Be+$,pe.unshift({data:_==null?void 0:_[je],index:je,offset:ge,size:Be})}ie.unshift(...pe)}if(de>0&&re.index<fe){const he=Math.min(de,fe-re.index);let pe=re.offset+re.size+$;for(let ge=re.index+1;ge<=re.index+he;ge++){const je=((Ae=Al(se,ge,ge)[0])==null?void 0:Ae.value)??re.size;ie.push({data:_==null?void 0:_[ge],index:ge,offset:pe,size:je}),pe+=je+$}}}return Mo(ie,Y,z,$,I,J)}),De(w=>w!==null),bt()),kd);Re(me(t,De(vf),ke(w=>w==null?void 0:w.length)),c),Re(me(A,ke(w=>w.topListHeight)),v),Re(v,h),Re(me(A,ke(w=>[w.top,w.bottom])),d),Re(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Fe(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),bt(Ps),ke(([w])=>w))),D=Nn(me(A,Aa(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),bt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,z=w.length-1;for(;w[O].type==="group"&&O<z;)O++;for(;w[z].type==="group"&&z>O;)z--;return{endIndex:w[z].index,startIndex:w[O].index}}),bt(Pv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:D,topItemsIndexes:E,...b}},jt(ua,qv,Cf,Zs,Qs,Js,dr,jf),{singleton:!0}),Qv=et(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Xe(),d=nn(me(Ut(s,t,o,r,c),ke(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Re(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},jt(cn,Vr),{singleton:!0}),dk=et(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ve(!1),o=nn(me(Ut(s,t,r),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Aa(0),bt()),0);return{alignToBottom:s,paddingTopAddition:o}},jt(cn,Qv),{singleton:!0}),Zv=et(()=>({context:ve(null)})),fk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Jv=et(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Xe();return Re(me(y,Fe(r,g,s,u,c,o,h),Fe(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=fk,done:D,...F}=v,w=Wv(v,b,k-1),O=Fs(w,b.offsetTree,A)+E+C,z=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:z,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?D&&Qn(me(d,De(X=>!X),Ur(wt(d)?1:2)),D):D==null||D(),q}),De(v=>v!==null)),p),{scrollIntoView:y}},jt(ua,cn,Qs,Vr,ur),{singleton:!0});function gg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const pk=(t,r)=>typeof t=="function"?gg(t(r)):r&&gg(t),mk=et(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ve(!1),E=Xe();let C=null;function N(D){Pe(d,{align:"end",behavior:D,index:"LAST"})}at(me(Ut(me(ze(r),Ur(1)),g),Fe(ze(k),u,h,v),ke(([[D,F],w,O,z,U])=>{let H=F&&z,q="auto";return H&&(q=pk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:D}}),De(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:F})=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D)}):C=Qn(t,()=>{wt(y)("following output to ",{totalCount:F},Pt.DEBUG),N(D),C=null})});function T(D){const F=Qn(c,w=>{D&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(wt(y)("scrolling to bottom due to increased size",{},Pt.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ut(ze(k),r,p),De(([D,,F])=>D!==!1&&F),oa(({value:D},[,F])=>({refreshed:D===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:D})=>D),Fe(k,r)),([,D])=>{wt(h)&&T(D!==!1)}),at(E,()=>{T(wt(k)!==!1)}),at(Ut(ze(k),c),([D,F])=>{D!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ve(null),B=Xe();return Re(Qd(me(ze(o),ke(D=>(D==null?void 0:D.length)??0)),me(ze(r))),B),at(me(Ut(me(B,Ur(1)),g),Fe(ze(A),h,v,b),ke(([[D,F],w,O,z,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:D,scrollingInProgress:z}))),De(D=>!!D),Aa(0)),D=>{C!==null&&(C(),C=null),wt(s)!==void 0?requestAnimationFrame(()=>{wt(y)("scrolling into view",{}),Pe(S,D)}):C=Qn(t,()=>{wt(y)("scrolling into view",{}),Pe(S,D),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},jt(ua,Js,Qs,Zs,dr,ur,cn,Zv,Jv)),hk=et(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(me(h,Fe(u),De(([,g])=>g!==0),Fe(c,o,r,s,t),ke(([[,g],p,y,v,b,S=[]])=>Xv(g,p,y,v,b,S))),d),{}),jt(ua,Zs,Vr,dr),{singleton:!0}),xk=et(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ve(0);return at(me(t,Fe(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ur(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Pe(r,c)})})}),{initialScrollTop:o}},jt(dr,cn,Vr),{singleton:!0}),ey=et(([{scrollVelocity:t}])=>{const r=ve(!1),s=Xe(),o=ve(!1);return Re(me(t,Fe(o,r,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),bt()),r),at(me(Ut(r,t,s),Fe(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},jt(Js),{singleton:!0}),Ef=et(([{scrollContainerState:t,scrollTo:r}])=>{const s=Xe(),o=Xe(),c=Xe(),u=ve(!1),d=ve(void 0);return Re(me(Ut(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Re(me(r,Fe(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},jt(cn)),gk=et(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Xe(),y=ve(void 0),v=ve(null),b=ve(null);return Re(h,v),Re(g,b),at(me(p,Fe(r,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=ek(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Re(me(y,De(vf),ke(vk)),c),Re(me(u,Fe(y),De(([,S])=>S!==void 0),bt(),ke(([,S])=>S.ranges)),t),{getState:p,restoreStateFrom:y}},jt(ua,cn,Zs,dr,Ef));function vk(t){return{align:"start",index:0,offset:t.scrollTop}}const yk=et(([{topItemsIndexes:t}])=>{const r=ve(0);return Re(me(r,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},jt(Vr));function ty(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const bk=ty(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),jk=et(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Fe(d),oa(([,N,T,A],[{bottom:B,items:D,offsetBottom:F,totalCount:w},O])=>{const z=B+F;let U=0;return T===w&&N.length>0&&D.length>0&&(D[0].originalIndex===0&&N[0].originalIndex===0||(U=z-A,U!==0&&(U+=O))),[U,D,w,z]},[0,[],0,0]),De(([N])=>N!==0),Fe(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Gs),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Pt.DEBUG),N))));function C(N){N>0?(Pe(r,{behavior:"auto",top:-N}),Pe(t,0)):(Pe(t,0),Pe(r,{behavior:"auto",top:-N}))}return at(me(E,Fe(t,u)),([N,T,A])=>{A&&bk()?Pe(t,T-N):C(-N)}),at(me(Ut(nn(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Aa(1)),C),Re(me(v,ke(N=>({top:-N}))),r),at(me(p,Fe(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},D])=>{function F(H){return H*(A+D)}if(T.length===0)return F(N);let w=0;const O=Vs(B,0);let z=0,U=0;for(;z<N;){z++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;z+H>N&&(w-=O,H=N-z+1),z+=H,w+=F(H),U++}return w})),N=>{Pe(t,N),requestAnimationFrame(()=>{Pe(r,{top:N}),requestAnimationFrame(()=>{Pe(t,0),Pe(k,!1)})})}),{deviation:t}},jt(cn,Js,Vr,ua,ur,jf)),Sk=et(([t,r,s,o,c,u,d,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...p,...y}),jt(Cf,hk,dr,ey,Qv,xk,dk,Ef,Jv,ur,Zv)),ny=et(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:D},F,{topItemCount:w},{groupCounts:O},z])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Re(X,z.scrollSeekRangeChanged),Re(me(z.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:p,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:D,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...z,...N,sizes:y,...T}},jt(ua,Zs,cn,gk,mk,Vr,Qs,jk,yk,qv,Sk));function kk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const vo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function ay(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Te.createContext({});function g(C,N){C.propsReady!==void 0&&Pe(C.propsReady,!1);for(const T of o){const A=C[r.required[T]];Pe(A,N[T])}for(const T of c)if(T in N){const A=C[r.optional[T]];Pe(A,N[T])}C.propsReady!==void 0&&Pe(C.propsReady,!0)}function p(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[r.methods[T]];Pe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=U2(C[r.events[T]]),N),{})}const v=Te.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Te.useState(()=>qo($2(t),w=>{g(w,A)})),[D]=Te.useState(ig(y,B));vo(()=>{for(const w of d)w in A&&at(D[w],A[w]);return()=>{Object.values(D).map(yf)}},[A,D,B]),vo(()=>{g(B,A)}),Te.useImperativeHandle(N,sg(p(B)));const F=s;return a.jsx(h.Provider,{value:B,children:s!==void 0?a.jsx(F,{...kk([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Te.useContext(h);return Te.useCallback(T=>{Pe(N[C],T)},[N,C])},S=C=>{const N=Te.useContext(h)[C],T=Te.useCallback(A=>at(N,A),[N]);return Te.useSyncExternalStore(T,()=>wt(N),()=>wt(N))},k=C=>{const N=Te.useContext(h)[C],[T,A]=Te.useState(ig(wt,N));return vo(()=>at(N,B=>{B!==T&&A(sg(B))}),[N,T]),T},E=parseInt(Te.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Te.useContext(h)[C];vo(()=>at(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const ry=Te.createContext(void 0),ly=Te.createContext(void 0),wd="-webkit-sticky",vg="sticky",Nf=ty(()=>{if(typeof document>"u")return vg;const t=document.createElement("div");return t.style.position=wd,t.style.position===wd?wd:vg}),sy=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Cd(t){return"self"in t}function wk(t){return"body"in t}function iy(t,r,s,o=Ol,c,u){const d=Te.useRef(null),h=Te.useRef(null),g=Te.useRef(null),p=Te.useCallback(b=>{let S,k,E;const C=b.target;if(wk(C)||Cd(C)){const T=Cd(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Pj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Te.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Cd(S)?(C=Math.max(ir(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ir(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Kv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&r(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Tf(t){return t}const Ck=et(()=>{const t=ve(h=>`Item ${h}`),r=ve(h=>`Group ${h}`),s=ve({}),o=ve(Tf),c=ve("div"),u=ve(Ol),d=(h,g=null)=>nn(me(s,ke(p=>p[h]),bt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),Ek=et(([t,r])=>({...t,...r}),jt(ny,Ck)),Nk=({height:t})=>a.jsx("div",{style:{height:t}}),Tk={overflowAnchor:"none",position:Nf(),zIndex:1},oy={overflowAnchor:"none"},Rk={...oy,display:"inline-block",height:"100%"},yg=Te.memo(function({showTopList:t=!1}){const r=Ue("listState"),s=Pn("sizeRanges"),o=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=Ue("itemContent"),p=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),k=Pn("gap"),E=Ue("horizontalDirection"),{callbackRef:C}=F2(s,b,v,t?Ol:h,S,k,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Rf("deviation",J=>{N!==J&&T(J)});const A=Ue("EmptyPlaceholder"),B=Ue("ScrollSeekPlaceholder")??Nk,D=Ue("ListComponent"),F=Ue("ItemComponent"),w=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),U=Ue("groupIndices").length>0,H=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&A!==null&&A!==void 0?a.jsx(A,{...tn(A,p)}):a.jsx(D,{...tn(D,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(J=>{const $=J.originalIndex,L=O($+r.firstItemIndex,J.data,p);return z?m.createElement(B,{...tn(B,p),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?m.createElement(w,{...tn(w,p),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:Tk},y(J.index,p)):m.createElement(F,{...tn(F,p),...zk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Rk:oy},U?g(J.index,J.groupIndex,J.data,p):g(J.index,J.data,p))})})}),Ak={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Mk={outline:"none",overflowX:"auto",position:"relative"},Ko=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Lk={position:Nf(),top:0,width:"100%",zIndex:1};function tn(t,r){if(typeof t!="string")return{context:r}}function zk(t,r){return{item:typeof t=="string"?void 0:r}}const Dk=Te.memo(function(){const t=Ue("HeaderComponent"),r=Pn("headerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),_k=Te.memo(function(){const t=Ue("FooterComponent"),r=Pn("footerHeight"),s=Ue("HeaderFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null});function cy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=iy(h,p,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Mk:Ak,...c},tabIndex:0,...d,...tn(g,u),children:o})})}function uy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Te.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),S=Te.useRef(null),k=r("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=iy(h,p,g,k,b);return sy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),a.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...tn(g,u),children:o})})}const Ok=({children:t})=>{const r=Te.useContext(ry),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Te.useMemo(()=>_v(s,g=>ir(g,u?"width":"height")),[s,u]),h=$r(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Ko(c),children:t})},Bk=({children:t})=>{const r=Te.useContext(ry),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=Ue("customScrollParent"),u=Bv(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Te.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Ko(d),children:t})},Ik=({children:t})=>{const r=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),o={...Lk,marginTop:`${s}px`},c=Ue("context");return a.jsx(r,{style:o,...tn(r,c),children:t})},Uk=Te.memo(function(t){const r=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,o=Ue("customScrollParent"),c=Ue("context");return a.jsxs(o||r?Vk:$k,{...t,context:c,children:[s&&a.jsx(Ik,{children:a.jsx(yg,{showTopList:!0})}),a.jsxs(o||r?Bk:Ok,{children:[a.jsx(Dk,{}),a.jsx(yg,{}),a.jsx(_k,{})]})]})}),{Component:Hk,useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}=ay(Ek,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Uk),$k=cy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Vk=uy({useEmitter:Rf,useEmitterValue:Ue,usePublisher:Pn}),Pk=Hk,Fk=et(()=>{const t=ve(p=>a.jsxs("td",{children:["Item $",p]})),r=ve(null),s=ve(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ve(null),c=ve(null),u=ve({}),d=ve(Tf),h=ve(Ol),g=(p,y=null)=>nn(me(u,ke(v=>v[p]),bt()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});jt(ny,Fk);Nf();const bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Gk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:jg,floor:Bo,max:Is,min:Ed,round:Sg}=Math;function kg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Wk(t){return{...Gk,items:t}}function yo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function qk(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Yk=et(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},D])=>{const F=ve(0),w=ve(0),O=ve(bg),z=ve({height:0,width:0}),U=ve({height:0,width:0}),H=Xe(),q=Xe(),X=ve(0),J=ve(null),$=ve({column:0,row:0}),L=Xe(),_=Xe(),I=ve(!1),V=ve(0),se=ve(!0),M=ve(!1),Y=ve(!1);at(me(k,Fe(V),De(([de,Se])=>Se!==0)),()=>{Pe(se,!1)}),at(me(Ut(k,se,U,z,V,M),De(([de,Se,Ae,_e,,re])=>de&&!Se&&Ae.height!==0&&_e.height!==0&&!re)),([,,,,de])=>{Pe(M,!0),kf(1,()=>{Pe(H,de)}),Qn(me(p),()=>{Pe(r,[0,0]),Pe(se,!0)})}),Re(me(_,De(de=>de!=null&&de.scrollTop>0),ia(0)),w),at(me(k,Fe(_),De(([,de])=>de!=null)),([,de])=>{de&&(Pe(z,de.viewport),Pe(U,de.item),Pe($,de.gap),de.scrollTop>0&&(Pe(I,!0),Qn(me(p,Ur(1)),Se=>{Pe(I,!1)}),Pe(g,{top:de.scrollTop})))}),Re(me(z,ke(({height:de})=>de)),v),Re(me(Ut(ze(z,yo),ze(U,yo),ze($,(de,Se)=>de!==void 0&&de.column===Se.column&&de.row===Se.row),ze(p)),ke(([de,Se,Ae,_e])=>({gap:Ae,item:Se,scrollTop:_e,viewport:de}))),L),Re(me(Ut(ze(F),o,ze($,qk),ze(U,yo),ze(z,yo),ze(J),ze(w),ze(I),ze(se),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[Se,Ae],_e,re,he,pe,ge,,je,Be])=>{const{column:Oe,row:rt}=_e,{height:Nt,width:ht}=re,{width:Dt}=he;if(ge===0&&(de===0||Dt===0))return bg;if(ht===0){const Gt=wf(Be,de),an=Gt+Math.max(ge-1,0);return Wk(kg(Gt,an,pe))}const Tt=dy(Dt,ht,Oe);let Qe,tt;je?Se===0&&Ae===0&&ge>0?(Qe=0,tt=ge-1):(Qe=Tt*Bo((Se+rt)/(Nt+rt)),tt=Tt*jg((Ae+rt)/(Nt+rt))-1,tt=Ed(de-1,Is(tt,Tt-1)),Qe=Ed(tt,Is(0,Qe))):(Qe=0,tt=-1);const be=kg(Qe,tt,pe),{bottom:pt,top:Ct}=wg(he,_e,re,be),Yt=jg(de/Tt),un=Yt*Nt+(Yt-1)*rt-pt;return{bottom:pt,itemHeight:Nt,items:be,itemWidth:ht,offsetBottom:un,offsetTop:Ct,top:Ct}})),O),Re(me(J,De(de=>de!==null),ke(de=>de.length)),F),Re(me(Ut(z,U,O,$),De(([de,Se,{items:Ae}])=>Ae.length>0&&Se.height!==0&&de.height!==0),ke(([de,Se,{items:Ae},_e])=>{const{bottom:re,top:he}=wg(de,_e,Se,Ae);return[he,re]}),bt(Ps)),r);const W=ve(!1);Re(me(p,Fe(W),ke(([de,Se])=>Se||de!==0)),W);const te=Nn(me(Ut(O,F),De(([{items:de}])=>de.length>0),Fe(W),De(([[de,Se],Ae])=>{const _e=de.items[de.items.length-1].index===Se-1;return(Ae||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===Se)&&_e}),ke(([[,de]])=>de-1),bt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ia(0),bt())),ie=Nn(me(ze(O),Fe(I),De(([{items:de},Se])=>de.length>0&&!Se),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),bt(Pv),Aa(0)));Re(ie,S.scrollSeekRangeChanged),Re(me(H,Fe(z,U,F,$),ke(([de,Se,Ae,_e,re])=>{const he=Yv(de),{align:pe,behavior:ge,offset:je}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=Is(0,Be,Ed(_e-1,Be));let Oe=nf(Se,re,Ae,Be);return pe==="end"?Oe=Sg(Oe-Se.height+Ae.height):pe==="center"&&(Oe=Sg(Oe-Se.height/2+Ae.height/2)),je!==void 0&&je!==0&&(Oe+=je),{behavior:ge,top:Oe}})),g);const ye=nn(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Re(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),z),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ye,...b,endReached:te,propsReady:E,rangeChanged:ie,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...D}},jt(Cf,cn,Js,ey,dr,Ef,ur));function dy(t,r,s){return Is(1,Bo((t+s)/(Bo(r)+s)))}function wg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=nf(t,r,s,o[0].index);return{bottom:nf(t,r,s,o[o.length-1].index)+c,top:u}}function nf(t,r,s,o){const c=dy(t.width,s.width,r.column),u=Bo(o/c),d=u*s.height+Is(0,u-1)*r.row;return d>0?d+r.row:d}const Kk=et(()=>{const t=ve(v=>`Item ${v}`),r=ve({}),s=ve(null),o=ve("virtuoso-grid-item"),c=ve("virtuoso-grid-list"),u=ve(Tf),d=ve("div"),h=ve(Ol),g=(v,b=null)=>nn(me(r,ke(S=>S[v]),bt()),b),p=ve(!1),y=ve(!1);return Re(ze(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Xk=et(([t,r])=>({...t,...r}),jt(Yk,Kk)),Qk=Te.memo(function(){const t=kt("gridState"),r=kt("listClassName"),s=kt("itemClassName"),o=kt("itemContent"),c=kt("computeItemKey"),u=kt("isSeeking"),d=Fn("scrollHeight"),h=kt("ItemComponent"),g=kt("ListComponent"),p=kt("ScrollSeekPlaceholder"),y=kt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=kt("log"),k=kt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=$r(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:D}=A.getBoundingClientRect();v({height:B,width:D})}b({column:Cg("column-gap",getComputedStyle(N).columnGap,S),row:Cg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return sy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:a.jsx(g,{className:r,ref:C,...tn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?a.jsx(p,{...tn(p,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(h,{...tn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),Zk=Te.memo(function(){const t=kt("HeaderComponent"),r=Fn("headerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),Jk=Te.memo(function(){const t=kt("FooterComponent"),r=Fn("footerHeight"),s=kt("headerFooterTag"),o=$r(Te.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=kt("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...tn(t,c)})}):null}),ew=({children:t})=>{const r=Te.useContext(ly),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=$r(Te.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Te.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Ko(!1),children:t})},tw=({children:t})=>{const r=Te.useContext(ly),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=kt("customScrollParent"),u=Bv(s,c,!1);return Te.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Ko(!1),children:t})},nw=Te.memo(function({...t}){const r=kt("useWindowScroll"),s=kt("customScrollParent"),o=s||r?rw:aw,c=s||r?tw:ew,u=kt("context");return a.jsx(o,{...t,...tn(o,u),children:a.jsxs(c,{children:[a.jsx(Zk,{}),a.jsx(Qk,{}),a.jsx(Jk,{})]})})}),{useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}=ay(Xk,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},nw),aw=cy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn}),rw=uy({useEmitter:fy,useEmitterValue:kt,usePublisher:Fn});function Cg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Pt.WARN),r==="normal"?0:parseInt(r??"0",10)}const lw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},py={source:"Own",installed:"Installed"};function sw(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function iw(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Eg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=lw[t],[d,h]=m.useState(()=>sw(u)),g=m.useCallback(()=>{h(b=>{const S=!b;return iw(u,S),S})},[u]),p=py[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(cw,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(ow,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function ow({origin:t,updateCount:r}){const[s,o]=m.useState(!1),c=py[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function cw({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Af(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function uw({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function dw({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function fw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function pw({skillId:t,trackedForUpdates:r}){let s=null;try{s=m.useContext(Cv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function ei(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function mw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(ei,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(dw,{target:t.symlinkTarget??null}),a.jsx(fw,{skill:t}),a.jsx(pw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Io=m.memo(mw);function hw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Io,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function xw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function Ng({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=r??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>xw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>a.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const Lo=new Map,Br=new Map,Ds=new Map;function Tn(t){Lo.delete(t),Br.delete(t);const r=Ds.get(t);if(r)for(const s of r)s()}function ti(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>Tn(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Ds.has(t)||Ds.set(t,new Set),Ds.get(t).add(b),()=>{var S;(S=Ds.get(t))==null||S.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=Lo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Br.has(t)){const C=Br.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=r().then(C=>{Lo.set(t,{data:C,fetchedAt:Date.now()}),Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Br.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Br.set(t,k)},[t,r,o,c]);const p=Lo.get(t),y=c&&!p&&Br.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}function gw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),zv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Nd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Nd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Nd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Nd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Tg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(vw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function vw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function yw(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function bw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function jw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function Sw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function af(t,r={}){const{enabled:s=!0,target:o}=r,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(bw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=jw(p.target);for(const v of c.current){if(!Sw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const kw=200;function ww(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function Cw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Af(g,r)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Ew(t,r){const s=[],o=[],c=[];for(const d of t){const h=ww(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Af(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function Nw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Af(y,r)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Tw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(W=>W.scope!==void 0&&W.scope!==null),k=g??"claude-cli",[E,C]=m.useState(""),N=m.useDeferredValue(E),T=m.useMemo(()=>Ew(t,N),[t,N]),A=m.useMemo(()=>Cw(t,N),[t,N]),B=k==="claude-code",{plugins:D}=z2(),F=B?{plugins:D??[]}:void 0,w=m.useMemo(()=>{const W=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=W.get(te.name);W.set(te.name,!!fe||!!te.enabled)}return W},[F==null?void 0:F.plugins]),[O,z]=m.useState(()=>rf(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=m.useState(()=>rf(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=m.useCallback(W=>{z(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(W))}catch{}},[k]),X=m.useCallback(W=>{H(W);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(W))}catch{}},[k]),{own:J,installed:$}=m.useMemo(()=>Nw(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=kw,I=m.useMemo(()=>{const W=te=>{const fe=[];for(const[,ie]of te){const ye=[...ie].sort((de,Se)=>de.skill.localeCompare(Se.skill));fe.push(...ye)}return fe};return S?[...W(T.own.byPlugin),...W(T.installed.byPlugin),...W(T.global.byPlugin)]:[...W(J.byPlugin),...W($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=m.useMemo(()=>r?I.findIndex(W=>W.plugin===r.plugin&&W.skill===r.skill):-1,[I,r]),se=m.useCallback(W=>{if(I.length===0)return;const te=V<0?W>0?0:I.length-1:Math.min(Math.max(V+W,0),I.length-1);s(I[te])},[I,V,s]),M=m.useMemo(()=>{if(!v)return null;const[W,te]=v.split("/");if(!W||!te)return null;const fe=t.find(de=>de.plugin===W&&de.skill===te);if(!fe)return{plugin:W,skill:te,bucket:null,pluginName:null};const ie=fe.source==="plugin"?"plugin":"project",ye=ie==="plugin"?fe.pluginName??W:null;return{plugin:W,skill:te,bucket:ie,pluginName:ye}},[v,t]),Y=m.useRef(null);return m.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const W=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${W}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),af([{key:"j",handler:()=>se(1)},{key:"k",handler:()=>se(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(uw,{value:E,onChange:C}),o&&a.jsx(zw,{}),!o&&c&&a.jsx(Dw,{error:c,onRetry:u}),!o&&!c&&S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Tg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?a.jsx(Ag,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Ms,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:A.availablePersonal.filtered===0?a.jsx(Aw,{queryActive:!!E,agentId:k}):a.jsx(Ls,{items:A.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsxs(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-available-${W}-collapsed`,headerActionSlot:B?a.jsx(gw,{pluginName:W,enabled:w.get(W)??!0}):void 0,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${W}`))]})]}),a.jsx(Lw,{}),a.jsx(Tg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&a.jsxs(a.Fragment,{children:[a.jsx(Ms,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:A.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&a.jsx(Ms,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([W,te])=>a.jsx(Ng,{pluginName:W,skills:te,persistKey:`vskill-plugin-authoring-${W}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===W,renderSkill:fe=>a.jsx(Io,{skill:fe,isSelected:(r==null?void 0:r.plugin)===fe.plugin&&(r==null?void 0:r.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${W}`))})]})]}),!o&&!c&&!S&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Eg,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?a.jsx(Rg,{queryActive:!!E}):a.jsx(Ls,{items:J.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})}),a.jsx(Mw,{}),a.jsx(Eg,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?a.jsx(Ag,{queryActive:!!E}):a.jsx(Ls,{items:$.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function rf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ms({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>rf(r)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(S))}catch{}return S})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function Rw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ls({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Rw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Pk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Io,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(hw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Rg({queryActive:t}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Mf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ag({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install <skill>"})," to add one."]})})}function Aw({queryActive:t,agentId:r}){return t?a.jsx(Ml,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Ml,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Mf,{children:"vskill install --global <skill>"})," to add one."]})})}function Ml({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Mf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Mw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Lw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function zw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(yw,{},t))})}function Dw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:_w(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function _w(t){const r=t.split(`
|
|
66
66
|
`)[0]??t;return r.length>80?r.slice(0,77)+"…":r}const my=240,hy=480,xy="vskill-sidebar-width",Us=320;function Lf(t){return Number.isFinite(t)?Math.round(Math.max(my,Math.min(hy,t))):Us}function Ow(){try{const t=localStorage.getItem(xy);if(!t)return Us;const r=Number(t);return Number.isFinite(r)?Lf(r):Us}catch{return Us}}function Bw(t){try{localStorage.setItem(xy,String(Lf(t)))}catch{}}function Iw({initialWidth:t,onChange:r}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),o=m.useRef(t);return m.useEffect(()=>{o.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=Lf(s.current.startWidth+h);o.current=g,r(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Bw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[r]),a.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":my,"aria-valuemax":hy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Uw({connected:t,hint:r,onRetry:s}){return t?null:a.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),a.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&a.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),a.jsx("div",{style:{flex:1}}),s&&a.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function gy(t,r){if(t!==401||typeof window>"u"||!r||typeof r!="object")return;const s=r;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function vy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(r){console.error("Failed to serialize request body:",r);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Td(){const[t,r]=m.useState([]),[s,o]=m.useState(!1),[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useCallback(async(v,b)=>{r([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=vy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw gy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
|
|
67
67
|
`);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};A==="done"?(u(!0),r(U=>[...U,z])):r(U=>[...U,z])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=m.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:p,stop:y}}function Hw(t){const r=m.useRef(t);r.current=t;const[s,o]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(p,y,v)=>{var S;(S=c.current.get(p))==null||S.abort();const b=new AbortController;c.current.set(p,b),o(k=>{const E=new Set(k);return E.add(p),E});try{const k=vy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,D;try{D=await E.json(),D&&typeof D=="object"&&"error"in D&&typeof D.error=="string"&&(B=D.error)}catch{}throw gy(E.status,D),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:D}=await C.read();if(B)break;T+=N.decode(D,{stream:!0});const F=T.split(`
|
|
68
68
|
`);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),z={event:A,data:O};r.current.onEvent(p,z)}catch{}A=""}}r.current.onDone(p)}catch(k){k.name!=="AbortError"&&r.current.onError(p,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(p),E}),c.current.delete(p)}},[]),d=m.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=m.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const $w={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Vw(t,r){var s,o;switch(r.type){case"SET_LOADING":return{...t,loading:r.loading};case"SET_ERROR":return{...t,error:r.error};case"INIT_DATA":{const c=new Map;if(r.benchmark)for(const d of r.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=r.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:r.panel};case"SET_CONTENT":return{...t,skillContent:r.content,isDirty:r.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:r.evals};case"SELECT_CASE":return{...t,selectedCaseId:r.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...t,caseRunStates:c,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,r.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);return c.set(r.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of r.caseIds)c.set(u,{status:"queued",mode:r.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:r.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(r.evalId,r.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const c=r.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(r.index,!c.get(r.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:r.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:r.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,r.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:r.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:r.runs,activationHistoryLoading:!1};default:return t}}function Pw(t){if(t==="unit"||t==="integration")return t}function Fw(t,r){const s=r.data;if(r.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),r.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),r.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}r.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const yy=m.createContext(null);function An(){const t=m.useContext(yy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Gw({plugin:t,skill:r,origin:s,children:o}){const c=s==="installed",[u,d]=m.useReducer(Vw,{...$w,plugin:t,skill:r}),h=m.useRef(new Set),g=m.useRef(new Set),p=m.useRef(new Map),y=m.useCallback((re,he)=>{let pe=p.current.get(re);pe||(pe={assertions:[]},p.current.set(re,pe)),Fw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:re,result:{...pe,assertions:[...pe.assertions]}})},[]),v=m.useCallback(re=>{if(g.current.has(re))return;g.current.add(re);const he=p.current.get(re)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:re,result:{...he,assertions:[...he.assertions]}}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,r]),b=m.useCallback((re,he)=>{g.current.has(re)||(g.current.add(re),d({type:"CASE_RUN_ERROR",caseId:re,error:he}),h.current.has(re)&&(h.current.delete(re),h.current.size===0&&Ce.getLatestBenchmark(t,r).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,r]),{startCase:S,stopCase:k,stopAll:E}=Hw({onEvent:y,onDone:v,onError:b});m.useEffect(()=>()=>{E()},[E]);const C=m.useCallback(async()=>{try{const re=await fetch(`/api/skills/${t}/${r}/activation-history`);if(!re.ok){if(re.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await re.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,r]);m.useEffect(()=>{let re=!1;async function he(){try{const[pe,ge,je]=await Promise.allSettled([Ce.getSkillDetail(t,r),Ce.getEvals(t,r),Ce.getLatestBenchmark(t,r)]);if(re)return;let Be=null,Oe=null;if(ge.status==="fulfilled")Be=ge.value;else{const rt=ge.reason;Oe=(rt==null?void 0:rt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:je.status==="fulfilled"?je.value:null})}catch(pe){re||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{re=!0}},[t,r,C]);const N=m.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,r,u.skillContent),d({type:"CONTENT_SAVED"})}catch(re){d({type:"SET_ERROR",error:re.message})}},[c,t,r,u.skillContent]),T=m.useCallback(async re=>{if(!c)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,r]),A=m.useCallback((re,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(re);if((pe==null?void 0:pe.status)!=="running")if(p.current.delete(re),g.current.delete(re),d({type:"CASE_RUN_START",caseId:re,mode:he}),he==="comparison"){const ge=`/api/skills/${t}/${r}/compare`;S(re,ge,{eval_ids:[re]})}else{const ge=`/api/skills/${t}/${r}/benchmark/case/${re}`;S(re,ge,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.caseRunStates,S]),B=m.useCallback((re="benchmark")=>{var ge;if(c)return;const he=((ge=u.evals)==null?void 0:ge.evals)??[];if(he.length===0)return;const pe=he.map(je=>je.id);for(const je of pe)p.current.delete(je),g.current.delete(je);d({type:"BULK_RUN_START",caseIds:pe,mode:re}),h.current=new Set(pe);for(const je of pe)if(re==="comparison")S(je,`/api/skills/${t}/${r}/compare`,{eval_ids:[je]});else{const Be=`/api/skills/${t}/${r}/benchmark/case/${je}`;S(je,Be,re==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.evals,S]),D=m.useCallback(re=>{k(re),d({type:"CASE_RUN_CANCEL",caseId:re}),h.current.delete(re),g.current.add(re)},[k]),F=m.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=m.useCallback(async(re,he)=>{d({type:"OPEN_IMPROVE",evalId:re})},[]),O=m.useCallback(async(re,he)=>{try{await Ce.applyImprovement(t,r,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(re,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,r,A]),z=Td(),U=m.useRef(null),H=m.useRef(0);m.useEffect(()=>{const re=z.events;for(let he=H.current;he<re.length;he++){const pe=re[he],ge=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge.improved,Be=ge.reasoning,Oe=ge.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const je=ge;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}H.current=re.length},[z.events]),m.useEffect(()=>{z.error&&d({type:"AI_EDIT_ERROR",message:z.error})},[z.error]),m.useEffect(()=>()=>{z.stop()},[z.stop]);const q=m.useCallback(async(re,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=z.stop,z.start(`/api/skills/${t}/${r}/improve?sse`,{mode:"instruct",instruction:re,content:u.skillContent,evals:u.evals??{skill_name:r,evals:[]},provider:he,model:pe}))},[c,t,r,u.skillContent,u.evals,z]),X=m.useCallback(()=>{z.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[z]),J=m.useCallback(async()=>{const re=u.aiEditResult;if(re!=null&&re.improved)try{if(await Ce.applyImprovement(t,r,re.improved),d({type:"SET_CONTENT",content:re.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Xs(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),ge=u.evals??{skill_name:r,evals:[]},je=pe(ge,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,r,je);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,r,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=m.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=m.useCallback(re=>{d({type:"TOGGLE_EVAL_CHANGE",index:re})},[]),_=m.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=m.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(async()=>{const re=u.aiEditEvalsRetry;if(re)try{const he=await Ce.saveEvals(t,r,re);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,r,u.aiEditEvalsRetry]),se=m.useCallback(async()=>{try{const re=await Ce.getSkillDetail(t,r);d({type:"SET_CONTENT",content:re.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,r]),{config:M}=Hr(),Y=Td(),W=m.useRef(0);m.useEffect(()=>{const re=Y.events;for(let he=W.current;he<re.length;he++){const pe=re[he],ge=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ge.phase,message:ge.message}}),pe.event==="done"){const je=ge;Ce.saveEvals(t,r,je).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:ge})}W.current=re.length},[Y.events,t,r]),m.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),m.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=m.useCallback(async re=>{if(c)return;W.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Pw(re==null?void 0:re.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${r}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,r,Y,M]),fe=Td(),ie=m.useRef(0);m.useEffect(()=>()=>{fe.stop()},[fe.stop]),m.useEffect(()=>{const re=fe.events;for(let he=ie.current;he<re.length;he++){const pe=re[he];if(pe.event==="classifying"){const ge=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:ge.index,total:ge.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ge=pe.data;if(ge.error)d({type:"ACTIVATION_ERROR",error:ge.error});else{d({type:"ACTIVATION_DONE",summary:ge});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:ge.total,summary:{precision:ge.precision,recall:ge.recall,reliability:ge.reliability,tp:ge.tp,tn:ge.tn,fp:ge.fp,fn:ge.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}ie.current=re.length},[fe.events,M,u.activationHistory]),m.useEffect(()=>{fe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ye=m.useRef(null),de=m.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),Se=m.useCallback(re=>{const pe=re.trim().split(`
|
|
@@ -99,4 +99,4 @@ You are an expert at...
|
|
|
99
99
|
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
100
100
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
101
101
|
}`})]}),document.body)}function _N({agent:t,focused:r,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return a.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),a.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function ON({row:t,onFocus:r}){return a.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),a.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function BN({agent:t}){const r=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return a.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),a.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&a.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function IN({agent:t,activeAgentId:r,onSwitch:s}){const o=t.id===r,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":HN(t.health)})]}),a.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[a.jsx($d,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),a.jsx($d,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),a.jsx($d,{label:ne.scopePicker.statsLastSync,value:t.lastSync?UN(t.lastSync):"—"})]}),a.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function $d({label:t,value:r}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function Zg(){return a.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function UN(t){try{const r=new Date(t).getTime(),s=Date.now()-r;if(Number.isNaN(r))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function HN(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function $N(t){const r=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)r.set(o,s);return t.agents.map(s=>{const o=r.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function VN({agents:t,activeAgentId:r,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useMemo(()=>t.find(S=>S.id===r)??t[0]??null,[t,r]),y=m.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=m.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),a.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&a.jsx(DN,{agents:t,activeAgentId:r,focusedAgentId:d??r,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Vy="vskill-ccode-banner-dismissed",PN=new Set(["claude-cli","claude-code"]);function FN(){try{return sessionStorage.getItem(Vy)==="true"}catch{return!1}}function GN(){try{sessionStorage.setItem(Vy,"true")}catch{}}function WN({activeAgentId:t}){const[r,s]=m.useState(()=>FN()),o=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{GN(),s(!0)},[]);return!t||!PN.has(t)||r?null:a.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function qN(){const[t,r]=m.useState(null),[s,o]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const h=await Ce.getAgents();r(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Co="workspace",YN=["skills","agents"];async function KN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function XN(t){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${r.status}`)}return await r.json()}async function QN(t){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function ZN(t){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${r.status}`)}return await r.json()}function Vd(){for(const t of YN)Tn(t)}function JN(){const{data:t,loading:r,error:s,revalidate:o}=ti(Co,KN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),d=m.useCallback(async p=>{await XN(p),Tn(Co),Vd()},[]),h=m.useCallback(async p=>{await QN(p),Tn(Co),Vd()},[]),g=m.useCallback(async p=>{await ZN(p),Tn(Co),Vd()},[]);return{workspace:c,activeProject:u,loading:r,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function eT({workspace:t,onSwitch:r,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(""),[v,b]=m.useState(null),[S,k]=m.useState(null),[E,C]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),B=(t==null?void 0:t.projects)??[],D=B.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function F(){b(null);const z=p.trim();if(!z){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!z.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(z)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:z}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${z}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),g(!0)}catch{}else g(!0)}function O(z){if(z.length<=50)return z;const U=z.split("/");return U.length<=4?z:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return a.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[a.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(D==null?void 0:D.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(D==null?void 0:D.colorDot)??"var(--text-tertiary, #999)"}}),a.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D?D.name:"No project"}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&a.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[B.length===0&&a.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&a.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(z=>{const U=c?c(z.path):!1,H=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return a.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(z.id),onMouseLeave:()=>k(X=>X===z.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),H&&a.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),a.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),U&&a.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),a.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:X=>{X.stopPropagation(),o(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"}),a.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),a.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&a.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("input",{type:"text",value:p,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&F(),z.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[a.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),a.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),a.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),a.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),a.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function tT(t,r){const s=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function nT({open:t,projects:r,onSwitch:s,onClose:o}){const[c,u]=m.useState(""),[d,h]=m.useState(0),g=m.useMemo(()=>tT(r,c),[r,c]);m.useEffect(()=>{t||(u(""),h(0))},[t]),m.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?a.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[a.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),a.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[a.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),a.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&a.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>a.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[a.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),a.jsxs("span",{className:"flex-1",children:[a.jsx("span",{className:"vskill-palette-name",children:y.name}),a.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const Jg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function aT({open:t,onClose:r,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=m.useState("destination"),[g,p]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[k,E]=m.useState(""),[C,N]=m.useState([]),[T,A]=m.useState(!1),[B,D]=m.useState(null);if(m.useEffect(()=>{t&&(h("destination"),p(s),v(""),S(""),E(""),D(null))},[t,s]),m.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),m.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),r())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,r]),!t)return null;const F=C.length>0,w=o&&F,O=o,z=Jg.test(y),U=g==="existing-plugin"?b.length>0:Jg.test(b),H=!T&&z&&(g==="standalone"||U),q=rT(c,g,b,y);async function X(){D(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){D(V.error??`Check failed: ${I.status}`);return}if(V.exists){D(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){D(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),r()}async function J(){D(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){D(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),r()}catch($){D($ instanceof Error?$.message:String($))}finally{A(!1)}}return a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),a.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[a.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&a.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx(Pd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),a.jsx(Pd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&p("existing-plugin")}),a.jsx(Pd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),d==="details"&&a.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&a.jsx(Eo,{label:"Plugin name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:No(!b||U)})}),g==="existing-plugin"&&a.jsx(Eo,{label:"Plugin",children:a.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...No(!0),fontFamily:"var(--font-mono)"},children:[a.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>a.jsx("option",{value:$.name,children:$.name},$.path))]})}),a.jsx(Eo,{label:"Skill name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:No(!y||z)})}),a.jsx(Eo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:a.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...No(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&a.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>a.jsx("div",{children:$},L))]}),B&&a.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[a.jsx("button",{type:"button",onClick:r,style:Fd,children:"Cancel"}),d==="destination"&&a.jsx("button",{type:"button",onClick:()=>h("details"),style:ev,children:"Continue →"}),d==="details"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>h("destination"),style:Fd,children:"← Back"}),a.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...Fd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),a.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...ev,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Pd({title:t,subtitle:r,description:s,icon:o,selected:c,disabled:u,onClick:d}){return a.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Eo({label:t,hint:r,children:s}){return a.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),r&&a.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),s]})}function No(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const ev={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},Fd={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function rT(t,r,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return r==="standalone"?[`${d}/skills/${c}/SKILL.md`]:r==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:r==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Py(t){return t.trim().toLowerCase()}function lT(t,r){const s=Py(r);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function sT(t,r){const s=Py(r);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function iT({open:t,onClose:r,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=m.useState(null),[h,g]=m.useState([]),[p,y]=m.useState(null),[v,b]=m.useState(null),[S,k]=m.useState(!1),[E,C]=m.useState(null),[N,T]=m.useState(""),[A,B]=m.useState("");m.useEffect(()=>{p?T(""):B("")},[p]);const D=m.useMemo(()=>lT(h,N),[h,N]),F=m.useMemo(()=>sT((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),m.useEffect(()=>{if(!p){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(p)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[p]),m.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&r()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,r]),t?a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),a.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[p&&a.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),a.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:p?(v==null?void 0:v.name)??p:"Browse plugins"}),a.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&a.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!p&&!S&&h.length===0&&!E&&a.jsx(oT,{}),!p&&h.length>0&&a.jsx(tv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!p&&h.length>0&&D.length===0&&a.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!p&&D.map(w=>a.jsxs("button",{type:"button",onClick:()=>y(w.name),style:uT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),p&&v&&a.jsxs(a.Fragment,{children:[v.description&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&a.jsx(tv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&a.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return a.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:a.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?a.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):a.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,p),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!p&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:a.jsx(cT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function tv({value:t,onChange:r,placeholder:s,ariaLabel:o,testId:c}){return a.jsx("div",{style:{padding:"0 4px 10px"},children:a.jsx("input",{type:"search",value:t,onChange:u=>r(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function oT(){return a.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",a.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[a.jsx("li",{children:a.jsx("code",{children:"anthropics/claude-plugins-official"})}),a.jsx("li",{children:a.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function cT({onAdded:t}){const[r,s]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null);async function h(){const g=r.trim();if(g){c(!0),d(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){d(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){d(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{type:"text",value:r,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!r.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!r.trim()?"not-allowed":"pointer",opacity:o||!r.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const uT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Gd=12;function dT({job:t,onDone:r}){const[s,o]=m.useState([]),[c,u]=m.useState("running"),[d,h]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),r({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const D of B){const F=D.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Gd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Gd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),zv(),Tn("skills"),r({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Gd),o(b))}catch{}}}S==="running"&&r({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),r({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return a.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[a.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?a.jsx(fT,{}):p}),a.jsxs("span",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&a.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&a.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
|
|
102
|
-
`)})]})}function fT(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const pT=3e3,mT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function nv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function hT(){const{toast:t}=Df(),r=m.useRef(new Map),s=m.useCallback(o=>{if(!nv(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<pT)return;r.current.set(o.provider,c);const d=mT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!nv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Fy="vskill.studio.prefs";function Gy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Wy(){const t=Gy();if(!t)return{};try{const r=t.getItem(Fy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function xT(t,r){const s=Gy();if(s)try{const c={...Wy(),[t]:r};s.setItem(Fy,JSON.stringify(c))}catch{}}function gT(t,r){const o=Wy()[t];return o===void 0?r:o}const av={open:!1,x:0,y:0,skill:null};function vT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function _r(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function yT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function bT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{_r(ne.toasts.permissionDenied,"error");return}_r(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_r(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_r(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_r(ne.toasts.skillDuplicated,"info");return;case"update":_r(ne.toasts.skillUpdated,"info");return;case"uninstall":_r(ne.actions.editPlaceholder,"info");return;case"delete":yT(r);return;default:return}}function jT(t){return t.startsWith("#/create")}function ST(t){return t.startsWith("#/updates")}function qy(t){const[r,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),r}function kT(){return qy(jT)}function wT(){return qy(ST)}const CT=m.lazy(()=>Xs(()=>import("./CommandPalette-ixp8tj0t.js"),__vite__mapDeps([2,1]))),ET=m.lazy(()=>Xs(()=>import("./CreateSkillPage-Df9oL8J-.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),NT=m.lazy(()=>Xs(()=>Promise.resolve().then(()=>DE),void 0).then(t=>({default:t.UpdatesPanel})));function TT(){return a.jsx(xS,{children:a.jsx(pS,{children:a.jsxs(tN,{children:[a.jsx(RT,{}),a.jsx(xN,{})]})})})}function RT(){var Wn,Et;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ea(),{config:h}=Hr(),{mode:g,resolvedTheme:p,setTheme:y}=Lv(),{toast:v}=Df(),[b,S]=m.useState(()=>Ow()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(vT(oe,xe))},[]),U=qN(),[H,q]=m.useState(()=>gT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),xT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?$N(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=JN(),[se,M]=m.useState(!1),[Y,W]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),W(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const re=LN(),he=re.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),hT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[rt,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>SN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=kN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=rt;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[rt,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),an=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{r({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[r]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=kT(),za=wT()?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(NT,{})}):gt?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(ET,{})}):a.jsx(oN,{selectedSkillInfo:an,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return a.jsxs(a.Fragment,{children:[a.jsx(gS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Uw,{connected:k}),liveMessage:Mt,topRail:a.jsx(h2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?a.jsx(eT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:a.jsx(Tw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?a.jsxs(a.Fragment,{children:[a.jsx(VN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>re.open(oe)}),a.jsx(WN,{activeAgentId:H})]}):null}),resizeHandle:a.jsx(Iw,{initialWidth:b??Us,onChange:S}),main:za,statusBar:a.jsx(E2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(vN,{open:N,onClose:()=>T(!1)}),a.jsx(EN,{open:re.isOpen,providerKey:re.providerKey,onClose:re.close}),a.jsx(bN,{state:w,onClose:pe,onAction:(oe,xe)=>bT(oe,xe)}),E&&a.jsx(m.Suspense,{fallback:null,children:a.jsx(CT,{open:E,onClose:()=>C(!1),commands:xt})}),a.jsx(nT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),a.jsx(aT,{open:Y,onClose:()=>W(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),a.jsx(iT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),a.jsx(Rv,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),a.jsx(dT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),a.jsx(jN,{open:rt!==null,title:rt?`Delete "${rt.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const rv="vskill.migrations.scope-rename.v1",AT={own:"authoring-project",installed:"available-project",global:"available-personal"},MT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function LT(t){if(t.getItem(rv)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(MT);if(!c)continue;const[,u,d]=c,h=AT[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(rv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{LT(window.localStorage)}catch{}f0.createRoot(document.getElementById("root")).render(a.jsx(m.StrictMode,{children:a.jsx(zj,{children:a.jsx(j2,{children:a.jsx(TT,{})})})}));export{Zo as E,kv as L,ni as P,Te as R,RE as S,Hr as a,Wy as b,EE as c,Xo as d,gT as g,a as j,m as r,ne as s,uf as t,Y0 as u,xT as w};
|
|
102
|
+
`)})]})}function fT(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const pT=3e3,mT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function nv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function hT(){const{toast:t}=Df(),r=m.useRef(new Map),s=m.useCallback(o=>{if(!nv(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<pT)return;r.current.set(o.provider,c);const d=mT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!nv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Fy="vskill.studio.prefs";function Gy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Wy(){const t=Gy();if(!t)return{};try{const r=t.getItem(Fy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function xT(t,r){const s=Gy();if(s)try{const c={...Wy(),[t]:r};s.setItem(Fy,JSON.stringify(c))}catch{}}function gT(t,r){const o=Wy()[t];return o===void 0?r:o}const av={open:!1,x:0,y:0,skill:null};function vT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function _r(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function yT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function bT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{_r(ne.toasts.permissionDenied,"error");return}_r(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_r(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_r(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_r(ne.toasts.skillDuplicated,"info");return;case"update":_r(ne.toasts.skillUpdated,"info");return;case"uninstall":_r(ne.actions.editPlaceholder,"info");return;case"delete":yT(r);return;default:return}}function jT(t){return t.startsWith("#/create")}function ST(t){return t.startsWith("#/updates")}function qy(t){const[r,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),r}function kT(){return qy(jT)}function wT(){return qy(ST)}const CT=m.lazy(()=>Xs(()=>import("./CommandPalette-BZekSSlW.js"),__vite__mapDeps([2,1]))),ET=m.lazy(()=>Xs(()=>import("./CreateSkillPage-CJCr7_2R.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage}))),NT=m.lazy(()=>Xs(()=>Promise.resolve().then(()=>DE),void 0).then(t=>({default:t.UpdatesPanel})));function TT(){return a.jsx(xS,{children:a.jsx(pS,{children:a.jsxs(tN,{children:[a.jsx(RT,{}),a.jsx(xN,{})]})})})}function RT(){var Wn,Et;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=ea(),{config:h}=Hr(),{mode:g,resolvedTheme:p,setTheme:y}=Lv(),{toast:v}=Df(),[b,S]=m.useState(()=>Ow()),[k]=m.useState(!0),[E,C]=m.useState(!1),[N,T]=m.useState(!1),[A,B]=m.useState(!1),[D,F]=m.useState("overview"),[w,O]=m.useState(av),z=m.useCallback((oe,xe)=>{O(vT(oe,xe))},[]),U=qN(),[H,q]=m.useState(()=>gT("activeAgent",null)),X=m.useCallback(oe=>{q(oe),xT("activeAgent",oe),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:oe}}))},[]);m.useEffect(()=>{var oe;!H&&((oe=U.response)!=null&&oe.suggested)&&X(U.response.suggested)},[H,(Wn=U.response)==null?void 0:Wn.suggested,X]);const J=m.useMemo(()=>U.response?$N(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=JN(),[se,M]=m.useState(!1),[Y,W]=m.useState(!1),[te,fe]=m.useState("standalone"),ie=m.useCallback((oe="standalone")=>{fe(oe),W(!0)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;ie((Ee==null?void 0:Ee.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",oe),()=>window.removeEventListener("studio:request-create-skill",oe)},[ie]);const[ye,de]=m.useState(!1),[Se,Ae]=m.useState(null);m.useEffect(()=>{function oe(){de(!0)}return window.addEventListener("studio:open-marketplace",oe),()=>window.removeEventListener("studio:open-marketplace",oe)},[]);const _e=m.useMemo(()=>{const oe=new Set;for(const xe of t.skills)xe.source==="plugin"&&xe.pluginName&&oe.add(xe.pluginName);return oe},[t.skills]);af([{key:"p",meta:!0,handler:oe=>{var Ee;const xe=typeof document<"u"?document.activeElement:null;xe&&xe.tagName==="INPUT"||((Ee=oe==null?void 0:oe.preventDefault)==null||Ee.call(oe),M(dn=>!dn))}}],{enabled:!0});const re=LN(),he=re.open;m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.provider&&he(Ee.provider)}return window.addEventListener("studio:open-setup-drawer",oe),()=>window.removeEventListener("studio:open-setup-drawer",oe)},[he]);const pe=m.useCallback(()=>{O(av)},[]);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.message&&v({message:Ee.message,severity:Ee.severity??"info"})}return window.addEventListener("studio:toast",oe),()=>window.removeEventListener("studio:toast",oe)},[v]),hT();const[ge,je]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Oe(Ee==null?void 0:Ee.provider),je(!0)}return window.addEventListener("studio:open-settings",oe),()=>window.removeEventListener("studio:open-settings",oe)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[rt,Nt]=m.useState(null),[ht,Dt]=m.useState(()=>new Set),Tt=m.useRef(!1),Qe=m.useMemo(()=>SN(),[]),tt=m.useCallback(oe=>`${oe.plugin}/${oe.skill}`,[]),be=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.add(tt(oe)),Ee})},[tt]),pt=m.useCallback(oe=>{Dt(xe=>{const Ee=new Set(xe);return Ee.delete(tt(oe)),Ee})},[tt]),Ct=kN({delayMs:1e4,onCommit:oe=>{o(),pt(oe)},onFailure:(oe,xe)=>{pt(oe),v({message:`Couldn't delete ${oe.skill}: ${xe.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{be(oe),Ct.enqueueDelete(oe)}}})}});m.useEffect(()=>{function oe(xe){if(!(xe instanceof CustomEvent))return;const Ee=xe.detail;Ee!=null&&Ee.skill&&Nt(Ee.skill)}return window.addEventListener("studio:request-delete",oe),()=>window.removeEventListener("studio:request-delete",oe)},[]);const Yt=m.useCallback(()=>{const oe=rt;if(Nt(null),!oe)return;const xe={plugin:oe.plugin,skill:oe.skill};be(xe),Ct.enqueueDelete(xe);const Ee=Tt.current?"":`Sent to your ${Qe}. Open Trash to restore. `;Tt.current=!0,v({message:`${Ee}Deleted ${oe.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Ct.cancelDelete(tt(xe)),pt(xe)}}})},[rt,be,pt,Ct,v,Qe,tt]),un=m.useCallback(()=>{Nt(null)},[]),Gt=m.useMemo(()=>t.skills.filter(oe=>!ht.has(tt(oe))),[t.skills,ht,tt]),an=m.useMemo(()=>t.selectedSkill?t.skills.find(oe=>oe.plugin===t.selectedSkill.plugin&&oe.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=m.useCallback(oe=>{r({plugin:oe.plugin,skill:oe.skill,origin:oe.origin})},[r]),Mt=m.useMemo(()=>{if(!t.selectedSkill)return"";const oe=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${oe})`},[t.selectedSkill]),xt=m.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(oe=>!oe)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);af([{key:"cmd+k",handler:()=>C(oe=>!oe)},{key:"ctrl+k",handler:()=>C(oe=>!oe)},{key:"?",handler:()=>T(oe=>!oe)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(oe=>!oe)},{key:"ctrl+b",handler:()=>B(oe=>!oe)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const gt=kT(),za=wT()?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(NT,{})}):gt?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(ET,{})}):a.jsx(oN,{selectedSkillInfo:an,activeDetailTab:D,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return a.jsxs(a.Fragment,{children:[a.jsx(gS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Uw,{connected:k}),liveMessage:Mt,topRail:a.jsx(h2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ie("standalone"),projectPickerSlot:$&&$.projects.length>0?a.jsx(eT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0}),sidebar:a.jsx(Tw,{skills:Gt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:z,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?a.jsxs(a.Fragment,{children:[a.jsx(VN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:oe=>re.open(oe)}),a.jsx(WN,{activeAgentId:H})]}):null}),resizeHandle:a.jsx(Iw,{initialWidth:b??Us,onChange:S}),main:za,statusBar:a.jsx(E2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Et=h==null?void 0:h.providers)==null?void 0:Et.map(oe=>{const xe=oe.id;return{id:xe,label:oe.label,available:oe.available,kind:xe==="ollama"||xe==="lm-studio"?"start-service":xe==="anthropic"||xe==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(vN,{open:N,onClose:()=>T(!1)}),a.jsx(EN,{open:re.isOpen,providerKey:re.providerKey,onClose:re.close}),a.jsx(bN,{state:w,onClose:pe,onAction:(oe,xe)=>bT(oe,xe)}),E&&a.jsx(m.Suspense,{fallback:null,children:a.jsx(CT,{open:E,onClose:()=>C(!1),commands:xt})}),a.jsx(nT,{open:se,projects:($==null?void 0:$.projects)??[],onSwitch:oe=>{L(oe)},onClose:()=>M(!1)}),a.jsx(aT,{open:Y,onClose:()=>W(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:oe=>{o(),setTimeout(()=>{u(oe.pluginName??"",oe.skillName)},500)}}),a.jsx(iT,{open:ye,onClose:()=>de(!1),installedNames:_e,onInstall:(oe,xe)=>{Ae({plugin:oe,marketplace:xe,ref:`${oe}@${xe}`}),de(!1)},onUninstall:async oe=>{if(window.confirm(`Uninstall ${oe}? This removes the plugin and its skills.`))try{const xe=await fetch(`/api/plugins/${encodeURIComponent(oe)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Ee=await xe.json().catch(()=>({}));if(!xe.ok||!Ee.ok){v({message:Ee.error??`Uninstall failed (${xe.status})`,severity:"error"});return}v({message:`Uninstalled ${oe}.`,severity:"info"}),o()}catch(xe){v({message:xe instanceof Error?xe.message:String(xe),severity:"error"})}}}),a.jsx(Rv,{open:ge,onClose:()=>je(!1),initialProvider:Be,onToast:oe=>v({message:oe,severity:"info"})}),a.jsx(dT,{job:Se,onDone:oe=>{oe.ok&&(o(),setTimeout(()=>Ae(null),3e3))}}),a.jsx(jN,{open:rt!==null,title:rt?`Delete "${rt.skill}"?`:"",body:`It will be sent to your ${Qe}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Yt,onCancel:un})]})}const rv="vskill.migrations.scope-rename.v1",AT={own:"authoring-project",installed:"available-project",global:"available-personal"},MT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function LT(t){if(t.getItem(rv)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(MT);if(!c)continue;const[,u,d]=c,h=AT[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(rv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{LT(window.localStorage)}catch{}f0.createRoot(document.getElementById("root")).render(a.jsx(m.StrictMode,{children:a.jsx(zj,{children:a.jsx(j2,{children:a.jsx(TT,{})})})}));export{Zo as E,kv as L,ni as P,Te as R,RE as S,Hr as a,Wy as b,EE as c,Xo as d,gT as g,a as j,m as r,ne as s,uf as t,Y0 as u,xT as w};
|