vskill 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/agents.json +1 -1
  2. package/dist/commands/add.js +10 -3
  3. package/dist/commands/add.js.map +1 -1
  4. package/dist/commands/outdated.d.ts +1 -0
  5. package/dist/commands/outdated.js +63 -25
  6. package/dist/commands/outdated.js.map +1 -1
  7. package/dist/commands/plugin.js +39 -7
  8. package/dist/commands/plugin.js.map +1 -1
  9. package/dist/commands/repair-skills.d.ts +27 -0
  10. package/dist/commands/repair-skills.js +190 -0
  11. package/dist/commands/repair-skills.js.map +1 -0
  12. package/dist/commands/submit.js +61 -1
  13. package/dist/commands/submit.js.map +1 -1
  14. package/dist/eval-server/authoring-routes.js +90 -17
  15. package/dist/eval-server/authoring-routes.js.map +1 -1
  16. package/dist/eval-server/plugin-cli-routes.js +20 -13
  17. package/dist/eval-server/plugin-cli-routes.js.map +1 -1
  18. package/dist/eval-server/plugin-discovery.d.ts +17 -0
  19. package/dist/eval-server/plugin-discovery.js +183 -0
  20. package/dist/eval-server/plugin-discovery.js.map +1 -0
  21. package/dist/eval-ui/assets/{CreateSkillPage-B9MwTYPn.js → CreateSkillPage-D9ZsmNub.js} +1 -1
  22. package/dist/eval-ui/assets/{FindSkillsPalette-DSW-Zyl_.js → FindSkillsPalette-BBj-hoqE.js} +2 -2
  23. package/dist/eval-ui/assets/{SearchPaletteCore-91Jq-ilw.js → SearchPaletteCore-Ddcfdn9a.js} +1 -1
  24. package/dist/eval-ui/assets/{SkillDetailPanel-CPhEDst2.js → SkillDetailPanel-Xymi4aZg.js} +1 -1
  25. package/dist/eval-ui/assets/{UpdateDropdown-OxJwLHid.js → UpdateDropdown-DTP2sv27.js} +1 -1
  26. package/dist/eval-ui/assets/{index-DnXSuywx.js → index-BmriQsHr.js} +4 -4
  27. package/dist/eval-ui/index.html +1 -1
  28. package/dist/index.js +16 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/installer/frontmatter.js +24 -8
  31. package/dist/installer/frontmatter.js.map +1 -1
  32. package/dist/lib/frontmatter.d.ts +33 -0
  33. package/dist/lib/frontmatter.js +85 -0
  34. package/dist/lib/frontmatter.js.map +1 -0
  35. package/dist/lockfile/authored.d.ts +35 -0
  36. package/dist/lockfile/authored.js +82 -0
  37. package/dist/lockfile/authored.js.map +1 -0
  38. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-OxJwLHid.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-DSW-Zyl_.js","assets/SkillDetailPanel-CPhEDst2.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-B9MwTYPn.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-DTP2sv27.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-BBj-hoqE.js","assets/SkillDetailPanel-Xymi4aZg.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-D9ZsmNub.js"])))=>i.map(i=>d[i]);
2
2
  /* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))i(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function i(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function Ev(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var jd={exports:{}},_s={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -62,7 +62,7 @@ Please change the parent <Route path="${w}"> to <Route path="${w==="/"?"*":`${w}
62
62
  `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))f=S.slice(7).trim();else if(S.startsWith("data: ")){let C={};try{C=JSON.parse(S.slice(6))}catch{f="";continue}if(f==="started"||f==="copied"||f==="deleted"||f==="indexed"||f==="done"||f==="error"){const E={type:f,...C};a==null||a(E),E.type==="done"&&(x=E),E.type==="error"&&(h=E)}f=""}}if(h){const y=new Ga(h.message,500);throw y.code=h.code,y}if(!x)throw new Ga("Transfer stream ended without 'done' event",500);return x}function NS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,f]=i.map(Number),[,x,h,y]=c.map(Number);return u!==x?u>x:d!==h?d>h:f>=y}function TS(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.set(d,c),u.length>=1){const f=u[u.length-1];s.set(`${f}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!NS(c.version,u.latest),f={...c,updateAvailable:d,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(f.trackedForUpdates=u.trackedForUpdates);const x=Wv({frontmatterVersion:f.version??null,registryCurrentVersion:f.currentVersion??null,pluginVersion:f.pluginVersion??null,installedCurrentVersion:f.currentVersion??null,preferInstalled:!0});return f.resolvedVersion=x.version,f.versionSource=x.versionSource,f})}const Ho=new Map,Pa=new Map,Ps=new Map;function Bn(t){Ho.delete(t),Pa.delete(t);const a=Ps.get(t);if(a)for(const s of a)s()}function qa(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=m.useState(0),[d,f]=m.useState(void 0),[x,h]=m.useState(0),y=m.useRef(!0),v=m.useRef(t);v.current=t;const b=()=>{f(void 0),Bn(t),h(E=>E+1)};m.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]),m.useEffect(()=>{if(!c)return;const E=()=>{y.current&&h(w=>w+1)};return Ps.has(t)||Ps.set(t,new Set),Ps.get(t).add(E),()=>{var w;(w=Ps.get(t))==null||w.delete(E)}},[t,c]),m.useEffect(()=>{if(!c)return;const E=Ho.get(t);if(!(!E||Date.now()-E.fetchedAt>i))return;if(Pa.has(t)){const A=Pa.get(t),I=()=>{y.current&&v.current===t&&u(L=>L+1)};A.subscribers.push(I);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(A=>{Ho.set(t,{data:A,fetchedAt:Date.now()}),Pa.delete(t),y.current&&v.current===t&&(f(void 0),u(I=>I+1));for(const I of N.subscribers)I()},A=>{Pa.delete(t);const I=A instanceof Error?A:new Error(String(A));y.current&&v.current===t&&(f(I),u(L=>L+1));for(const L of N.subscribers)L()});N.promise=T,Pa.set(t,N)},[t,a,i,c,x]);const S=Ho.get(t),C=c&&!S&&!d&&Pa.has(t);return{data:S==null?void 0:S.data,loading:C,error:d,revalidate:b}}function RS(t){const[a,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const AS=500,uf="vskill.updates.seenLastId";function LS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(uf)}catch{return null}}function Md(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(uf):window.localStorage.setItem(uf,t)}catch{}}function MS(){let t=new Map;const a=new Set,s=new Set,i=[];let c=LS();c&&(s.add(c),i.push(c));function u(){t=new Map(t);for(const f of Array.from(a))f()}function d(f){if(!s.has(f)){if(s.add(f),i.push(f),i.length>AS){const x=i.shift();x&&s.delete(x)}c=f,Md(f)}}return{getSnapshot(){return t},subscribe(f){return a.add(f),()=>{a.delete(f)}},ingest(f){return s.has(f.eventId)?"duplicate":(d(f.eventId),t.set(f.skillId,{skillId:f.skillId,version:f.version,diffSummary:f.diffSummary,eventId:f.eventId,publishedAt:f.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(f){t.has(f)&&(t.delete(f),u())},clearSeen(){s.clear(),i.length=0,c=null,Md(null)},mergeBulk(f){if(f.length!==0){for(const x of f)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Md(null),u()}}}const Ua=MS(),zS=3e5,DS=500,_S=15e3,OS=6e4,BS=6e4,IS="/api/v1/skills/stream";function sg(t){const a=new Map;for(const i of t)a.set(i.name,i);const s=new Map;for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&s.set(c,(s.get(c)??0)+1)}for(const i of t){const c=i.name.split("/").pop()||i.name;c!==i.name&&((s.get(c)??0)>1||a.has(c)||a.set(c,i))}return a}function ig(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function $S(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function US(t){const a=(t==null?void 0:t.intervalMs)??zS,s=(t==null?void 0:t.debounceMs)??DS,i=(t==null?void 0:t.timeoutMs)??_S,c=(t==null?void 0:t.staleAfterMs)??OS,u=(t==null?void 0:t.disconnectFallbackMs)??BS,d=(t==null?void 0:t.streamUrlBase)??IS,f=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=m.useMemo(()=>{const D=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return D.length===0?"":[...D].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[h,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[S,C]=m.useState(0),[E,w]=m.useState(!1),[N,T]=m.useState(null),[A,I]=m.useState(null),L=m.useRef(null),H=m.useRef(null),k=m.useRef(null),O=m.useRef(null),z=m.useRef(!0),[_,$]=m.useState(()=>f?"connecting":"fallback"),q=m.useRef(_);q.current=_;const K=m.useSyncExternalStore(D=>Ua.subscribe(D),()=>Ua.getSnapshot(),()=>Ua.getSnapshot()),Q=K.size,U=m.useCallback(async()=>{w(!0);const D=new AbortController,W=setTimeout(()=>D.abort(),i);try{const X=await Promise.race([ke.getSkillUpdates(),new Promise((ee,de)=>{D.signal.addEventListener("abort",()=>{de(new Error("TIMEOUT"))})})]);if(X==="TIMEOUT")throw new Error("TIMEOUT");if(!z.current)return;y(X),b(sg(X)),C(ig(X)),H.current=Date.now(),T(H.current),I(null)}catch(X){if(!z.current)return;I(X instanceof Error?X:new Error(String(X)))}finally{clearTimeout(W),z.current&&w(!1)}},[i]),M=m.useCallback(()=>{if(L.current)return L.current;const D=U().finally(()=>{L.current=null});return L.current=D,D},[U]),B=m.useCallback(()=>{k.current==null&&(k.current=setInterval(()=>{M()},a))},[a,M]),F=m.useCallback(()=>{k.current!=null&&(clearInterval(k.current),k.current=null)},[]);m.useEffect(()=>{z.current=!0,(H.current==null||Date.now()-H.current>c)&&M(),(typeof document>"u"||document.visibilityState!=="hidden")&&B();const X=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){F();return}O.current=setTimeout(()=>{O.current=null,(H.current==null||Date.now()-H.current>c)&&M(),B()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",X),()=>{z.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",X),O.current&&clearTimeout(O.current),F()}},[]);const te=m.useCallback(async D=>{if(D.length!==0)try{const W=await ke.checkSkillUpdates(D);if(!z.current||W.length===0)return;const X=Date.now(),ee=W.filter(le=>le.skillId&&le.eventId&&le.version).map(le=>({skillId:le.skillId,version:le.version,eventId:le.eventId,publishedAt:le.publishedAt,diffSummary:le.diffSummary,receivedAt:X}));ee.length>0&&Ua.mergeBulk(ee);const de=W.filter(le=>typeof le.trackedForUpdates=="boolean"||typeof le.updateAvailable=="boolean").map(le=>({name:le.name??le.skillId,installed:le.installed??"",latest:le.latest??null,updateAvailable:le.updateAvailable??!1,trackedForUpdates:typeof le.trackedForUpdates=="boolean"?le.trackedForUpdates:void 0}));de.length>0&&y(le=>{const ce=new Map;for(const Le of le)ce.set(Le.name,Le);let ne=0;for(const Le of de){const Ee=Le.name,Me=ce.get(Ee);if(Me){const Pe={...Me};Me.trackedForUpdates===void 0&&Le.trackedForUpdates!==void 0&&(Pe.trackedForUpdates=Le.trackedForUpdates),ce.set(Ee,Pe)}else ce.set(Ee,{name:Le.name,installed:Le.installed??"",latest:Le.latest??null,updateAvailable:Le.updateAvailable??!1,trackedForUpdates:Le.trackedForUpdates}),ne+=1}if(ne===0&&ce.size===le.length)return le;const ge=[...ce.values()];return b(sg(ge)),C(ig(ge)),ge})}catch{}},[]);m.useEffect(()=>{const D=f||x;if(!D){$("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){$("fallback");return}$("connecting");const W=D.split(","),X=`${d}?skills=${encodeURIComponent(D)}`;let ee=null,de=null,le=null;const ce=()=>{de==null&&(de=setTimeout(()=>{de=null,z.current&&q.current!=="connected"&&$("fallback")},u))},ne=()=>{de!=null&&(clearTimeout(de),de=null)};ce();const ge=1e3,Le=()=>{z.current&&le==null&&(le=setTimeout(()=>{if(le=null,!!z.current&&!(ee&&ee.readyState!==EventSource.CLOSED)){if(ee)try{ee.close()}catch{}Pe()}},ge))},Ee=ie=>{if(!z.current)return;let fe;try{fe=JSON.parse(ie.data)}catch{return}if(!$S(fe)||Ua.ingest(fe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const je=`${fe.skillId} updated to ${fe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:je,severity:"info",skillId:fe.skillId,version:fe.version,eventId:fe.eventId}}))}},Me=()=>{z.current&&(Ua.clearSeen(),te(W))},Pe=()=>{z.current&&(ee=new EventSource(X),ee.onopen=()=>{z.current&&(ne(),$("connected"))},ee.onerror=()=>{z.current&&(ce(),ee&&ee.readyState===EventSource.CLOSED&&Le())},ee.onmessage=Ee,ee.addEventListener("gone",Me))};return Pe(),()=>{if(ne(),le!=null&&(clearTimeout(le),le=null),ee){try{ee.removeEventListener("gone",Me)}catch{}try{ee.close()}catch{}}}},[f,x,d,u,te]),m.useEffect(()=>{if(!x)return;const D=x.split(",");te(D)},[x,te]);const V=m.useCallback(D=>{Ua.dismiss(D)},[]);return{updates:h,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:M,updatesById:K,pushUpdateCount:Q,status:_,dismiss:V}}function HS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const PS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function VS(t,a){switch(a.type){case"SELECT_SKILL":return{...t,selectedSkill:a.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:a.mode,selectedSkill:a.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:a.query};case"SET_SKILLS":return{...t,skills:a.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:a.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:a.loading};case"SET_MOBILE":return{...t,isMobile:a.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:a.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:a.skill,revealSkillId:`${a.skill.plugin}/${a.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const qv=m.createContext(null),Yv=qv;function cr(){const t=m.useContext(Yv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function FS({children:t}){const[a,s]=m.useReducer(VS,PS),i=RS("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=m.useState(()=>{try{const te=window.localStorage.getItem("vskill.studio.prefs");if(!te)return null;const V=JSON.parse(te);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,f]=m.useState(c!==null);m.useEffect(()=>{function te(V){if(!(V instanceof CustomEvent))return;const D=V.detail;D!=null&&D.agentId&&(u(D.agentId),f(!0))}return window.addEventListener("studio:agent-changed",te),()=>window.removeEventListener("studio:agent-changed",te)},[]),m.useEffect(()=>{if(d)return;let te=!1;return ke.getAgents().then(V=>{if(te)return;const D=(V==null?void 0:V.suggested)??"claude-code";u(W=>W??D),f(!0)}).catch(()=>{te||(u(V=>V??"claude-code"),f(!0))}),()=>{te=!0}},[d]);const x=m.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const te={agent:c};return ke.getSkills(te).then(V=>{s({type:"SET_SKILLS",skills:V});const W=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(W){const[,X,ee]=W,de=V.find(le=>le.plugin===X&&le.skill===ee);de&&s({type:"SELECT_SKILL",skill:{plugin:X,skill:ee,origin:de.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);m.useEffect(()=>{x()},[x]);const h=m.useCallback(te=>{s({type:"SELECT_SKILL",skill:te}),window.location.hash=`/skills/${te.plugin}/${te.skill}`},[]),y=m.useRef(a.skills);m.useEffect(()=>{y.current=a.skills},[a.skills]);const v=m.useCallback((te,V)=>{const D=y.current,W=te?D.find(de=>de.plugin===te&&de.skill===V):D.find(de=>de.skill===V&&de.source!=="plugin");if(!te&&!W){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const X=(W==null?void 0:W.plugin)??te,ee=(W==null?void 0:W.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:X,skill:V,origin:ee}}),window.location.hash=`/skills/${X}/${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)},[]),C=m.useCallback(te=>{s({type:"SET_MODE",mode:te})},[]),E=m.useCallback(te=>{s({type:"SET_SEARCH",query:te})},[]),w=m.useCallback(te=>{s({type:"SET_MOBILE_VIEW",view:te})},[]),N=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=m.useRef(new Map),A=m.useRef(""),I=m.useRef(!1),[L,H]=m.useState(""),k=m.useMemo(()=>a.skills.map(te=>`${te.plugin}/${te.skill}`),[a.skills]),O=m.useMemo(()=>L?L.split(",").filter(Boolean):[],[L]),z=US({skillIds:O,trackingSkillIds:k}),_=m.useRef("");m.useEffect(()=>{const te=a.skills.filter(ee=>ee.origin==="installed");if(te.length===0){H(""),_.current="";return}const V=new Map;for(const ee of z.updates)V.set(ee.name.split("/").pop()||ee.name,ee);const D=te.map(ee=>{const de=V.get(ee.skill),le=ee.currentVersion??(de==null?void 0:de.installed)??ee.version??ee.pluginVersion??"1.0.0";return{plugin:ee.plugin,skill:ee.skill,name:(de==null?void 0:de.name)??ee.skill,currentVersion:le}}),W=D.map(ee=>`${ee.plugin}/${ee.skill}@${ee.currentVersion}#${ee.name}`).sort().join("|");if(W===_.current)return;_.current=W;let X=!1;return ke.resolveInstalledSkillIds(D).then(ee=>{if(X)return;const ce=[...HS(ee).flatMap(ne=>[ne.uuid,ne.slug].filter(Boolean))].sort().join(",");ce!==A.current&&(A.current=ce,T.current=new Map(ee.map(ne=>[`${ne.plugin}/${ne.skill}`,{uuid:ne.uuid,slug:ne.slug}])),H(ce))}).catch(ee=>{if(X||(_.current=""),!I.current){I.current=!0;const de=ee instanceof Error?ee.message:String(ee);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",de)}}),()=>{X=!0}},[a.skills,z.updates]);const $=m.useMemo(()=>{const te=a.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const D={...V};return delete D.updateAvailable,delete D.currentVersion,delete D.latestVersion,delete D.trackedForUpdates,D});return TS(te,z.updates)},[a.skills,z.updates]),q=m.useMemo(()=>{const te={source:0,installed:0};for(const V of $)V.updateAvailable&&(te[V.origin]+=1);return te},[$]),K=m.useMemo(()=>({...a,skills:$}),[a,$]),Q=z.updateCount,U=z.refresh,M=z.isRefreshing,B=m.useCallback((te,V)=>{U(),x(),Bn(`versions/${te}/${V}`),z.dismiss(`${te}/${V}`)},[U,x,z]),F=m.useMemo(()=>({state:K,selectSkill:h,clearSelection:S,setMode:C,setSearch:E,setMobileView:w,refreshSkills:x,updateCount:Q,dismissUpdateNotification:N,updates:z.updates,outdatedByOrigin:q,isRefreshingUpdates:M,refreshUpdates:U,revealSkill:v,clearReveal:b,updatesById:z.updatesById,pushUpdateCount:z.pushUpdateCount,updateStreamStatus:z.status,dismissPushUpdate:z.dismiss,activeAgent:c,onSkillUpdated:B}),[K,h,S,C,E,w,x,Q,N,z.updates,q,M,U,v,b,z.updatesById,z.pushUpdateCount,z.status,z.dismiss,c,B]);return r.jsx(Yv.Provider,{value:F,children:t})}const GS={config:null,loading:!0};function WS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Kv=m.createContext(null);function Ya(){const t=m.useContext(Kv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function qS({children:t}){const[a,s]=m.useReducer(WS,GS),i=m.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{i()},[i]);const c=m.useCallback(async(d,f)=>{const x=await ke.setConfig(d,f);return s({type:"SET_CONFIG",config:x}),x},[]),u=m.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Kv.Provider,{value:u,children:t})}function YS({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:f=320,sidebarHidden:x=!1}){const h={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${f}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:x?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:h,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!x&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!x&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:i}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const og=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],KS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},XS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},QS={"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"},ZS={"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 JS(t,a){var f,x;const s=KS[t.id]??null,i=XS[t.id]??null,c=s?!!((f=a==null?void 0:a.wrapperFolders)!=null&&f[s]):!1,u=i?!!((x=a==null?void 0:a.binaries)!=null&&x[i]):!0,d=t.models.map(h=>({id:h.id,displayName:h.label,billingMode:ZS[t.id]??"per-token",...h.pricing?{pricing:h.pricing}:{},...h.resolvedId?{resolvedId:h.resolvedId}:{}}));return{id:t.id,displayName:e2(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:QS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function e2(t,a){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??a}function t2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of og){const c=a.get(i);c&&s.push(c)}for(const i of t)og.includes(i.id)||s.push(i);return s}function n2(t){const[a,s]=m.useState(null),[i,c]=m.useState("loading"),[u,d]=m.useState(null),[f,x]=m.useState(null),h=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(),I=t2((A.providers||[]).map(L=>JS(L,A.detection)));s({agents:I,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);m.useEffect(()=>{S()},[S]);const C=m.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const I=await fetch("/api/openrouter/models");if(!I.ok){I.status!==400&&x(`OpenRouter catalog fetch failed (${I.status})`);return}const L=await I.json();y.current=T,x(null),s(O=>{if(!O)return O;const z=O.agents.map(_=>{if(_.id!=="openrouter")return _;const $=L.models.map(K=>({id:K.id,displayName:K.name,contextWindow:K.contextWindow,pricing:K.pricing,billingMode:"per-token"}));return{..._,models:$,catalogAgeMs:L.ageSec?L.ageSec*1e3:0,cacheStale:!!L.stale}});return{...O,agents:z}});const H=L.ageSec??0;(L.stale===!0||H>600)&&((A=v.current)==null||A.call(v,"openrouter",H*1e3))}catch(I){x(`OpenRouter catalog unreachable: ${I.message}`)}},[]),E=m.useCallback(T=>{h.current=T,T==="openrouter"&&C()},[C]),w=m.useCallback(()=>{y.current=0,S()},[S]),N=m.useCallback(async(T,A)=>{var H,k;let I;try{I=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(H=b.current)==null||H.call(b,`Network error while setting ${T}: ${O.message}`);return}if(I.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let L=`Failed to set ${T} (${I.status})`;try{const O=await I.json();O&&typeof O.error=="string"&&(L=O.error)}catch{}(k=b.current)==null||k.call(b,L)},[]);return{status:i,catalog:a,error:u,openRouterError:f,focusAgent:E,refresh:w,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function zd({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(f){if(f.stopPropagation(),t==="cli-install"&&i){window.open(i,"_blank","noopener,noreferrer");return}s()}function d(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u(f))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function df({unlocked:t=!1,size:a=10}){return t?r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const r2={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,a)=>`${t} of ${a}`},a2={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"},l2={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"},s2={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"},i2={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"},o2={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"},c2={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."},u2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},d2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},f2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},p2={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"},m2={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)."}},h2={subscriptionBilling:"· subscription",free:"· free"},x2={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`},g2={providersLabel:"Providers",providerSummary:(t,a)=>`${t}/${a} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},v2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},y2={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.`},b2={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"},j2={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."},S2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},k2={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"}},se={sidebar:r2,shell:a2,detail:l2,actions:s2,palette:i2,shortcuts:o2,toasts:c2,connection:u2,forms:d2,errors:f2,picker:p2,providers:m2,models:h2,settings:x2,statusBar:g2,scopePicker:v2,scopeSection:y2,claudeCodeLabel:b2,setupDrawer:j2,setupProviders:k2,scopeLabels:S2},w2=new Set(["claude-cli","claude-code"]);function cg(t){return w2.has(t)}const ug=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function C2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>ug.has(x.id)),f=t.filter(x=>!ug.has(x.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(x=>r.jsx(dg,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id)),f.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),f.map(x=>r.jsx(dg,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id))]})}function dg({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=se,f={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},x={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},h=cg(t.id),y={minHeight:36,height:h?"auto":36,padding:h?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>i(t.id),onFocus:()=>i(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),cg(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:se.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:se.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(df,{unlocked:!0,size:10}):r.jsx(df,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:se.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(zd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(zd,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(zd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),f[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:f[t.id]})]})}function E2(t,a,s,i){const d=t>=80,f=m.useRef(null),[x,h]=m.useState(0),y=m.useCallback(S=>{h(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(x/a)-4),C=Math.ceil(s/a)+8,E=Math.min(t,S+C);return{visibleStart:S,visibleEnd:E}},[d,x,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:f,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Xv=44,N2=352,T2=60,fg=480;function R2(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${se.models.subscriptionBilling}`:se.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function A2(t,a){if(!a)return t;const s=a.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),f=u.displayName.toLowerCase().indexOf(s);return d!==f?d-f:c.displayName.length-u.displayName.length})}function L2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>x(u),T2);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&h.current&&h.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:fg,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:se.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:se.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>A2(t.models,f),[t.models,f]),v=E2(y.length,Xv,N2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:fg,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.jsx("input",{ref:h,type:"text",placeholder:se.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":se.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&&f?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:se.picker.noMatches(f)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:se.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:se.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const C=v.visibleStart+S;return r.jsx(z2,{model:b,isActive:b.id===a,isFocused:s===C,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function M2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function z2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=R2(t),d=M2(t.id,c,t.resolvedId),f=d!==null,x=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",h=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:i,title:t.id,style:{width:"100%",minHeight:Xv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,borderLeft:h,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),f&&r.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const pg={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function D2(){const[t,a]=m.useState(null),[s,i]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{i(!0);try{const h=await fetch("/api/settings/keys");if(!h.ok)throw new Error(`GET /api/settings/keys returned ${h.status}`);const y=await h.json();a({...pg,...y}),u(null)}catch(h){u(h.message),a(pg)}finally{i(!1)}},[]);m.useEffect(()=>{d()},[d]);const f=m.useCallback(async(h,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,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]),x=m.useCallback(async h=>{const y=await fetch(`/api/settings/keys/${h}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${h} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:f,remove:x,refresh:d}}function _2({onMigrated:t,fetchImpl:a}){const[s,i]=m.useState({kind:"loading"}),c=a??globalThis.fetch,u=m.useCallback(async()=>{var h;try{const y=await c("/api/settings/migration-status");if(!y.ok){i({kind:"hidden"});return}const v=await y.json();v.pending&&(((h=v.darwinKeys)==null?void 0:h.length)??0)>0?i({kind:"visible",darwinKeys:v.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{i({kind:"working"});try{const h=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!h.ok){i({kind:"error",message:`Migration failed (${h.status})`});return}const y=await h.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(h){i({kind:"error",message:h.message})}},[c,u,t]),f=m.useCallback(async()=>{i({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:Dd,children:"Retry"})]});const x=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:x,"data-testid":"migration-migrate",style:{...Dd,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void f(),"data-testid":"migration-dismiss",style:{...Dd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Dd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},O2=[{id:"anthropic",name:se.providers.anthropic.name,keyIssuanceUrl:se.providers.anthropic.keyIssuanceUrl,prefix:se.providers.anthropic.keyPrefix,placeholder:`Paste ${se.providers.anthropic.name} key`},{id:"openai",name:se.providers.openai.name,keyIssuanceUrl:se.providers.openai.keyIssuanceUrl,prefix:se.providers.openai.keyPrefix,placeholder:se.providers.openai.pastePlaceholder},{id:"openrouter",name:se.providers.openrouter.name,keyIssuanceUrl:se.providers.openrouter.keyIssuanceUrl,prefix:se.providers.openrouter.keyPrefix,placeholder:`Paste ${se.providers.openrouter.name} key`}];function B2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Qv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:f}=D2(),x=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const C=await fetch("/api/settings/storage-path");if(!C.ok)throw new Error(`GET /api/settings/storage-path returned ${C.status}`);const E=await C.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),m.useEffect(()=>{if(!t)return;const S=document.activeElement,C=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",w=(N=x.current)==null?void 0:N.querySelector(E);w==null||w.focus()},0);return()=>{var E;clearTimeout(C),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),m.useEffect(()=>{if(!t)return;const S=C=>{if(C.key==="Escape"){C.preventDefault(),a();return}if(C.key==="Tab"&&x.current){const E=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const w=E[0],N=E[E.length-1];C.shiftKey&&document.activeElement===w?(C.preventDefault(),N.focus()):!C.shiftKey&&document.activeElement===N&&(C.preventDefault(),w.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=m.useCallback(async()=>{var S,C;if(y)try{await((C=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:C.call(S,y)),i==null||i(se.settings.pathCopied)}catch{}},[i,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:x,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:se.settings.title}),r.jsx(_2,{onMigrated:()=>{f()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:se.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:se.settings.sectionApiKeys}),O2.map(S=>r.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 C=>{const E=await u(S.id,C);return i==null||i(se.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),i==null||i(se.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?h:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?se.settings.storagePath(y):se.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Va,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:se.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function I2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:f,inputRef:x}){const[h,y]=m.useState(""),[v,b]=m.useState(!1),[S,C]=m.useState(!1),[E,w]=m.useState(!1),[N,T]=m.useState(null),A=h.trim(),I=A.length===0,L=A.length>0&&!A.startsWith(i),H=m.useCallback(async()=>{if(I)return;C(!0);const z=A;y("");try{const _=await d(z);_.warning?T(_.warning):T(null)}finally{C(!1)}},[I,d,A]),k=m.useCallback(async()=>{var z;try{if(!((z=navigator.clipboard)!=null&&z.readText))return;const _=await navigator.clipboard.readText();y(_)}catch{}},[]),O=m.useCallback(async()=>{w(!1),await f()},[f]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:x,type:v?"text":"password",value:h,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"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Va,children:v?se.settings.hide:se.settings.show}),r.jsx("button",{type:"button",onClick:k,style:Va,children:se.settings.paste})]}),L&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:mg,children:se.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:mg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:H,disabled:I||S,"data-testid":`save-${t}`,style:{...Va,background:I?"var(--surface-2)":"var(--accent, var(--color-accent))",color:I?"var(--text-muted)":"white",cursor:I?"not-allowed":"pointer"},children:se.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:se.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Va,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>w(!1),style:Va,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>w(!0),"data-testid":`remove-${t}`,style:{...Va,color:"var(--text-muted)"},children:se.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?se.settings.keyStoredAt(B2(u.updatedAt)):se.settings.noKey})]})]})}const Va={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},mg={fontSize:11,color:"var(--warning, var(--text-muted))"};function $2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function U2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=n2({onStaleCatalog:(_,$)=>{const q=Math.round($/6e4);t==null||t(`Using cached ${_} catalog (${q} min old)`)},onSetActiveError:_=>t==null?void 0:t(_)}),[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,y]=m.useState(),[v,b]=m.useState(null),[S,C]=m.useState("agents"),[E,w]=m.useState(0),N=m.useRef(null);m.useRef(null),m.useEffect(()=>{var _;s&&!v&&b(s.activeAgent??((_=s.agents[0])==null?void 0:_.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=m.useMemo(()=>T.find(_=>_.id===v)??T[0],[T,v]);m.useEffect(()=>{w(0)},[v]);const I=m.useCallback(()=>{var _;d(!0),C("agents"),b((s==null?void 0:s.activeAgent)??((_=T[0])==null?void 0:_.id)??null),w(0)},[s,T]),L=m.useCallback(()=>{var _;d(!1),(_=N.current)==null||_.focus()},[]);m.useEffect(()=>{const _=$=>{var K;if(!($.metaKey||$.ctrlKey)||$.key.toLowerCase()!=="k")return;const q=(K=document.activeElement)==null?void 0:K.tagName;q==="INPUT"||q==="TEXTAREA"||($.preventDefault(),d(Q=>!Q))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[]),m.useEffect(()=>{if(!u)return;const _=q=>{if(q.key==="Escape"){q.preventDefault(),L();return}if(q.key==="ArrowDown"){q.preventDefault(),$(1);return}if(q.key==="ArrowUp"){q.preventDefault(),$(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),C("models"),w(K=>{const Q=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(K,Math.max(0,Q)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),C("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)C("models"),w(0);else if(S==="models"&&A){const K=Math.max(0,Math.min(A.models.length-1,E)),Q=A.models[K];Q&&(c(A.id,Q.id),L())}return}};function $(q){if(S==="agents"){const K=T.findIndex(U=>U.id===v),Q=T[Math.max(0,Math.min(T.length-1,K+q))];Q&&(b(Q.id),i(Q.id));return}if(S==="models"&&A){const K=A.models.length;if(K===0)return;w(Q=>{const U=Q+q;return Math.max(0,Math.min(K-1,U))})}}return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[u,S,T,v,A,E,L,i,c]);const H=m.useCallback(_=>{y(_==="anthropic"||_==="openrouter"?_:void 0),x(!0),d(!1)},[]),k=T.find(_=>_.id===(s==null?void 0:s.activeAgent)),O=k==null?void 0:k.models.find(_=>_.id===(s==null?void 0:s.activeModel)),z=m.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const _=(k==null?void 0:k.displayName)??"Agent",$=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${_} · ${$}`},[a,s,k,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?L():I(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:k!=null&&k.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:z})]}),u&&typeof document<"u"&&rc.createPortal(r.jsxs(H2,{reducedMotion:$2(),onClickOutside:L,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(C2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:_=>{b(_),i(_)},onSelect:_=>{b(_),i(_),C("models")},onOpenSettings:H}),A&&r.jsx(L2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:_=>{c(A.id,_),L()},onOpenSettings:H})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>H(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:se.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:se.picker.footerHint})]})]}),document.body),r.jsx(Qv,{open:f,onClose:()=>x(!1),initialProvider:h,onToast:t})]})}function H2({children:t,reducedMotion:a,onClickOutside:s}){const i=m.useRef(null);return m.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
63
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
64
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
- }`})]})}function hg(){typeof window>"u"||(window.location.hash="#/")}function P2({onHome:t}){const[a,s]=m.useState(!1),[i,c]=m.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),hg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),hg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const xg=m.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function V2({toast:t,onDismiss:a}){const[s,i]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function F2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(xg,{politeness:"polite",message:s}),r.jsx(xg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(V2,{toast:c,onDismiss:a})},c.id))})]})}const Zv=m.createContext(null);function ac(){const t=m.useContext(Zv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function G2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=m.useState([]),[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(new Map),y=m.useCallback(w=>{const N=h.current.get(w);N&&(clearTimeout(N),h.current.delete(w)),c(T=>T.filter(A=>A.id!==w))},[]),v=m.useCallback((w,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(w)},N);h.current.set(w,T)},[y]),b=m.useCallback(w=>{const N=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(A=>[...A,T]),T.severity==="error"?x(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=m.useCallback(()=>{for(const w of h.current.values())clearTimeout(w);h.current.clear(),c([])},[]);m.useEffect(()=>{function w(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),I=A[A.length-1],L=h.current.get(I.id);return L&&(clearTimeout(L),h.current.delete(I.id)),T.filter(H=>H.id!==I.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]),m.useEffect(()=>()=>{for(const w of h.current.values())clearTimeout(w);h.current.clear()},[]);const C=i.slice(0,a),E=m.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Zv.Provider,{value:E,children:[t,r.jsx(F2,{toasts:C,onDismiss:y,liveMessage:u,liveAssertiveMessage:f})]})}function W2(){const{data:t,loading:a}=qa("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const q2=m.lazy(()=>Vl(()=>import("./UpdateDropdown-OxJwLHid.js"),__vite__mapDeps([0,1])));function Y2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:x}=cr(),{toast:h}=ac(),{data:y}=W2(),v=(y==null?void 0:y.degraded)===!0,b=m.useMemo(()=>{if(!f||f.size===0)return;const H=new Map;for(const[k,O]of f)O.diffSummary&&H.set(k,O.diffSummary);return H.size>0?H:void 0},[f]),[S,C]=m.useState(!1),E=m.useRef(null),w=m.useCallback(()=>C(!1),[]),N=v?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),A=t===0?"No updates available":`${t} updates available, open summary`,I=v?`${A} — platform crawler degraded`:A,L=v?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:E,type:"button","data-testid":"update-bell","aria-label":I,"aria-haspopup":"dialog","aria-expanded":S,title:L,onClick:()=>C(H=>!H),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||v?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(q2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:H=>{const k=H.localSkill??H.name.split("/").pop()??"",O=H.localPlugin??"";if(u)u(O,k);else{const _=H.name.split("/"),$=_.length>=2?_[_.length-2]:_[0];c({plugin:$,skill:k,origin:"installed"})}if(!(d??[]).some(_=>_.skill===k&&(O===""||_.plugin===O))){const _=H.installLocations??[];if(_.length>0){const $=x?_.filter(K=>K.agent===x):[],q=x?_.filter(K=>K.agent!==x):_;if($.length>0&&q.length>0){const K=q.length>=2?`Also installed under ${q.length} other locations.`:`Also installed under ${q[0].agentLabel}.`;h({severity:"info",message:K})}else{const K=_[0].agentLabel;h({severity:"info",message:`Skill installed under ${K} — switch to ${K} to view details.`})}}}w()},onViewAll:()=>{window.location.hash="#/updates",w()},onClose:w,anchorRef:E})})]})}function gg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function K2({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(P2,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(vg,{segment:"origin",onClick:()=>gg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(yg,{}),r.jsx(vg,{segment:"plugin",onClick:()=>gg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(yg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),r.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(U2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(Y2,{})})]})]})]})}function vg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function yg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const lc="vskill-theme";function Jv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function X2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function Q2(t){try{const a=t.getItem(lc);return Jv(a)}catch{return"auto"}}function Z2(t,a){try{t.setItem(lc,a)}catch{}}function J2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function ek(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ey=m.createContext(null);function tk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[f,x]=m.useState(()=>c?Q2(c):"auto"),[h,y]=m.useState(()=>ek(u)),v=m.useMemo(()=>X2(f,h),[f,h]);m.useEffect(()=>{d&&J2(d,f,v)},[d,f,v]),m.useEffect(()=>{if(!u)return;const C=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",E),()=>C.removeEventListener("change",E);const w=C;return w.addListener(E),()=>w.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const C=E=>{E.key===lc&&x(Jv(E.newValue))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),m.useEffect(()=>{if(!u||!d)return;let C;try{C=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(C.matches);const w=T=>E(T.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",w),()=>C.removeEventListener("change",w);const N=C;return N.addListener(w),()=>N.removeListener(w)},[u,d]);const b=m.useCallback(C=>{x(C),c&&Z2(c,C)},[c]),S=m.useMemo(()=>({mode:f,resolvedTheme:v,setTheme:b}),[f,v,b]);return r.jsx(ey.Provider,{value:S,children:i})}function ty(){const t=m.useContext(ey);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const bg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function nk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of bg){const c=a.get(i);c&&s.push(c)}for(const i of t)bg.includes(i.id)||s.push(i);return s}function rk(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function ak({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=nk(t),c=rk(640),[u,d]=m.useState(!1),f=m.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(h=>h.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":se.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:se.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(h=>r.jsx(jg,{p:h,onClick:f},h.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(jg,{p:x,onClick:f,compact:!0},x.id))})}function jg({p:t,onClick:a,compact:s}){const i=t.available?se.statusBar.unlocked(t.label):t.kind==="cli-install"?se.statusBar.lockedCli(t.label):se.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(df,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function lk(){try{return typeof localStorage>"u"?null:localStorage.getItem(lc)}catch{return null}}function sk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:x,setTheme:h}=ty(),v=lk()==="auto",b=ik(f,x,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(Sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(ok,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Sg,{}),r.jsx(ak,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>h(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${f} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(ck,{mode:f}),r.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function ik(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function ok({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function Sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function ck({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ff=new Set;function ny(){for(const t of ff)t()}const uk=5,dk=1e3,fk=6e4;function pk(){const[t,a]=m.useState(void 0),[s,i]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),f=m.useRef(null),x=m.useRef(null),h=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},C=m.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),E=m.useCallback(async()=>{if(!h.current||document.visibilityState==="hidden")return;C();const N=new AbortController;f.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!h.current)return;const A=await T.json();if(!h.current)return;d.current=0,a(A.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{h.current&&b(I=>I+1)},fk)}catch(T){if(!h.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>uk){i(!0);return}const A=dk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{h.current&&b(I=>I+1)},A)}},[C]);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,S(),C()}),[C]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),C()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[C]);const w=m.useCallback(()=>{d.current=0,i(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(ff.add(w),()=>{ff.delete(w)}),[w]),{plugins:t,paused:s,loading:c,retry:w}}const sc=0,ba=1,Fl=2,ry=4;function kg(t){return()=>t}function mk(t){t()}function ay(t,a){return s=>t(a(s))}function wg(t,a){return()=>t(a)}function hk(t,a){return s=>t(a,s)}function _f(t){return t!==void 0}function xk(...t){return()=>{t.map(mk)}}function Gl(){}function ic(t,a){return a(t),t}function gk(t,a){return a(t)}function Nt(...t){return t}function ct(t,a){return t(ba,a)}function Fe(t,a){t(sc,a)}function Of(t){t(Fl)}function Lt(t){return t(ry)}function Ae(t,a){return ct(t,hk(a,sc))}function sr(t,a){const s=t(ba,i=>{s(),a(i)});return s}function Cg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function ly(t,a){return t===a}function Et(t=ly){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Ie(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ay(a,t)}function xr(t){return a=>()=>{a(t)}}function xe(t,...a){const s=vk(...a);return((i,c)=>{switch(i){case Fl:Of(t);return;case ba:return ct(t,s(c))}})}function gr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function Ur(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function We(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;ct(u,x=>{const h=s;s|=f,a[d]=x,h!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const f=()=>{u([d].concat(a))};s===c?f():i=f}}function vk(...t){return a=>t.reduceRight(gk,a)}function yk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ba:return u?s===u?void 0:(i(),s=u,a=ct(t,u),a):(i(),Gl);case Fl:i(),s=null;return}}}function ye(t){let a=t;const s=nt();return((i,c)=>{switch(i){case sc:a=c;break;case ba:{c(a);break}case ry:return a}return s(i,c)})}function pn(t,a){return ic(ye(a),s=>Ae(t,s))}function nt(){const t=[];return((a,s)=>{switch(a){case sc:t.slice().forEach(i=>{i(s)});return;case Fl:t.splice(0,t.length);return;case ba:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function In(t){return ic(nt(),a=>Ae(t,a))}function st(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:bk(),singleton:s}}const bk=()=>Symbol();function jk(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const f=i(c.map(x=>s(x)));return d&&a.set(u,f),f};return s(t)}function Wt(...t){const a=nt(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;ct(u,x=>{s[d]=x,i|=f,i===c&&Fe(a,s)})}),function(u,d){switch(u){case Fl:{Of(a);return}case ba:return i===c&&d(s),ct(a,d)}}}function Be(t,a=ly){return xe(t,Et(a))}function pf(...t){return function(a,s){switch(a){case Fl:return;case ba:return xk(...t.map(i=>ct(i,s)))}}}const Xt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Sk={[Xt.DEBUG]:"debug",[Xt.ERROR]:"error",[Xt.INFO]:"log",[Xt.WARN]:"warn"},kk=()=>typeof globalThis>"u"?window:globalThis,ja=st(()=>{const t=ye(Xt.ERROR);return{log:ye((a,s,i=Xt.INFO)=>{const c=kk().VIRTUOSO_LOG_LEVEL??Lt(t);i>=c&&console[Sk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Bf(t,a,s).callbackRef}function Bf(t,a,s){const i=Re.useRef(null);let c=d=>{};const u=Re.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const f=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?f():requestAnimationFrame(f)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function wk(t,a,s,i,c,u,d,f,x){const h=Re.useCallback(y=>{const v=Ck(y.children,a,f?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let C;S&&(C=b.ownerDocument.defaultView);const E=d?f?d.scrollLeft:d.scrollTop:S?f?C.scrollX||C.document.documentElement.scrollLeft:C.scrollY||C.document.documentElement.scrollTop:f?b.scrollLeft:b.scrollTop,w=d?f?d.scrollWidth:d.scrollHeight:S?f?C.document.documentElement.scrollWidth:C.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,N=d?f?d.offsetWidth:d.offsetHeight:S?f?C.innerWidth:C.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:w,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(f?Eg("column-gap",getComputedStyle(y).columnGap,c):Eg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,i,f]);return Bf(h,s,x)}function Ck(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const f=t.item(d);if(f.dataset.index===void 0)continue;const x=parseInt(f.dataset.index),h=parseFloat(f.dataset.knownSize),y=a(f,s);if(y===0&&i("Zero-sized element, this should not happen",{child:f},Xt.ERROR),y===h)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==x-1?u.push({endIndex:x,size:y,startIndex:x}):u[u.length-1].endIndex++}return u}function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Xt.WARN),a==="normal"?0:parseInt(a??"0",10)}function sy(t,a,s){const i=Re.useRef(null),c=Re.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const h=x.getBoundingClientRect(),y=h.width;let v,b;if(a){const S=a.getBoundingClientRect(),C=h.top-S.top;b=S.height-Math.max(0,C),v=C+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,h.top),v=h.top+S.scrollY}i.current={listHeight:h.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Bf(c,!0,s),f=Re.useCallback(()=>{c(d.current)},[c,d]);return Re.useEffect(()=>{var h;if(a){a.addEventListener("scroll",f);const y=new ResizeObserver(()=>{requestAnimationFrame(f)});return y.observe(a),()=>{a.removeEventListener("scroll",f),y.unobserve(a)}}const x=(h=d.current)==null?void 0:h.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",f),x==null||x.addEventListener("resize",f),()=>{x==null||x.removeEventListener("scroll",f),x==null||x.removeEventListener("resize",f)}},[f,a,d]),u}const yn=st(()=>{const t=nt(),a=nt(),s=ye(0),i=nt(),c=ye(0),u=nt(),d=nt(),f=ye(0),x=ye(0),h=ye(0),y=ye(0),v=nt(),b=nt(),S=ye(!1),C=ye(!1),E=ye(!1);return Ae(xe(t,we(({scrollTop:w})=>w)),a),Ae(xe(t,we(({scrollHeight:w})=>w)),d),Ae(a,c),{deviation:s,fixedFooterHeight:h,fixedHeaderHeight:x,footerHeight:y,headerHeight:f,horizontalDirection:C,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Zs={lvl:0};function iy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:f,value:x}=a(t[d]);u.push({end:f-1,start:i,value:c}),i=f,c=x}return u.push({end:1/0,start:i,value:c}),u}function xt(t){return t===Zs}function Js(t,a){if(!xt(t))return a===t.k?t.v:a<t.k?Js(t.l,a):Js(t.r,a)}function or(t,a,s="k"){if(xt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function On(t,a,s){return xt(t)?uy(a,s,1):a===t.k?Kt(t,{k:a,v:s}):a<t.k?Ng(Kt(t,{l:On(t.l,a,s)})):Ng(Kt(t,{r:On(t.r,a,s)}))}function Ol(){return Zs}function Bl(t,a,s){if(xt(t))return[];const i=or(t,a)[0];return Ek(hf(t,i,s))}function mf(t,a){if(xt(t))return Zs;const{k:s,l:i,r:c}=t;if(a===s){if(xt(i))return c;if(xt(c))return i;const[u,d]=cy(i);return Po(Kt(t,{k:u,l:oy(i),v:d}))}return a<s?Po(Kt(t,{l:mf(i,a)})):Po(Kt(t,{r:mf(c,a)}))}function Fa(t){return xt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function hf(t,a,s){if(xt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(hf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(hf(u,a,s))),f}function Po(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(_d(a))return dy(Kt(t,{lvl:s-1}));if(!xt(a)&&!xt(a.r))return Kt(a.r,{l:Kt(a,{r:a.r.l}),lvl:s,r:Kt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(_d(t))return xf(Kt(t,{lvl:s-1}));if(!xt(i)&&!xt(i.l)){const c=i.l,u=_d(c)?i.lvl-1:i.lvl;return Kt(c,{l:Kt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:xf(Kt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Kt(t,a){return uy(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function oy(t){return xt(t.r)?t.l:Po(Kt(t,{r:oy(t.r)}))}function _d(t){return xt(t)||t.lvl>t.r.lvl}function cy(t){return xt(t.r)?[t.k,t.v]:cy(t.r)}function uy(t,a,s,i=Zs,c=Zs){return{k:t,l:i,lvl:s,r:c,v:a}}function Ng(t){return xf(dy(t))}function dy(t){const{l:a}=t;return!xt(a)&&a.lvl===t.lvl?Kt(a,{r:Kt(t,{l:a.r})}):t}function xf(t){const{lvl:a,r:s}=t;return!xt(s)&&!xt(s.r)&&s.lvl===a&&s.r.lvl===a?Kt(s,{l:Kt(t,{r:s.l}),lvl:a+1}):t}function Ek(t){return iy(t,({k:a,v:s})=>({index:a,value:s}))}function fy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function ei(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const If=st(()=>({recalcInProgress:ye(!1)}),[],{singleton:!0});function py(t,a,s){return t[qo(t,a,s)]}function qo(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],f=s(d,a);if(f===0)return u;if(f===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Nk(t,a,s,i){const c=qo(t,a,i),u=qo(t,s,i,c);return t.slice(c,u+1)}function va(t,a){return Math.round(t.getBoundingClientRect()[a])}function oc(t){return!xt(t.groupOffsetTree)}function $f({index:t},a){return a===t?0:a<t?-1:1}function Tk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Rk(t,a){let s=xt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),xt(t)){t=On(t,0,u);continue}const f=Bl(t,d-1,c+1);if(f.some(Ok(i)))continue;let x=!1,h=!1;for(const{end:y,start:v,value:b}of f)x?(c>=v||u===b)&&(t=mf(t,v)):(h=b!==u,x=!0),y>c&&c>=v&&b!==u&&(t=On(t,c+1,b));h&&(t=On(t,d,u))}return[t,s]}function Ak(t){return typeof t.groupIndex<"u"}function Lk({offset:t},a){return a===t?0:a<t?-1:1}function ti(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=py(a,t,$f),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function my(t,a){if(!oc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function hy(t,a,s){if(Ak(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=my(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Mk(t,a,s,i=0){return i>0&&(a=Math.max(a,py(t,i,$f).offset)),iy(Nk(t,a,s,Lk),_k)}function zk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Xt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&xt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((C,E)=>On(On(C,E,b),E+1,S),d)}else[d,f]=Rk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:h,lastSize:y,offsetTree:v}=gf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>On(b,S,ti(S,v,c)),Ol()),lastIndex:x,lastOffset:h,lastSize:y,offsetTree:v,sizeTree:d}}function Dk(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Tg(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function gf(t,a,s,i){let c=t,u=0,d=0,f=0,x=0;if(a!==0){x=qo(c,a-1,$f),f=c[x].offset;const h=or(s,a-1);u=h[0],d=h[1],c.length&&c[x].size===or(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:h,value:y}of Bl(s,a,1/0)){const v=h-u,b=v*d+f+v*i;c.push({index:h,offset:b,size:y}),u=h,f=b,d=y}return{lastIndex:u,lastOffset:f,lastSize:d,offsetTree:c}}function _k(t){return{index:t.index,value:t}}function Ok(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Bk={offsetHeight:"height",offsetWidth:"width"},br=st(([{log:t},{recalcInProgress:a}])=>{const s=nt(),i=nt(),c=pn(i,0),u=nt(),d=nt(),f=ye(0),x=ye([]),h=ye(void 0),y=ye(void 0),v=ye(void 0),b=ye(void 0),S=ye((k,O)=>va(k,Bk[O])),C=ye(void 0),E=ye(0),w=Tk(),N=pn(xe(s,We(x,t,E),gr(zk,w),Et()),w),T=pn(xe(x,Et(),gr((k,O)=>({current:O,prev:k.current}),{current:[],prev:[]}),we(({prev:k})=>k)),[]);Ae(xe(x,Ie(k=>k.length>0),We(N,E),we(([k,O,z])=>{const _=k.reduce(($,q,K)=>On($,q,ti(q,O.offsetTree,z)||K),Ol());return{...O,groupIndices:k,groupOffsetTree:_}})),N),Ae(xe(i,We(N),Ie(([k,{lastIndex:O}])=>k<O),we(([k,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:k}])),s),Ae(h,y);const A=pn(xe(h,we(k=>k===void 0)),!0);Ae(xe(y,Ie(k=>k!==void 0&&xt(Lt(N).sizeTree)),we(k=>{const O=Lt(v),z=Lt(x).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:k,startIndex:1}]:[]:[{endIndex:0,size:k,startIndex:0}]})),s),Ae(xe(b,Ie(k=>k!==void 0&&k.length>0&&xt(Lt(N).sizeTree)),we(k=>{const O=[];let z=k[0],_=0;for(let $=1;$<k.length;$++){const q=k[$];q!==z&&(O.push({endIndex:$-1,size:z,startIndex:_}),z=q,_=$)}return O.push({endIndex:k.length-1,size:z,startIndex:_}),O})),s),Ae(xe(x,We(v,y),Ie(([,k,O])=>k!==void 0&&O!==void 0),we(([k,O,z])=>{const _=[];for(let $=0;$<k.length;$++){const q=k[$],K=k[$+1];_.push({startIndex:q,endIndex:q,size:O}),K!==void 0&&_.push({startIndex:q+1,endIndex:K-1,size:z})}return _})),s);const I=In(xe(s,We(N),gr(({sizes:k},[O,z])=>({changed:z!==k,sizes:z}),{changed:!1,sizes:w}),we(k=>k.changed)));ct(xe(f,gr((k,O)=>({diff:k.prev-O,prev:O}),{diff:0,prev:0}),we(k=>k.diff)),k=>{const{groupIndices:O}=Lt(N);if(k>0)Fe(a,!0),Fe(u,k+Tg(k,O));else if(k<0){const z=Lt(T);z.length>0&&(k-=Tg(-k,z)),Fe(d,k)}}),ct(xe(f,We(t)),([k,O])=>{k<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:f},Xt.ERROR)});const L=In(u);Ae(xe(u,We(N),we(([k,O])=>{const z=O.groupIndices.length>0,_=[],$=O.lastSize;if(z){const q=Js(O.sizeTree,0);let K=0,Q=0;for(;K<k;){const M=O.groupIndices[Q],B=O.groupIndices.length===Q+1?1/0:O.groupIndices[Q+1]-M-1;_.push({endIndex:M,size:q,startIndex:M}),_.push({endIndex:M+1+B-1,size:$,startIndex:M+1}),Q++,K+=B+1}const U=Fa(O.sizeTree);return K!==k&&U.shift(),U.reduce((M,{k:B,v:F})=>{let te=M.ranges;return M.prevSize!==0&&(te=[...M.ranges,{endIndex:B+k-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:B+k,prevSize:F,ranges:te}},{prevIndex:k,prevSize:0,ranges:_}).ranges}return Fa(O.sizeTree).reduce((q,{k:K,v:Q})=>({prevIndex:K+k,prevSize:Q,ranges:[...q.ranges,{endIndex:K+k-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:$,ranges:[]}).ranges})),s);const H=In(xe(d,We(N,E),we(([k,{offsetTree:O},z])=>{const _=-k;return ti(_,O,z)})));return Ae(xe(d,We(N,E),we(([k,O,z])=>{if(O.groupIndices.length>0){if(xt(O.sizeTree))return O;let $=Ol();const q=Lt(T);let K=0,Q=0,U=0;for(;K<-k;){U=q[Q];const M=q[Q+1]-U-1;Q++,K+=M+1}if($=Fa(O.sizeTree).reduce((M,{k:B,v:F})=>On(M,Math.max(0,B+k),F),$),K!==-k){const M=Js(O.sizeTree,U);$=On($,0,M);const B=or(O.sizeTree,-k+1)[1];$=On($,1,B)}return{...O,sizeTree:$,...gf(O.offsetTree,0,$,z)}}const _=Fa(O.sizeTree).reduce(($,{k:q,v:K})=>On($,Math.max(0,q+k),K),Ol());return{...O,sizeTree:_,...gf(O.offsetTree,0,_,z)}})),N),{beforeUnshiftWith:L,data:C,defaultItemSize:y,firstItemIndex:f,fixedItemSize:h,fixedGroupSize:v,gap:E,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:I,shiftWith:d,shiftWithOffset:H,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:A,unshiftWith:u}},Nt(ja,If),{singleton:!0});function Ik(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const xy=st(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=nt(),d=nt(),f=In(xe(u,we(Ik)));return Ae(xe(f,we(x=>x.totalCount)),s),Ae(xe(f,we(x=>x.groupIndices)),t),Ae(xe(Wt(c,a,i),Ie(([x,h])=>oc(h)),we(([x,h,y])=>or(h.groupOffsetTree,Math.max(x-y,0),"v")[0]),Et(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Nt(br,yn)),Sa=st(([{log:t}])=>{const a=ye(!1),s=In(xe(a,Ie(i=>i),Et()));return ct(a,i=>{i&&Lt(t)("props updated",{},Xt.DEBUG)}),{didMount:s,propsReady:a}},Nt(ja),{singleton:!0}),$k=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!$k)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ii=st(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:f,scrollingInProgress:x,scrollTo:h,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=nt(),C=nt(),E=ye(0);let w=null,N=null,T=null;function A(){w!==null&&(w(),w=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Fe(x,!1)}return Ae(xe(S,We(s,v,i,E,f,d,b),We(t,u,c),we(([[I,L,H,k,O,z,_,$],q,K,Q])=>{const U=gy(I),{align:M,behavior:B,offset:F}=U,te=k-1,V=hy(U,L,te);let D=ti(V,L.offsetTree,q)+z;M==="end"?(D+=K+or(L.sizeTree,V)[1]-H+Q,V===te&&(D+=_)):M==="center"?D+=(K+or(L.sizeTree,V)[1]-H+Q)/2:D-=O,F!==void 0&&F!==0&&(D+=F);const W=X=>{A(),X?($("retrying to scroll to",{location:I},Xt.DEBUG),Fe(S,I)):(Fe(C,!0),$("list did not change, scroll successful",{},Xt.DEBUG))};if(A(),B==="smooth"){let X=!1;T=ct(a,ee=>{X=X||ee}),w=sr(y,()=>{W(X)})}else w=sr(xe(a,Uk(150)),W);return N=setTimeout(()=>{A()},1200),Fe(x,!0),$("scrolling from index to",{behavior:B,index:V,top:D},Xt.DEBUG),{behavior:B,top:D}})),h),{scrollTargetReached:C,scrollToIndex:S,topListHeight:E}},Nt(br,yn,ja),{singleton:!0});function Uk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Uf(t,a){t===0?a():requestAnimationFrame(()=>{Uf(t-1,a)})}function Hf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const oi=st(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const f=ye(!0),x=ye(0),h=ye(!0);return Ae(xe(d,We(x),Ie(([y,v])=>v!==0),xr(!1)),f),Ae(xe(d,We(x),Ie(([y,v])=>v!==0),xr(!1)),h),ct(xe(Wt(a,d),We(f,s,t,h),Ie(([[,y],v,{sizeTree:b},S,C])=>y&&(!xt(b)||_f(S))&&!v&&!C),We(x)),([,y])=>{sr(c,()=>{Fe(h,!0)}),Uf(4,()=>{sr(i,()=>{Fe(f,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:h,initialTopMostItemIndex:x,scrolledToInitialItem:f}},Nt(br,yn,ii,Sa),{singleton:!0});function vy(t,a){return Math.abs(t-a)<1.01}const ni="up",Ws="down",Hk="none",Pk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Vk=0,ci=st(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ye(!1),f=ye(!0),x=nt(),h=nt(),y=ye(4),v=ye(Vk),b=pn(xe(pf(xe(Be(c),Wa(1),xr(!0)),xe(Be(c),Wa(1),xr(!1),Cg(100))),Et()),!1),S=pn(xe(pf(xe(s,xr(!0)),xe(s,xr(!1),Cg(200))),Et()),!1);Ae(xe(Wt(Be(c),Be(v)),we(([T,A])=>T<=A),Et()),f),Ae(xe(f,Ur(50)),h);const C=In(xe(Wt(i,Be(u),Be(a),Be(t),Be(y)),gr((T,[{scrollHeight:A,scrollTop:I},L,H,k,O])=>{const z=I+L-A>-O,_={scrollHeight:A,scrollTop:I,viewportHeight:L};if(z){let q,K;return I>T.state.scrollTop?(q="SCROLLED_DOWN",K=T.state.scrollTop-I):(q="SIZE_DECREASED",K=T.state.scrollTop-I||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:K,state:_}}let $;return _.scrollHeight>T.state.scrollHeight?$="SIZE_INCREASED":L<T.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":I<T.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:_}},Pk),Et((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=pn(xe(i,gr((T,{scrollHeight:A,scrollTop:I,viewportHeight:L})=>{if(!vy(T.scrollHeight,A)){const H=A-(I+L)<1;return T.scrollTop!==I&&H?{changed:!0,jump:T.scrollTop-I,scrollHeight:A,scrollTop:I}:{changed:!0,jump:0,scrollHeight:A,scrollTop:I}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:I}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(T=>T.changed),we(T=>T.jump)),0);Ae(xe(C,we(T=>T.atBottom)),d),Ae(xe(d,Ur(50)),x);const w=ye(Ws);Ae(xe(i,we(({scrollTop:T})=>T),Et(),gr((T,A)=>Lt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?ni:Ws,prevScrollTop:A},{direction:Ws,prevScrollTop:0}),we(T=>T.direction)),w),Ae(xe(i,Ur(50),xr(Hk)),w);const N=ye(0);return Ae(xe(b,Ie(T=>!T),xr(0)),N),Ae(xe(c,Ur(100),We(b),Ie(([T,A])=>A),gr(([T,A],[I])=>[A,I],[0,0]),we(([T,A])=>A-T)),N),{atBottomState:C,atBottomStateChange:x,atBottomThreshold:y,atTopStateChange:h,atTopThreshold:v,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:w,scrollVelocity:N}},Nt(yn)),ri="top",ai="bottom",Rg="none";function Ag(t,a,s){return typeof t=="number"?s===ni&&a===ri||s===Ws&&a===ai?t:0:s===ni?a===ri?t.main:t.reverse:a===ai?t.main:t.reverse}function Lg(t,a){return typeof t=="number"?t:t[a]??0}const Pf=st(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=nt(),d=ye(0),f=ye(0),x=ye(0),h=pn(xe(Wt(Be(i),Be(c),Be(s),Be(u,ei),Be(x),Be(d),Be(a),Be(t),Be(f)),we(([y,v,b,[S,C],E,w,N,T,A])=>{const I=y-T,L=w+N,H=Math.max(b-I,0);let k=Rg;const O=Lg(A,ri),z=Lg(A,ai);return S-=T,S+=b+N,C+=b+N,C-=T,S>y+L-O&&(k=ni),C<y-H+v+z&&(k=Ws),k!==Rg?[Math.max(I-b-Ag(E,ri,k)-O,0),I-H-N+v+Ag(E,ai,k)+z]:null}),Ie(y=>y!==null),Et(ei)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:x,topListHeight:d,visibleRange:h}},Nt(yn),{singleton:!0});function Fk(t,a,s){if(oc(a)){const i=my(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Od={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Vo(t,a,s,i,c,u){const{lastIndex:d,lastOffset:f,lastSize:x}=c;let h=0,y=0;if(t.length>0){h=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=f+v*x+(v-1)*i,S=h,C=b-y;return{bottom:y,firstItemIndex:u,items:Mg(t,c,u),offsetBottom:C,offsetTop:h,top:S,topItems:Mg(a,c,u),topListHeight:a.reduce((E,w)=>w.size+E,0),totalCount:s}}function yy(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const f=t+d,x=Hf(a,f),h=Array.from({length:f}).map((y,v)=>({data:u[v+x],index:v+x,offset:0,size:0}));return Vo(h,[],f,c,s,i)}function Mg(t,a,s){if(t.length===0)return[];if(!oc(a))return t.map(h=>({...h,index:h.index+s,originalIndex:h.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let f,x=0;for(const h of t){(!f||f.end<h.index)&&(f=d.shift(),x=a.groupIndices.indexOf(f.start));let y;h.index===f.start?y={index:x,type:"group"}:y={groupIndex:x,index:h.index-(x+1)+s},u.push({...y,data:h.data,offset:h.offset,originalIndex:h.index,size:h.size})}return u}function zg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=st(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:f,visibleRange:x},{initialTopMostItemIndex:h,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:C}])=>{const E=ye([]),w=ye(0),N=nt(),T=ye(0);Ae(u.topItemsIndexes,E);const A=pn(xe(Wt(S,C,Be(x,ei),Be(c),Be(i),Be(h),y,Be(E),Be(a),Be(s),Be(T),t),Ie(([k,O,,z,,,,,,,,_])=>{const $=_!==void 0&&_.length!==z;return k&&!O&&!$}),we(([,,[k,O],z,_,$,q,K,Q,U,M,B])=>{var ge,Le;const F=_,{offsetTree:te,sizeTree:V}=F,D=Lt(w);if(z===0)return{...Od,totalCount:z};if(k===0&&O===0)return D===0?{...Od,totalCount:z}:yy(D,$,_,Q,U,B||[]);if(xt(V))return D>0?null:Vo(Fk(Hf($,z),F,B),[],z,U,F,Q);const W=[];if(K.length>0){const Ee=K[0],Me=K[K.length-1];let Pe=0;for(const ie of Bl(V,Ee,Me)){const fe=ie.value,he=Math.max(ie.start,Ee),be=Math.min(ie.end,Me);for(let je=he;je<=be;je++)W.push({data:B==null?void 0:B[je],index:je,offset:Pe,size:fe}),Pe+=fe}}if(!q)return Vo([],W,z,U,F,Q);const X=K.length>0?K[K.length-1]+1:0,ee=Mk(te,k,O,X);if(ee.length===0)return null;const de=z-1,le=ic([],Ee=>{for(const Me of ee){const Pe=Me.value;let ie=Pe.offset,fe=Me.start;const he=Pe.size;if(Pe.offset<k){fe+=Math.floor((k-Pe.offset+U)/(he+U));const je=fe-Me.start;ie+=je*he+je*U}fe<X&&(ie+=(X-fe)*he,fe=X);const be=Math.min(Me.end,de);for(let je=fe;je<=be&&!(ie>=O);je++)Ee.push({data:B==null?void 0:B[je],index:je,offset:ie,size:he}),ie+=he+U}}),ce=zg(M,ri),ne=zg(M,ai);if(le.length>0&&(ce>0||ne>0)){const Ee=le[0],Me=le[le.length-1];if(ce>0&&Ee.index>X){const Pe=Math.min(ce,Ee.index-X),ie=[];let fe=Ee.offset;for(let he=Ee.index-1;he>=Ee.index-Pe;he--){const be=((ge=Bl(V,he,he)[0])==null?void 0:ge.value)??Ee.size;fe-=be+U,ie.unshift({data:B==null?void 0:B[he],index:he,offset:fe,size:be})}le.unshift(...ie)}if(ne>0&&Me.index<de){const Pe=Math.min(ne,de-Me.index);let ie=Me.offset+Me.size+U;for(let fe=Me.index+1;fe<=Me.index+Pe;fe++){const he=((Le=Bl(V,fe,fe)[0])==null?void 0:Le.value)??Me.size;le.push({data:B==null?void 0:B[fe],index:fe,offset:ie,size:he}),ie+=he+U}}}return Vo(le,W,z,U,F,Q)}),Ie(k=>k!==null),Et()),Od);Ae(xe(t,Ie(_f),we(k=>k==null?void 0:k.length)),c),Ae(xe(A,we(k=>k.topListHeight)),v),Ae(v,f),Ae(xe(A,we(k=>[k.top,k.bottom])),d),Ae(xe(A,we(k=>k.items)),N);const I=In(xe(A,Ie(({items:k})=>k.length>0),We(c,t),Ie(([{items:k},O])=>k[k.length-1].originalIndex===O-1),we(([,k,O])=>[k-1,O]),Et(ei),we(([k])=>k))),L=In(xe(A,Ur(200),Ie(({items:k,topItems:O})=>k.length>0&&k[0].originalIndex===O.length),we(({items:k})=>k[0].index),Et())),H=In(xe(A,Ie(({items:k})=>k.length>0),we(({items:k})=>{let O=0,z=k.length-1;for(;k[O].type==="group"&&O<z;)O++;for(;k[z].type==="group"&&z>O;)z--;return{endIndex:k[z].index,startIndex:k[O].index}}),Et(fy)));return{endReached:I,initialItemCount:w,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:H,startReached:L,topItemsIndexes:E,...b}},Nt(br,xy,Pf,oi,ii,ci,Sa,If),{singleton:!0}),by=st(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=nt(),d=pn(xe(Wt(s,t,i,a,c),we(([f,x,h,y,v])=>f+x+h+y+v.offsetBottom+v.bottom)),0);return Ae(Be(d),u),{totalListHeight:d,totalListHeightChanged:u}},Nt(yn,Xa),{singleton:!0}),Gk=st(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ye(!1),i=pn(xe(Wt(s,t,a),Ie(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Ur(0),Et()),0);return{alignToBottom:s,paddingTopAddition:i}},Nt(yn,by),{singleton:!0}),jy=st(()=>({context:ye(null)})),Wk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,Sy=st(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:x},{scrollToIndex:h}])=>{const y=nt();return Ae(xe(y,We(a,x,s,u,c,i,f),We(t),we(([[v,b,S,C,E,w,N,T],A])=>{const{calculateViewLocation:I=Wk,done:L,...H}=v,k=hy(v,b,C-1),O=ti(k,b.offsetTree,A)+E+w,z=O+or(b.sizeTree,k)[1],_=T+w,$=T+S-N,q=I({itemBottom:z,itemTop:O,locationParams:H,viewportBottom:$,viewportTop:_});return q!==null?L&&sr(xe(d,Ie(K=>!K),Wa(Lt(d)?1:2)),L):L==null||L(),q}),Ie(v=>v!==null)),h),{scrollIntoView:y}},Nt(br,yn,ii,Xa,ja),{singleton:!0});function Dg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const qk=(t,a)=>typeof t=="function"?Dg(t(a)):a&&Dg(t),Yk=st(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:f},{didMount:x,propsReady:h},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const C=ye(!1),E=nt();let w=null;function N(L){Fe(d,{align:"end",behavior:L,index:"LAST"})}ct(xe(Wt(xe(Be(a),Wa(1)),x),We(Be(C),u,f,v),we(([[L,H],k,O,z,_])=>{let $=H&&z,q="auto";return $&&(q=qk(k,O||_),$=$&&q!==!1),{followOutputBehavior:q,shouldFollow:$,totalCount:L}}),Ie(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:H})=>{w!==null&&(w(),w=null),Lt(s)!==void 0?requestAnimationFrame(()=>{Lt(y)("following output to ",{totalCount:H},Xt.DEBUG),N(L)}):w=sr(t,()=>{Lt(y)("following output to ",{totalCount:H},Xt.DEBUG),N(L),w=null})});function T(L){const H=sr(c,k=>{L&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(Lt(y)("scrolling to bottom due to increased size",{},Xt.DEBUG),N("auto"))});setTimeout(H,100)}ct(xe(Wt(Be(C),a,h),Ie(([L,,H])=>L!==!1&&H),gr(({value:L},[,H])=>({refreshed:L===H,value:H}),{refreshed:!1,value:0}),Ie(({refreshed:L})=>L),We(C,a)),([,L])=>{Lt(f)&&T(L!==!1)}),ct(E,()=>{T(Lt(C)!==!1)}),ct(Wt(Be(C),c),([L,H])=>{L!==!1&&!H.atBottom&&H.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ye(null),I=nt();return Ae(pf(xe(Be(i),we(L=>(L==null?void 0:L.length)??0)),xe(Be(a))),I),ct(xe(Wt(xe(I,Wa(1)),x),We(Be(A),f,v,b),we(([[L,H],k,O,z,_])=>H&&O&&(k==null?void 0:k({context:_,totalCount:L,scrollingInProgress:z}))),Ie(L=>!!L),Ur(0)),L=>{w!==null&&(w(),w=null),Lt(s)!==void 0?requestAnimationFrame(()=>{Lt(y)("scrolling into view",{}),Fe(S,L)}):w=sr(t,()=>{Lt(y)("scrolling into view",{}),Fe(S,L),w=null})}),{autoscrollToBottom:E,followOutput:C,scrollIntoViewOnChange:A}},Nt(br,ci,ii,oi,Sa,ja,yn,jy,Sy)),Kk=st(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Ae(xe(f,We(u),Ie(([,x])=>x!==0),We(c,i,a,s,t),we(([[,x],h,y,v,b,S=[]])=>yy(x,h,y,v,b,S))),d),{}),Nt(br,oi,Xa,Sa),{singleton:!0}),Xk=st(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ye(0);return ct(xe(t,We(i),Ie(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(xe(s,Wa(1),Ie(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:i}},Nt(Sa,yn,Xa),{singleton:!0}),ky=st(([{scrollVelocity:t}])=>{const a=ye(!1),s=nt(),i=ye(!1);return Ae(xe(t,We(i,a,s),Ie(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,f])=>{const{enter:x,exit:h}=u;if(d){if(h(c,f))return!1}else if(x(c,f))return!0;return d}),Et()),a),ct(xe(Wt(a,t,s),We(i)),([[c,u,d],f])=>{c&&f!==!1&&f!==void 0&&f.change&&f.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Nt(ci),{singleton:!0}),Vf=st(([{scrollContainerState:t,scrollTo:a}])=>{const s=nt(),i=nt(),c=nt(),u=ye(!1),d=ye(void 0);return Ae(xe(Wt(s,i),we(([{scrollTop:f,viewportHeight:x},{offsetTop:h,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,f-h),viewportHeight:x}))),t),Ae(xe(a,We(i),we(([f,{offsetTop:x}])=>({...f,top:f.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Nt(yn)),Qk=st(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:x}])=>{const h=nt(),y=ye(void 0),v=ye(null),b=ye(null);return Ae(f,v),Ae(x,b),ct(xe(h,We(a,i,d,v,b,s)),([S,C,E,w,N,T,A])=>{const I=Dk(C.sizeTree);w&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:I,scrollTop:E})}),Ae(xe(y,Ie(_f),we(Zk)),c),Ae(xe(u,We(y),Ie(([,S])=>S!==void 0),Et(),we(([,S])=>S.ranges)),t),{getState:h,restoreStateFrom:y}},Nt(br,yn,oi,Sa,Vf));function Zk(t){return{align:"start",index:0,offset:t.scrollTop}}const Jk=st(([{topItemsIndexes:t}])=>{const a=ye(0);return Ae(xe(a,Ie(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Nt(Xa));function wy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const ew=wy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),tw=st(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:f},{listState:x},{beforeUnshiftWith:h,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:C}])=>{const E=In(xe(x,We(d),gr(([,N,T,A],[{bottom:I,items:L,offsetBottom:H,totalCount:k},O])=>{const z=I+H;let _=0;return T===k&&N.length>0&&L.length>0&&(L[0].originalIndex===0&&N[0].originalIndex===0||(_=z-A,_!==0&&(_+=O))),[_,L,k,z]},[0,[],0,0]),Ie(([N])=>N!==0),We(i,f,s,c,S,C),Ie(([,N,T,A,,,I])=>!I&&!A&&N!==0&&T===ni),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Xt.DEBUG),N))));function w(N){N>0?(Fe(a,{behavior:"auto",top:-N}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-N}))}return ct(xe(E,We(t,u)),([N,T,A])=>{A&&ew()?Fe(t,T-N):w(-N)}),ct(xe(Wt(pn(u,!1),t,C),Ie(([N,T,A])=>!N&&!A&&T!==0),we(([N,T])=>T),Ur(1)),w),Ae(xe(v,we(N=>({top:-N}))),a),ct(xe(h,We(b,y),we(([N,{groupIndices:T,lastSize:A,sizeTree:I},L])=>{function H($){return $*(A+L)}if(T.length===0)return H(N);let k=0;const O=Js(I,0);let z=0,_=0;for(;z<N;){z++,k+=O;let $=T.length===_+1?1/0:T[_+1]-T[_]-1;z+$>N&&(k-=O,$=N-z+1),z+=$,k+=H($),_++}return k})),N=>{Fe(t,N),requestAnimationFrame(()=>{Fe(a,{top:N}),requestAnimationFrame(()=>{Fe(t,0),Fe(C,!1)})})}),{deviation:t}},Nt(yn,ci,Xa,br,ja,If)),nw=st(([t,a,s,i,c,u,d,f,x,h,y])=>({...t,...a,...s,...i,...c,...u,...d,...f,...x,...h,...y}),Nt(Pf,Kk,Sa,ky,by,Xk,Gk,Vf,Sy,ja,jy)),Cy=st(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:f,itemSize:x,sizeRanges:h,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:C,initialTopMostItemIndex:E,scrolledToInitialItem:w},N,T,A,I,{scrollToIndex:L},H,{topItemCount:k},{groupCounts:O},z])=>{const{listState:_,minOverscanItemCount:$,topItemsIndexes:q,rangeChanged:K,...Q}=I;return Ae(K,z.scrollSeekRangeChanged),Ae(xe(z.windowViewportRect,we(U=>U.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:f,initialItemFinalLocationReached:C,initialTopMostItemIndex:E,scrolledToInitialItem:w,sizeRanges:h,topItemCount:k,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:x,listState:_,minOverscanItemCount:$,scrollToIndex:L,statefulTotalCount:v,trackItemSizes:S,rangeChanged:K,...Q,...z,...N,sizes:y,...T}},Nt(br,oi,yn,Qk,Yk,Xa,ii,tw,Jk,xy,nw));function rw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const To=typeof document<"u"?Re.useLayoutEffect:Re.useEffect;function Ey(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),f=Re.createContext({});function x(w,N){w.propsReady!==void 0&&Fe(w.propsReady,!1);for(const T of i){const A=w[a.required[T]];Fe(A,N[T])}for(const T of c)if(T in N){const A=w[a.optional[T]];Fe(A,N[T])}w.propsReady!==void 0&&Fe(w.propsReady,!0)}function h(w){return u.reduce((N,T)=>(N[T]=A=>{const I=w[a.methods[T]];Fe(I,A)},N),{})}function y(w){return d.reduce((N,T)=>(N[T]=yk(w[a.events[T]]),N),{})}const v=Re.forwardRef(function(w,N){const{children:T,...A}=w,[I]=Re.useState(()=>ic(jk(t),k=>{x(k,A)})),[L]=Re.useState(wg(y,I));To(()=>{for(const k of d)k in A&&ct(L[k],A[k]);return()=>{Object.values(L).map(Of)}},[A,L,I]),To(()=>{x(I,A)}),Re.useImperativeHandle(N,kg(h(I)));const H=s;return r.jsx(f.Provider,{value:I,children:s!==void 0?r.jsx(H,{...rw([...i,...c,...d],A),children:T}):T})}),b=w=>{const N=Re.useContext(f);return Re.useCallback(T=>{Fe(N[w],T)},[N,w])},S=w=>{const N=Re.useContext(f)[w],T=Re.useCallback(A=>ct(N,A),[N]);return Re.useSyncExternalStore(T,()=>Lt(N),()=>Lt(N))},C=w=>{const N=Re.useContext(f)[w],[T,A]=Re.useState(wg(Lt,N));return To(()=>ct(N,I=>{I!==T&&A(kg(I))}),[N,T]),T},E=parseInt(Re.version)>=18?S:C;return{Component:v,useEmitter:(w,N)=>{const T=Re.useContext(f)[w];To(()=>ct(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const Ny=Re.createContext(void 0),Ty=Re.createContext(void 0),Bd="-webkit-sticky",_g="sticky",Ff=wy(()=>{if(typeof document>"u")return _g;const t=document.createElement("div");return t.style.position=Bd,t.style.position===Bd?Bd:_g}),Ry=typeof document<"u"?Re.useLayoutEffect:Re.useEffect;function Id(t){return"self"in t}function aw(t){return"body"in t}function Ay(t,a,s,i=Gl,c,u){const d=Re.useRef(null),f=Re.useRef(null),x=Re.useRef(null),h=Re.useCallback(b=>{let S,C,E;const w=b.target;if(aw(w)||Id(w)){const T=Id(w)?w:w.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,C=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?w.scrollLeft:w.scrollTop,S=u===!0?w.scrollWidth:w.scrollHeight,C=u===!0?w.offsetWidth:w.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:C})};b.suppressFlushSync===!0?N():vS.flushSync(N),f.current!==null&&(E===f.current||E<=0||E===S-C)&&(f.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Re.useEffect(()=>{const b=c||d.current;return i(c||d.current),h({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",h,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",h)}},[d,h,s,i,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 C=b.behavior==="smooth";let E,w,N;Id(S)?(w=Math.max(va(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(w=S[u===!0?"scrollWidth":"scrollHeight"],E=va(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=w-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),vy(E,w)||b.top===N){t({scrollHeight:w,scrollTop:N,viewportHeight:E}),C&&a(!0);return}C?(f.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,f.current=null,a(!0)},1e3)):f.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 Gf(t){return t}const lw=st(()=>{const t=ye(f=>`Item ${f}`),a=ye(f=>`Group ${f}`),s=ye({}),i=ye(Gf),c=ye("div"),u=ye(Gl),d=(f,x=null)=>pn(xe(s,we(h=>h[f]),Et()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),sw=st(([t,a])=>({...t,...a}),Nt(Cy,lw)),iw=({height:t})=>r.jsx("div",{style:{height:t}}),ow={overflowAnchor:"none",position:Ff(),zIndex:1},Ly={overflowAnchor:"none"},cw={...Ly,display:"inline-block",height:"100%"},Og=Re.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Jn("sizeRanges"),i=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Jn("windowScrollContainerState"),d=Jn("scrollContainerState"),f=c||i?u:d,x=Ue("itemContent"),h=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),C=Jn("gap"),E=Ue("horizontalDirection"),{callbackRef:w}=wk(s,b,v,t?Gl:f,S,C,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Re.useState(0);Wf("deviation",Q=>{N!==Q&&T(Q)});const A=Ue("EmptyPlaceholder"),I=Ue("ScrollSeekPlaceholder")??iw,L=Ue("ListComponent"),H=Ue("ItemComponent"),k=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),_=Ue("groupIndices").length>0,$=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),K=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:$?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:$?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...fn(A,h)}):r.jsx(L,{...fn(L,h),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:K,children:(t?a.topItems:a.items).map(Q=>{const U=Q.originalIndex,M=O(U+a.firstItemIndex,Q.data,h);return z?m.createElement(I,{...fn(I,h),height:Q.size,index:Q.index,key:M,type:Q.type||"item",...Q.type==="group"?{}:{groupIndex:Q.groupIndex}}):Q.type==="group"?m.createElement(k,{...fn(k,h),"data-index":U,"data-item-index":Q.index,"data-known-size":Q.size,key:M,style:ow},y(Q.index,h)):m.createElement(H,{...fn(H,h),...pw(H,Q.data),"data-index":U,"data-item-group-index":Q.groupIndex,"data-item-index":Q.index,"data-known-size":Q.size,key:M,style:E?cw:Ly},_?x(Q.index,Q.groupIndex,Q.data,h):x(Q.index,Q.data,h))})})}),uw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},dw={outline:"none",overflowX:"auto",position:"relative"},cc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),fw={position:Ff(),top:0,width:"100%",zIndex:1};function fn(t,a){if(typeof t!="string")return{context:a}}function pw(t,a){return{item:typeof t=="string"?void 0:a}}const mw=Re.memo(function(){const t=Ue("HeaderComponent"),a=Jn("headerHeight"),s=Ue("HeaderFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),hw=Re.memo(function(){const t=Ue("FooterComponent"),a=Jn("footerHeight"),s=Ue("HeaderFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null});function My({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Re.memo(function({children:i,style:c,context:u,...d}){const f=s("scrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:C}=Ay(f,h,x,y,void 0,v);return t("scrollTo",C),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?dw:uw,...c},tabIndex:0,...d,...fn(x,u),children:i})})}function zy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Re.memo(function({children:i,style:c,context:u,...d}){const f=s("windowScrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Re.useRef(null),C=a("scrollerRef"),{scrollByCallback:E,scrollerRef:w,scrollToCallback:N}=Ay(f,h,x,C,b);return Ry(()=>{var T;return w.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{w.current=null}},[w,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...fn(x,u),children:i})})}const xw=({children:t})=>{const a=Re.useContext(Ny),s=Jn("viewportHeight"),i=Jn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Re.useMemo(()=>ay(s,x=>va(x,u?"width":"height")),[s,u]),f=Ka(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Re.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:f,style:cc(c),children:t})},gw=({children:t})=>{const a=Re.useContext(Ny),s=Jn("windowViewportRect"),i=Jn("fixedItemHeight"),c=Ue("customScrollParent"),u=sy(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Re.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:cc(d),children:t})},vw=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),i={...fw,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:i,...fn(a,c),children:t})},yw=Re.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,i=Ue("customScrollParent"),c=Ue("context");return r.jsxs(i||a?Sw:jw,{...t,context:c,children:[s&&r.jsx(vw,{children:r.jsx(Og,{showTopList:!0})}),r.jsxs(i||a?gw:xw,{children:[r.jsx(mw,{}),r.jsx(Og,{}),r.jsx(hw,{})]})]})}),{Component:bw,useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}=Ey(sw,{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"}},yw),jw=My({useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}),Sw=zy({useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}),kw=bw,ww=st(()=>{const t=ye(h=>r.jsxs("td",{children:["Item $",h]})),a=ye(null),s=ye(h=>r.jsxs("td",{colSpan:1e3,children:["Group ",h]})),i=ye(null),c=ye(null),u=ye({}),d=ye(Gf),f=ye(Gl),x=(h,y=null)=>pn(xe(u,we(v=>v[h]),Et()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Nt(Cy,ww);Ff();const Bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ig,floor:Yo,max:qs,min:$d,round:$g}=Math;function Ug(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Ew(t){return{...Cw,items:t}}function Ro(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Nw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Tw=st(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:f,scrollTo:x,scrollTop:h,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:C,propsReady:E},{customScrollParent:w,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:I},L])=>{const H=ye(0),k=ye(0),O=ye(Bg),z=ye({height:0,width:0}),_=ye({height:0,width:0}),$=nt(),q=nt(),K=ye(0),Q=ye(null),U=ye({column:0,row:0}),M=nt(),B=nt(),F=ye(!1),te=ye(0),V=ye(!0),D=ye(!1),W=ye(!1);ct(xe(C,We(te),Ie(([ne,ge])=>ge!==0)),()=>{Fe(V,!1)}),ct(xe(Wt(C,V,_,z,te,D),Ie(([ne,ge,Le,Ee,,Me])=>ne&&!ge&&Le.height!==0&&Ee.height!==0&&!Me)),([,,,,ne])=>{Fe(D,!0),Uf(1,()=>{Fe($,ne)}),sr(xe(h),()=>{Fe(a,[0,0]),Fe(V,!0)})}),Ae(xe(B,Ie(ne=>ne!=null&&ne.scrollTop>0),xr(0)),k),ct(xe(C,We(B),Ie(([,ne])=>ne!=null)),([,ne])=>{ne&&(Fe(z,ne.viewport),Fe(_,ne.item),Fe(U,ne.gap),ne.scrollTop>0&&(Fe(F,!0),sr(xe(h,Wa(1)),ge=>{Fe(F,!1)}),Fe(x,{top:ne.scrollTop})))}),Ae(xe(z,we(({height:ne})=>ne)),v),Ae(xe(Wt(Be(z,Ro),Be(_,Ro),Be(U,(ne,ge)=>ne!==void 0&&ne.column===ge.column&&ne.row===ge.row),Be(h)),we(([ne,ge,Le,Ee])=>({gap:Le,item:ge,scrollTop:Ee,viewport:ne}))),M),Ae(xe(Wt(Be(H),i,Be(U,Nw),Be(_,Ro),Be(z,Ro),Be(Q),Be(k),Be(F),Be(V),Be(te)),Ie(([,,,,,,,ne])=>!ne),we(([ne,[ge,Le],Ee,Me,Pe,ie,fe,,he,be])=>{const{column:je,row:Ge}=Ee,{height:ut,width:gt}=Me,{width:Ht}=Pe;if(fe===0&&(ne===0||Ht===0))return Bg;if(gt===0){const it=Hf(be,ne),bt=it+Math.max(fe-1,0);return Ew(Ug(it,bt,ie))}const Tt=Dy(Ht,gt,je);let qe,zt;he?ge===0&&Le===0&&fe>0?(qe=0,zt=fe-1):(qe=Tt*Yo((ge+Ge)/(ut+Ge)),zt=Tt*Ig((Le+Ge)/(ut+Ge))-1,zt=$d(ne-1,qs(zt,Tt-1)),qe=$d(zt,qs(0,qe))):(qe=0,zt=-1);const kt=Ug(qe,zt,ie),{bottom:vt,top:Zt}=Hg(Pe,Ee,Me,kt),ve=Ig(ne/Tt),rt=ve*ut+(ve-1)*Ge-vt;return{bottom:vt,itemHeight:ut,items:kt,itemWidth:gt,offsetBottom:rt,offsetTop:Zt,top:Zt}})),O),Ae(xe(Q,Ie(ne=>ne!==null),we(ne=>ne.length)),H),Ae(xe(Wt(z,_,O,U),Ie(([ne,ge,{items:Le}])=>Le.length>0&&ge.height!==0&&ne.height!==0),we(([ne,ge,{items:Le},Ee])=>{const{bottom:Me,top:Pe}=Hg(ne,Ee,ge,Le);return[Pe,Me]}),Et(ei)),a);const X=ye(!1);Ae(xe(h,We(X),we(([ne,ge])=>ge||ne!==0)),X);const ee=In(xe(Wt(O,H),Ie(([{items:ne}])=>ne.length>0),We(X),Ie(([[ne,ge],Le])=>{const Ee=ne.items[ne.items.length-1].index===ge-1;return(Le||ne.bottom>0&&ne.itemHeight>0&&ne.offsetBottom===0&&ne.items.length===ge)&&Ee}),we(([[,ne]])=>ne-1),Et())),de=In(xe(Be(O),Ie(({items:ne})=>ne.length>0&&ne[0].index===0),xr(0),Et())),le=In(xe(Be(O),We(F),Ie(([{items:ne},ge])=>ne.length>0&&!ge),we(([{items:ne}])=>({endIndex:ne[ne.length-1].index,startIndex:ne[0].index})),Et(fy),Ur(0)));Ae(le,S.scrollSeekRangeChanged),Ae(xe($,We(z,_,H,U),we(([ne,ge,Le,Ee,Me])=>{const Pe=gy(ne),{align:ie,behavior:fe,offset:he}=Pe;let be=Pe.index;be==="LAST"&&(be=Ee-1),be=qs(0,be,$d(Ee-1,be));let je=vf(ge,Me,Le,be);return ie==="end"?je=$g(je-ge.height+Le.height):ie==="center"&&(je=$g(je-ge.height/2+Le.height/2)),he!==void 0&&he!==0&&(je+=he),{behavior:fe,top:je}})),x);const ce=pn(xe(O,we(ne=>ne.offsetBottom+ne.bottom)),0);return Ae(xe(I,we(ne=>({height:ne.visibleHeight,width:ne.visibleWidth}))),z),{customScrollParent:w,data:Q,deviation:K,footerHeight:c,gap:U,headerHeight:u,increaseViewportBy:t,initialItemCount:k,itemDimensions:_,overscan:s,restoreStateFrom:B,scrollBy:d,scrollContainerState:f,scrollHeight:q,scrollTo:x,scrollToIndex:$,scrollTop:h,smoothScrollTargetReached:y,totalCount:H,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:I,...S,gridState:O,horizontalDirection:W,initialTopMostItemIndex:te,totalListHeight:ce,...b,endReached:ee,propsReady:E,rangeChanged:le,startReached:de,stateChanged:M,stateRestoreInProgress:F,...L}},Nt(Pf,yn,ci,ky,Sa,Vf,ja));function Dy(t,a,s){return qs(1,Yo((t+s)/(Yo(a)+s)))}function Hg(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=vf(t,a,s,i[0].index);return{bottom:vf(t,a,s,i[i.length-1].index)+c,top:u}}function vf(t,a,s,i){const c=Dy(t.width,s.width,a.column),u=Yo(i/c),d=u*s.height+qs(0,u-1)*a.row;return d>0?d+a.row:d}const Rw=st(()=>{const t=ye(v=>`Item ${v}`),a=ye({}),s=ye(null),i=ye("virtuoso-grid-item"),c=ye("virtuoso-grid-list"),u=ye(Gf),d=ye("div"),f=ye(Gl),x=(v,b=null)=>pn(xe(a,we(S=>S[v]),Et()),b),h=ye(!1),y=ye(!1);return Ae(Be(y),h),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:h,reportReadyState:y,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Aw=st(([t,a])=>({...t,...a}),Nt(Tw,Rw)),Lw=Re.memo(function(){const t=At("gridState"),a=At("listClassName"),s=At("itemClassName"),i=At("itemContent"),c=At("computeItemKey"),u=At("isSeeking"),d=er("scrollHeight"),f=At("ItemComponent"),x=At("ListComponent"),h=At("ScrollSeekPlaceholder"),y=At("context"),v=er("itemDimensions"),b=er("gap"),S=At("log"),C=At("stateRestoreInProgress"),E=er("reportReadyState"),w=Ka(Re.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:I,width:L}=A.getBoundingClientRect();v({height:I,width:L})}b({column:Pg("column-gap",getComputedStyle(N).columnGap,S),row:Pg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return Ry(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),C?null:r.jsx(x,{className:a,ref:w,...fn(x,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?r.jsx(h,{...fn(h,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(f,{...fn(f,y),className:s,"data-index":N.index,key:T},i(N.index,N.data,y))})})}),Mw=Re.memo(function(){const t=At("HeaderComponent"),a=er("headerHeight"),s=At("headerFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),zw=Re.memo(function(){const t=At("FooterComponent"),a=er("footerHeight"),s=At("headerFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Dw=({children:t})=>{const a=Re.useContext(Ty),s=er("itemDimensions"),i=er("viewportDimensions"),c=Ka(Re.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Re.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:cc(!1),children:t})},_w=({children:t})=>{const a=Re.useContext(Ty),s=er("windowViewportRect"),i=er("itemDimensions"),c=At("customScrollParent"),u=sy(s,c,!1);return Re.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:cc(!1),children:t})},Ow=Re.memo(function({...t}){const a=At("useWindowScroll"),s=At("customScrollParent"),i=s||a?Iw:Bw,c=s||a?_w:Dw,u=At("context");return r.jsx(i,{...t,...fn(i,u),children:r.jsxs(c,{children:[r.jsx(Mw,{}),r.jsx(Lw,{}),r.jsx(zw,{})]})})}),{useEmitter:_y,useEmitterValue:At,usePublisher:er}=Ey(Aw,{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"}},Ow),Bw=My({useEmitter:_y,useEmitterValue:At,usePublisher:er}),Iw=zy({useEmitter:_y,useEmitterValue:At,usePublisher:er});function Pg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Xt.WARN),a==="normal"?0:parseInt(a??"0",10)}const $w={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Oy={source:"Own",installed:"Installed"};function Uw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function Hw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Vg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=$w[t],[d,f]=m.useState(()=>Uw(u)),x=m.useCallback(()=>{f(b=>{const S=!b;return Hw(u,S),S})},[u]),h=Oy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Vw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:h}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(Pw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Pw({origin:t,updateCount:a}){const[s,i]=m.useState(!1),c=Oy[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Vw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function qf(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Fw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return m.useEffect(()=>{function x(h){var b;if(h.key!=="/")return;const y=h.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(h.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":f?!0:void 0,"aria-describedby":f?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),f&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function Gw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Ww({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function qw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(qv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Yw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ui(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",f=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!f.startsWith("v")?`v${f}`:f,h=i==="sm"?10:12,y=i==="sm"?1:2,v=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Yw(c,f,u),C=t.title??S,E={display:"inline-flex",alignItems:"center",padding:`${y}px ${v}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:h,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(E.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:C,style:E,children:x})}function Kw({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ui,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Gw,{target:t.symlinkTarget??null}),r.jsx(Ww,{skill:t}),r.jsx(qw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Ys=m.memo(Kw);function Xw({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((f,x)=>f.skill.localeCompare(x.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:d.map(f=>{const x=!!s&&s.plugin===f.plugin&&s.skill===f.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Ys,{skill:f,isSelected:x,onSelect:()=>i(f),onContextMenu:c,dirty:u==null?void 0:u.has(`${f.plugin}/${f.skill}`)})},`${f.plugin}/${f.skill}`)})})]})}function Qw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Ud({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const f=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,h]=m.useState(()=>Qw(i,s)),y=d?!1:x,v=m.useCallback(()=>{h(C=>{const E=!C;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(E))}catch{}return E})},[i]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick: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:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:f}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(C=>r.jsx("div",{"data-vskill-plugin-skill":C.pluginNamespace??C.skill,children:c(C)},`${C.pluginNamespace??C.skill}`))})]})}function Fo({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const x=m.useRef(null),h=m.useRef(null),y=m.useRef(null);if(m.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var C;(C=h.current)==null||C.focus()}),()=>{var C,E;(E=(C=y.current)==null?void 0:C.focus)==null||E.call(C),y.current=null}},[t]),m.useEffect(()=>{if(!t)return;function C(E){if(E.key==="Escape"){E.preventDefault(),f();return}if(E.key==="Tab"&&x.current){const w=x.current.querySelectorAll("button:not([disabled])");if(w.length===0)return;const N=w[0],T=w[w.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[t,f]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:C=>{C.target===C.currentTarget&&f()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:h,type:"button","data-testid":"confirm-dialog-cancel",onClick:f,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function Zw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Hd(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Jw({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,x]=m.useState(null),[h,y]=m.useState(!1),v=m.useRef(null);m.useEffect(()=>{if(!i)return;function C(E){v.current&&!v.current.contains(E.target)&&c(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[i]);async function b(C){d(C),x(null);try{const E=await fetch(`/api/plugins/${encodeURIComponent(t)}/${C}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),w=await E.json().catch(()=>({}));if(!E.ok||!w.ok){const N=w.error??`${C} failed (${E.status})`;x(N),C==="uninstall"&&Hd(`Failed to uninstall ${t}: ${N}`,"error");return}if(C==="uninstall"){const N=w.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Hd(N,"success")}Bn("skills"),ny(),s==null||s(),c(!1)}catch(E){const w=E instanceof Error?E.message:String(E);x(w),C==="uninstall"&&Hd(`Failed to uninstall ${t}: ${w}`,"error")}finally{d(null)}}function S(){y(!0)}return r.jsxs("div",{ref:v,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:C=>{C.stopPropagation(),c(E=>!E)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-tertiary)",C.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Pd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Pd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Pd,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:f})]}),r.jsx(Fo,{open:h,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{y(!1),c(!1)},onConfirm:()=>{y(!1),b("uninstall")}})]})}function Pd({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const eC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function tC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=m.useState(s),[x,h]=m.useState(i??""),[y,v]=m.useState(!1),[b,S]=m.useState(null),[C,E]=m.useState(null),w=eC.test(d),N=y||!w,T=m.useCallback(async A=>{if(A.preventDefault(),!N){v(!0),S(null),E(null);try{const I=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:x.trim()});c({pluginDir:I.pluginDir,manifestPath:I.manifestPath})}catch(I){if(I instanceof Ga){S(I.message);const L=I.details;L&&typeof L.stderr=="string"&&E(L.stderr)}else S(I instanceof Error?I.message:String(I));v(!1)}}},[N,t,d,x,c]);return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"vskill-convert-dialog-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:A=>{A.target===A.currentTarget&&!y&&u()},children:r.jsxs("form",{onSubmit:T,style:{background:"var(--bg-primary, #fff)",color:"var(--text-primary, #111)",borderRadius:8,padding:20,width:"min(540px, 92vw)",boxShadow:"0 12px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-sans)"},children:[r.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",r.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),r.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),r.jsx("input",{type:"text",value:d,onChange:A=>f(A.target.value),disabled:y,autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontSize:13,fontFamily:"var(--font-mono)",boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),!w&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),r.jsx("input",{type:"text",value:x,onChange:A=>h(A.target.value),disabled:y,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&r.jsxs("div",{role:"alert",style:{marginTop:12,padding:8,fontSize:12,background:"var(--color-error-bg, #fee)",color:"var(--color-error, #c00)",borderRadius:4},children:[r.jsx("div",{style:{fontWeight:500},children:b}),C&&r.jsx("pre",{style:{marginTop:6,padding:6,fontSize:11,fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",background:"rgba(0,0,0,0.04)",borderRadius:3,maxHeight:160,overflow:"auto"},children:C})]}),r.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{type:"button",onClick:u,disabled:y,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:y?"not-allowed":"pointer"},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:N,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",opacity:N?.5:1},children:y?"Converting…":"Convert"})]})]})})}function Fg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const f=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",h=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${f}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:h?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[h&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:f,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(nC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return h?r.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}):r.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 nC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function rC(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function aC(t){const a=t.key.split("+").map(f=>f.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const f of a.slice(0,-1)){const x=f.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function lC(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function sC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function yf(t,a={}){const{enabled:s=!0,target:i}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(aC),m.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(x){const h=x,y=lC(h.target);for(const v of c.current){if(!sC(h,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(h);return}}}return d.addEventListener("keydown",f),()=>{d.removeEventListener("keydown",f)}},[s,i])}function By(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function iC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function oC({projectRoot:t}){const{status:a,loading:s}=By();if(s||!a||a.status==="github"||iC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const cC=200;function uC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function dC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const d of t){const f=d.scopeV2??(d.scope==="installed"?"available-project":d.scope==="global"?"available-personal":"authoring-project");f==="available-project"?s.availableProject.push(d):f==="available-personal"?s.availablePersonal.push(d):f==="available-plugin"?s.availablePlugin.push(d):f==="authoring-plugin"?s.authoringPlugin.push(d):s.authoringProject.push(d)}function i(d){const f=d.filter(y=>qf(y,a)),x={};for(const y of f){const v=y.pluginName??y.plugin;(x[v]||(x[v]=[])).push(y)}const h=Object.entries(x).sort((y,v)=>y[0].localeCompare(v[0]));return{total:d.length,filtered:f.length,byPlugin:h}}const c=i(s.authoringProject),u=c.byPlugin.filter(([,d])=>d.length>=2).map(([d,f])=>({groupKey:d,skills:f,anchorSkillDir:f[0].dir}));return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:c,authoringPlugin:i(s.authoringPlugin),authoringCandidatePlugins:u}}function fC(t,a){const s=[],i=[],c=[];for(const d of t){const f=uC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var y;const f=d.filter(v=>qf(v,a)),x={};for(const v of f)(x[y=v.plugin]||(x[y]=[])).push(v);const h=Object.entries(x).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:f.length,byPlugin:h}}return{own:u(s),installed:u(i),global:u(c)}}function pC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var h;const d=u.filter(y=>qf(y,a)),f={};for(const y of d)(f[h=y.plugin]||(f[h]=[])).push(y);const x=Object.entries(f).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function mC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:f,activeAgentId:x,outdatedByScope:h,topSlot:y,revealSkillId:v,onRevealComplete:b,dirtySkillIds:S,onSkillsChanged:C}){const[E,w]=m.useState(null),N=!!x||t.some(ce=>ce.scope!==void 0&&ce.scope!==null),T=x??"claude-cli",[A,I]=m.useState(""),L=m.useDeferredValue(A),H=m.useMemo(()=>fC(t,L),[t,L]),k=m.useMemo(()=>dC(t,L),[t,L]),O=T==="claude-code",{plugins:z}=pk(),_=O?{plugins:z??[]}:void 0,$=m.useMemo(()=>{const ce=new Map;for(const ne of(_==null?void 0:_.plugins)??[]){const ge=ce.get(ne.name);ce.set(ne.name,!!ge||!!ne.enabled)}return ce},[_==null?void 0:_.plugins]),[q,K]=m.useState(()=>bf(`vskill-sidebar-${T}-group-available-collapsed`)),[Q,U]=m.useState(()=>bf(`vskill-sidebar-${T}-group-authoring-collapsed`)),M=m.useCallback(ce=>{K(ce);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-available-collapsed`,String(ce))}catch{}},[T]),B=m.useCallback(ce=>{U(ce);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-authoring-collapsed`,String(ce))}catch{}},[T]),{own:F,installed:te}=m.useMemo(()=>pC(t,L),[t,L]),D=H.own.filtered+H.installed.filtered+H.global.filtered>=cC,W=m.useMemo(()=>{const ce=ne=>{const ge=[];for(const[,Le]of ne){const Ee=[...Le].sort((Me,Pe)=>Me.skill.localeCompare(Pe.skill));ge.push(...Ee)}return ge};return N?[...ce(H.own.byPlugin),...ce(H.installed.byPlugin),...ce(H.global.byPlugin)]:[...ce(F.byPlugin),...ce(te.byPlugin)]},[N,H.own.byPlugin,H.installed.byPlugin,H.global.byPlugin,F.byPlugin,te.byPlugin]),X=m.useMemo(()=>a?W.findIndex(ce=>ce.plugin===a.plugin&&ce.skill===a.skill):-1,[W,a]),ee=m.useCallback(ce=>{if(W.length===0)return;const ne=X<0?ce>0?0:W.length-1:Math.min(Math.max(X+ce,0),W.length-1);s(W[ne])},[W,X,s]),de=m.useMemo(()=>{if(!v)return null;const[ce,ne]=v.split("/");if(!ce||!ne)return null;const ge=t.find(Me=>Me.plugin===ce&&Me.skill===ne);if(!ge)return{plugin:ce,skill:ne,bucket:null,pluginName:null};const Le=ge.source==="plugin"?"plugin":"project",Ee=Le==="plugin"?ge.pluginName??ce:null;return{plugin:ce,skill:ne,bucket:Le,pluginName:Ee}},[v,t]),le=m.useRef(null);return m.useEffect(()=>{if(!v){le.current=null;return}if(le.current===v)return;const ce=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),ne=document.querySelector(`[data-skill-id="${ce}"]`);ne&&(le.current=v,ne.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),yf([{key:"j",handler:()=>ee(1)},{key:"k",handler:()=>ee(-1)},{key:"Enter",handler:()=>{X>=0&&s(W[X])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(Fw,{value:A,onChange:I}),i&&r.jsx(jC,{}),!i&&c&&r.jsx(SC,{error:c,onRetry:u}),!i&&!c&&N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Fg,{name:se.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:q,onToggle:M,count:k.availableProject.total+k.availablePersonal.total+k.availablePlugin.total}),!q&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:se.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${T}-available-project-collapsed`,count:k.availableProject.total,filteredCount:A?k.availableProject.filtered:null,updateCount:(h==null?void 0:h.installed)??(f==null?void 0:f.installed),headerRightSlot:O?r.jsx(oC,{projectRoot:T}):null,children:k.availableProject.filtered===0?r.jsx(Wg,{queryActive:!!A,agentId:T}):r.jsx($s,{items:k.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),r.jsx(Is,{label:se.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${T}-available-personal-collapsed`,count:k.availablePersonal.total,filteredCount:A?k.availablePersonal.filtered:null,updateCount:h==null?void 0:h.global,children:k.availablePersonal.filtered===0?r.jsx(xC,{queryActive:!!A,agentId:T}):r.jsx($s,{items:k.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),O&&r.jsxs(Is,{label:se.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-available-plugin-collapsed`,count:k.availablePlugin.total,filteredCount:A?k.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),k.availablePlugin.filtered===0?r.jsx(gC,{queryActive:!!A,hasInstalled:k.availablePlugin.total>0}):k.availablePlugin.byPlugin.map(([ce,ne])=>r.jsx(Ud,{pluginName:ce,skills:ne,persistKey:`vskill-plugin-available-${ce}-collapsed`,headerActionSlot:O?r.jsx(Jw,{pluginName:ce,enabled:$.get(ce)??!0}):void 0,renderSkill:ge=>r.jsx(Ys,{skill:ge,isSelected:(a==null?void 0:a.plugin)===ge.plugin&&(a==null?void 0:a.skill)===ge.skill,onSelect:()=>s(ge),onContextMenu:d,dirty:S==null?void 0:S.has(`${ge.plugin}/${ge.skill}`)})},`available-${ce}`))]})]}),r.jsx(bC,{}),r.jsx(Fg,{name:se.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:de?!1:Q,onToggle:B,count:k.authoringProject.total+k.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!Q||de)&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:se.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${T}-authoring-project-collapsed`,count:k.authoringProject.total,filteredCount:A?k.authoringProject.filtered:null,updateCount:(h==null?void 0:h.own)??(f==null?void 0:f.source),forceOpen:(de==null?void 0:de.bucket)==="project",children:k.authoringProject.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsxs(r.Fragment,{children:[k.authoringCandidatePlugins.map(ce=>r.jsx(Ud,{pluginName:ce.groupKey,skills:ce.skills,persistKey:`vskill-candidate-plugin-${ce.groupKey}-collapsed`,headerActionSlot:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w({candidateLabel:ce.groupKey,initialName:ce.groupKey,anchorSkillDir:ce.anchorSkillDir})},title:"Write .claude-plugin/plugin.json into this folder so Claude Code recognizes it as a plugin",style:{fontSize:10,fontWeight:500,padding:"2px 8px",borderRadius:10,border:"1px solid var(--border-subtle, rgba(128,128,128,0.3))",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Not a plugin yet · Convert →"}),renderSkill:ne=>r.jsx(Ys,{skill:ne,isSelected:(a==null?void 0:a.plugin)===ne.plugin&&(a==null?void 0:a.skill)===ne.skill,onSelect:()=>s(ne),onContextMenu:d,dirty:S==null?void 0:S.has(`${ne.plugin}/${ne.skill}`)})},`candidate-${ce.groupKey}`)),r.jsx($s,{items:k.authoringProject.byPlugin.filter(([ce,ne])=>!(ne.length>=2&&k.authoringCandidatePlugins.some(ge=>ge.groupKey===ce))),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})]})}),O&&r.jsx(Is,{label:se.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-authoring-plugin-collapsed`,count:k.authoringPlugin.total,filteredCount:A?k.authoringPlugin.filtered:null,forceOpen:(de==null?void 0:de.bucket)==="plugin",children:k.authoringPlugin.filtered===0?r.jsx(vC,{queryActive:!!A,hasSources:k.authoringPlugin.total>0,candidates:k.authoringCandidatePlugins,onPromote:ce=>w({candidateLabel:ce.groupKey,initialName:ce.groupKey,anchorSkillDir:ce.anchorSkillDir})}):k.authoringPlugin.byPlugin.map(([ce,ne])=>r.jsx(Ud,{pluginName:ce,skills:ne,persistKey:`vskill-plugin-authoring-${ce}-collapsed`,forceOpen:(de==null?void 0:de.bucket)==="plugin"&&de.pluginName===ce,renderSkill:ge=>r.jsx(Ys,{skill:ge,isSelected:(a==null?void 0:a.plugin)===ge.plugin&&(a==null?void 0:a.skill)===ge.skill,onSelect:()=>s(ge),onContextMenu:d,dirty:S==null?void 0:S.has(`${ge.plugin}/${ge.skill}`)})},`authoring-${ce}`))})]})]}),!i&&!c&&!N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Vg,{origin:"source",count:F.total,filteredCount:A?F.filtered:null,updateCount:f==null?void 0:f.source,children:F.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsx($s,{items:F.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),r.jsx(yC,{}),r.jsx(Vg,{origin:"installed",count:te.total,filteredCount:A?te.filtered:null,updateCount:f==null?void 0:f.installed,children:te.filtered===0?r.jsx(Wg,{queryActive:!!A}):r.jsx($s,{items:te.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})})]}),E&&r.jsx(tC,{anchorSkillDir:E.anchorSkillDir,candidateLabel:E.candidateLabel,initialName:E.initialName,onCancel:()=>w(null),onConverted:()=>{w(null),C==null||C()}})]})}function bf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Is({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[x,h]=m.useState(()=>bf(a)),y=d?!1:x,v=m.useCallback(()=>{h(S=>{const C=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(C))}catch{}return C})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:y?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!y&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function hC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function $s({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=hC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(kw,{overscan:4,totalCount:d.length,itemContent:f=>{const x=d[f];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const h=x.skill,y=!!a&&a.plugin===h.plugin&&a.skill===h.skill;return r.jsx(Ys,{skill:h,isSelected:y,onSelect:()=>s(h),onContextMenu:i,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>r.jsx(Xw,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Gg({queryActive:t}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx($l,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Wg({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install <skill>"})," to add one."]})})}function xC({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install --global <skill>"})," to add one."]})})}function gC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx($l,{children:"Browse marketplaces…"})," above to add one."]})})}function vC({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsxs(r.Fragment,{children:[r.jsx(yr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx($l,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",r.jsx($l,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&r.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>r.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(c),title:`Promote ${c.groupKey}/ to a Claude Code plugin`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"6px 8px",fontSize:12,background:"transparent",border:"1px dashed var(--border-subtle, rgba(128,128,128,0.35))",borderRadius:4,color:"var(--text-primary)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)"},children:[r.jsxs("span",{children:[c.groupKey,"/ ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),r.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function yr({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function $l({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function yC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function bC(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function jC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(rC,{},t))})}function SC({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:kC(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function kC(t){const a=t.split(`
65
+ }`})]})}function hg(){typeof window>"u"||(window.location.hash="#/")}function P2({onHome:t}){const[a,s]=m.useState(!1),[i,c]=m.useState(!1),u=f=>{f.metaKey||f.ctrlKey||f.shiftKey||f.button!==0||(f.preventDefault(),hg(),t==null||t())},d=f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),hg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:i?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const xg=m.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function V2({toast:t,onDismiss:a}){const[s,i]=m.useState(!0),c=m.useRef(null);m.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function F2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(xg,{politeness:"polite",message:s}),r.jsx(xg,{politeness:"assertive",message:i}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(V2,{toast:c,onDismiss:a})},c.id))})]})}const Zv=m.createContext(null);function ac(){const t=m.useContext(Zv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function G2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=m.useState([]),[u,d]=m.useState(""),[f,x]=m.useState(""),h=m.useRef(new Map),y=m.useCallback(w=>{const N=h.current.get(w);N&&(clearTimeout(N),h.current.delete(w)),c(T=>T.filter(A=>A.id!==w))},[]),v=m.useCallback((w,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(w)},N);h.current.set(w,T)},[y]),b=m.useCallback(w=>{const N=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(A=>[...A,T]),T.severity==="error"?x(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=m.useCallback(()=>{for(const w of h.current.values())clearTimeout(w);h.current.clear(),c([])},[]);m.useEffect(()=>{function w(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),I=A[A.length-1],L=h.current.get(I.id);return L&&(clearTimeout(L),h.current.delete(I.id)),T.filter(H=>H.id!==I.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]),m.useEffect(()=>()=>{for(const w of h.current.values())clearTimeout(w);h.current.clear()},[]);const C=i.slice(0,a),E=m.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Zv.Provider,{value:E,children:[t,r.jsx(F2,{toasts:C,onDismiss:y,liveMessage:u,liveAssertiveMessage:f})]})}function W2(){const{data:t,loading:a}=qa("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const q2=m.lazy(()=>Vl(()=>import("./UpdateDropdown-DTP2sv27.js"),__vite__mapDeps([0,1])));function Y2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:f,activeAgent:x}=cr(),{toast:h}=ac(),{data:y}=W2(),v=(y==null?void 0:y.degraded)===!0,b=m.useMemo(()=>{if(!f||f.size===0)return;const H=new Map;for(const[k,O]of f)O.diffSummary&&H.set(k,O.diffSummary);return H.size>0?H:void 0},[f]),[S,C]=m.useState(!1),E=m.useRef(null),w=m.useCallback(()=>C(!1),[]),N=v?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),A=t===0?"No updates available":`${t} updates available, open summary`,I=v?`${A} — platform crawler degraded`:A,L=v?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:E,type:"button","data-testid":"update-bell","aria-label":I,"aria-haspopup":"dialog","aria-expanded":S,title:L,onClick:()=>C(H=>!H),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||v?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:T})]}),S&&r.jsx(m.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(q2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:H=>{const k=H.localSkill??H.name.split("/").pop()??"",O=H.localPlugin??"";if(u)u(O,k);else{const _=H.name.split("/"),$=_.length>=2?_[_.length-2]:_[0];c({plugin:$,skill:k,origin:"installed"})}if(!(d??[]).some(_=>_.skill===k&&(O===""||_.plugin===O))){const _=H.installLocations??[];if(_.length>0){const $=x?_.filter(K=>K.agent===x):[],q=x?_.filter(K=>K.agent!==x):_;if($.length>0&&q.length>0){const K=q.length>=2?`Also installed under ${q.length} other locations.`:`Also installed under ${q[0].agentLabel}.`;h({severity:"info",message:K})}else{const K=_[0].agentLabel;h({severity:"info",message:`Skill installed under ${K} — switch to ${K} to view details.`})}}}w()},onViewAll:()=>{window.location.hash="#/updates",w()},onClose:w,anchorRef:E})})]})}function gg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function K2({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(P2,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&d&&r.jsxs(r.Fragment,{children:[r.jsx(vg,{segment:"origin",onClick:()=>gg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(yg,{}),r.jsx(vg,{segment:"plugin",onClick:()=>gg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(yg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]})]}),r.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"var(--border-default)"}}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(U2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(Y2,{})})]})]})]})}function vg({segment:t,onClick:a,style:s,children:i}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:i})}function yg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const lc="vskill-theme";function Jv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function X2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function Q2(t){try{const a=t.getItem(lc);return Jv(a)}catch{return"auto"}}function Z2(t,a){try{t.setItem(lc,a)}catch{}}function J2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function ek(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ey=m.createContext(null);function tk({storage:t,matchMedia:a,target:s,children:i}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[f,x]=m.useState(()=>c?Q2(c):"auto"),[h,y]=m.useState(()=>ek(u)),v=m.useMemo(()=>X2(f,h),[f,h]);m.useEffect(()=>{d&&J2(d,f,v)},[d,f,v]),m.useEffect(()=>{if(!u)return;const C=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",E),()=>C.removeEventListener("change",E);const w=C;return w.addListener(E),()=>w.removeListener(E)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const C=E=>{E.key===lc&&x(Jv(E.newValue))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[]),m.useEffect(()=>{if(!u||!d)return;let C;try{C=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(C.matches);const w=T=>E(T.matches);if(typeof C.addEventListener=="function")return C.addEventListener("change",w),()=>C.removeEventListener("change",w);const N=C;return N.addListener(w),()=>N.removeListener(w)},[u,d]);const b=m.useCallback(C=>{x(C),c&&Z2(c,C)},[c]),S=m.useMemo(()=>({mode:f,resolvedTheme:v,setTheme:b}),[f,v,b]);return r.jsx(ey.Provider,{value:S,children:i})}function ty(){const t=m.useContext(ey);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const bg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function nk(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of bg){const c=a.get(i);c&&s.push(c)}for(const i of t)bg.includes(i.id)||s.push(i);return s}function rk(t){const[a,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function ak({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=nk(t),c=rk(640),[u,d]=m.useState(!1),f=m.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.filter(h=>h.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":se.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:se.statusBar.providerSummary(x,i.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:i.map(h=>r.jsx(jg,{p:h,onClick:f},h.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(jg,{p:x,onClick:f,compact:!0},x.id))})}function jg({p:t,onClick:a,compact:s}){const i=t.available?se.statusBar.unlocked(t.label):t.kind==="cli-install"?se.statusBar.lockedCli(t.label):se.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(df,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function lk(){try{return typeof localStorage>"u"?null:localStorage.getItem(lc)}catch{return null}}function sk({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:f,resolvedTheme:x,setTheme:h}=ty(),v=lk()==="auto",b=ik(f,x,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(Sg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(ok,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Sg,{}),r.jsx(ak,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>h(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${f} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(ck,{mode:f}),r.jsx("span",{style:{textTransform:"capitalize"},children:f})]})]})}function ik(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function ok({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function Sg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function ck({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ff=new Set;function ny(){for(const t of ff)t()}const uk=5,dk=1e3,fk=6e4;function pk(){const[t,a]=m.useState(void 0),[s,i]=m.useState(!1),[c,u]=m.useState(!0),d=m.useRef(0),f=m.useRef(null),x=m.useRef(null),h=m.useRef(!0),y=m.useRef(0),[v,b]=m.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},C=m.useCallback(()=>{f.current&&(f.current.abort(),f.current=null)},[]),E=m.useCallback(async()=>{if(!h.current||document.visibilityState==="hidden")return;C();const N=new AbortController;f.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!h.current)return;const A=await T.json();if(!h.current)return;d.current=0,a(A.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{h.current&&b(I=>I+1)},fk)}catch(T){if(!h.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>uk){i(!0);return}const A=dk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{h.current&&b(I=>I+1)},A)}},[C]);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,S(),C()}),[C]),m.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),m.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),C()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[C]);const w=m.useCallback(()=>{d.current=0,i(!1),S(),y.current+=1,b(N=>N+1)},[]);return m.useEffect(()=>(ff.add(w),()=>{ff.delete(w)}),[w]),{plugins:t,paused:s,loading:c,retry:w}}const sc=0,ba=1,Fl=2,ry=4;function kg(t){return()=>t}function mk(t){t()}function ay(t,a){return s=>t(a(s))}function wg(t,a){return()=>t(a)}function hk(t,a){return s=>t(a,s)}function _f(t){return t!==void 0}function xk(...t){return()=>{t.map(mk)}}function Gl(){}function ic(t,a){return a(t),t}function gk(t,a){return a(t)}function Nt(...t){return t}function ct(t,a){return t(ba,a)}function Fe(t,a){t(sc,a)}function Of(t){t(Fl)}function Lt(t){return t(ry)}function Ae(t,a){return ct(t,hk(a,sc))}function sr(t,a){const s=t(ba,i=>{s(),a(i)});return s}function Cg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function ly(t,a){return t===a}function Et(t=ly){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Ie(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>ay(a,t)}function xr(t){return a=>()=>{a(t)}}function xe(t,...a){const s=vk(...a);return((i,c)=>{switch(i){case Fl:Of(t);return;case ba:return ct(t,s(c))}})}function gr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function Ur(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function We(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;ct(u,x=>{const h=s;s|=f,a[d]=x,h!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const f=()=>{u([d].concat(a))};s===c?f():i=f}}function vk(...t){return a=>t.reduceRight(gk,a)}function yk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case ba:return u?s===u?void 0:(i(),s=u,a=ct(t,u),a):(i(),Gl);case Fl:i(),s=null;return}}}function ye(t){let a=t;const s=nt();return((i,c)=>{switch(i){case sc:a=c;break;case ba:{c(a);break}case ry:return a}return s(i,c)})}function pn(t,a){return ic(ye(a),s=>Ae(t,s))}function nt(){const t=[];return((a,s)=>{switch(a){case sc:t.slice().forEach(i=>{i(s)});return;case Fl:t.splice(0,t.length);return;case ba:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function In(t){return ic(nt(),a=>Ae(t,a))}function st(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:bk(),singleton:s}}const bk=()=>Symbol();function jk(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const f=i(c.map(x=>s(x)));return d&&a.set(u,f),f};return s(t)}function Wt(...t){const a=nt(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const f=2**d;ct(u,x=>{s[d]=x,i|=f,i===c&&Fe(a,s)})}),function(u,d){switch(u){case Fl:{Of(a);return}case ba:return i===c&&d(s),ct(a,d)}}}function Be(t,a=ly){return xe(t,Et(a))}function pf(...t){return function(a,s){switch(a){case Fl:return;case ba:return xk(...t.map(i=>ct(i,s)))}}}const Xt={DEBUG:0,INFO:1,WARN:2,ERROR:3},Sk={[Xt.DEBUG]:"debug",[Xt.ERROR]:"error",[Xt.INFO]:"log",[Xt.WARN]:"warn"},kk=()=>typeof globalThis>"u"?window:globalThis,ja=st(()=>{const t=ye(Xt.ERROR);return{log:ye((a,s,i=Xt.INFO)=>{const c=kk().VIRTUOSO_LOG_LEVEL??Lt(t);i>=c&&console[Sk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Bf(t,a,s).callbackRef}function Bf(t,a,s){const i=Re.useRef(null);let c=d=>{};const u=Re.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const f=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?f():requestAnimationFrame(f)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function wk(t,a,s,i,c,u,d,f,x){const h=Re.useCallback(y=>{const v=Ck(y.children,a,f?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let C;S&&(C=b.ownerDocument.defaultView);const E=d?f?d.scrollLeft:d.scrollTop:S?f?C.scrollX||C.document.documentElement.scrollLeft:C.scrollY||C.document.documentElement.scrollTop:f?b.scrollLeft:b.scrollTop,w=d?f?d.scrollWidth:d.scrollHeight:S?f?C.document.documentElement.scrollWidth:C.document.documentElement.scrollHeight:f?b.scrollWidth:b.scrollHeight,N=d?f?d.offsetWidth:d.offsetHeight:S?f?C.innerWidth:C.innerHeight:f?b.offsetWidth:b.offsetHeight;i({scrollHeight:w,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(f?Eg("column-gap",getComputedStyle(y).columnGap,c):Eg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,i,f]);return Bf(h,s,x)}function Ck(t,a,s,i){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const f=t.item(d);if(f.dataset.index===void 0)continue;const x=parseInt(f.dataset.index),h=parseFloat(f.dataset.knownSize),y=a(f,s);if(y===0&&i("Zero-sized element, this should not happen",{child:f},Xt.ERROR),y===h)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==x-1?u.push({endIndex:x,size:y,startIndex:x}):u[u.length-1].endIndex++}return u}function Eg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Xt.WARN),a==="normal"?0:parseInt(a??"0",10)}function sy(t,a,s){const i=Re.useRef(null),c=Re.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const h=x.getBoundingClientRect(),y=h.width;let v,b;if(a){const S=a.getBoundingClientRect(),C=h.top-S.top;b=S.height-Math.max(0,C),v=C+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,h.top),v=h.top+S.scrollY}i.current={listHeight:h.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Bf(c,!0,s),f=Re.useCallback(()=>{c(d.current)},[c,d]);return Re.useEffect(()=>{var h;if(a){a.addEventListener("scroll",f);const y=new ResizeObserver(()=>{requestAnimationFrame(f)});return y.observe(a),()=>{a.removeEventListener("scroll",f),y.unobserve(a)}}const x=(h=d.current)==null?void 0:h.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",f),x==null||x.addEventListener("resize",f),()=>{x==null||x.removeEventListener("scroll",f),x==null||x.removeEventListener("resize",f)}},[f,a,d]),u}const yn=st(()=>{const t=nt(),a=nt(),s=ye(0),i=nt(),c=ye(0),u=nt(),d=nt(),f=ye(0),x=ye(0),h=ye(0),y=ye(0),v=nt(),b=nt(),S=ye(!1),C=ye(!1),E=ye(!1);return Ae(xe(t,we(({scrollTop:w})=>w)),a),Ae(xe(t,we(({scrollHeight:w})=>w)),d),Ae(a,c),{deviation:s,fixedFooterHeight:h,fixedHeaderHeight:x,footerHeight:y,headerHeight:f,horizontalDirection:C,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Zs={lvl:0};function iy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:f,value:x}=a(t[d]);u.push({end:f-1,start:i,value:c}),i=f,c=x}return u.push({end:1/0,start:i,value:c}),u}function xt(t){return t===Zs}function Js(t,a){if(!xt(t))return a===t.k?t.v:a<t.k?Js(t.l,a):Js(t.r,a)}function or(t,a,s="k"){if(xt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function On(t,a,s){return xt(t)?uy(a,s,1):a===t.k?Kt(t,{k:a,v:s}):a<t.k?Ng(Kt(t,{l:On(t.l,a,s)})):Ng(Kt(t,{r:On(t.r,a,s)}))}function Ol(){return Zs}function Bl(t,a,s){if(xt(t))return[];const i=or(t,a)[0];return Ek(hf(t,i,s))}function mf(t,a){if(xt(t))return Zs;const{k:s,l:i,r:c}=t;if(a===s){if(xt(i))return c;if(xt(c))return i;const[u,d]=cy(i);return Po(Kt(t,{k:u,l:oy(i),v:d}))}return a<s?Po(Kt(t,{l:mf(i,a)})):Po(Kt(t,{r:mf(c,a)}))}function Fa(t){return xt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function hf(t,a,s){if(xt(t))return[];const{k:i,l:c,r:u,v:d}=t;let f=[];return i>a&&(f=f.concat(hf(c,a,s))),i>=a&&i<=s&&f.push({k:i,v:d}),i<=s&&(f=f.concat(hf(u,a,s))),f}function Po(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(_d(a))return dy(Kt(t,{lvl:s-1}));if(!xt(a)&&!xt(a.r))return Kt(a.r,{l:Kt(a,{r:a.r.l}),lvl:s,r:Kt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(_d(t))return xf(Kt(t,{lvl:s-1}));if(!xt(i)&&!xt(i.l)){const c=i.l,u=_d(c)?i.lvl-1:i.lvl;return Kt(c,{l:Kt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:xf(Kt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Kt(t,a){return uy(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function oy(t){return xt(t.r)?t.l:Po(Kt(t,{r:oy(t.r)}))}function _d(t){return xt(t)||t.lvl>t.r.lvl}function cy(t){return xt(t.r)?[t.k,t.v]:cy(t.r)}function uy(t,a,s,i=Zs,c=Zs){return{k:t,l:i,lvl:s,r:c,v:a}}function Ng(t){return xf(dy(t))}function dy(t){const{l:a}=t;return!xt(a)&&a.lvl===t.lvl?Kt(a,{r:Kt(t,{l:a.r})}):t}function xf(t){const{lvl:a,r:s}=t;return!xt(s)&&!xt(s.r)&&s.lvl===a&&s.r.lvl===a?Kt(s,{l:Kt(t,{r:s.l}),lvl:a+1}):t}function Ek(t){return iy(t,({k:a,v:s})=>({index:a,value:s}))}function fy(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function ei(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const If=st(()=>({recalcInProgress:ye(!1)}),[],{singleton:!0});function py(t,a,s){return t[qo(t,a,s)]}function qo(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],f=s(d,a);if(f===0)return u;if(f===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Nk(t,a,s,i){const c=qo(t,a,i),u=qo(t,s,i,c);return t.slice(c,u+1)}function va(t,a){return Math.round(t.getBoundingClientRect()[a])}function oc(t){return!xt(t.groupOffsetTree)}function $f({index:t},a){return a===t?0:a<t?-1:1}function Tk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Rk(t,a){let s=xt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),xt(t)){t=On(t,0,u);continue}const f=Bl(t,d-1,c+1);if(f.some(Ok(i)))continue;let x=!1,h=!1;for(const{end:y,start:v,value:b}of f)x?(c>=v||u===b)&&(t=mf(t,v)):(h=b!==u,x=!0),y>c&&c>=v&&b!==u&&(t=On(t,c+1,b));h&&(t=On(t,d,u))}return[t,s]}function Ak(t){return typeof t.groupIndex<"u"}function Lk({offset:t},a){return a===t?0:a<t?-1:1}function ti(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=py(a,t,$f),d=t-i,f=u*d+(d-1)*s+c;return f>0?f+s:f}function my(t,a){if(!oc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function hy(t,a,s){if(Ak(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=my(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function Mk(t,a,s,i=0){return i>0&&(a=Math.max(a,py(t,i,$f).offset)),iy(Nk(t,a,s,Lk),_k)}function zk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,Xt.DEBUG);const u=t.sizeTree;let d=u,f=0;if(s.length>0&&xt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((C,E)=>On(On(C,E,b),E+1,S),d)}else[d,f]=Rk(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:h,lastSize:y,offsetTree:v}=gf(t.offsetTree,f,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>On(b,S,ti(S,v,c)),Ol()),lastIndex:x,lastOffset:h,lastSize:y,offsetTree:v,sizeTree:d}}function Dk(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Tg(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function gf(t,a,s,i){let c=t,u=0,d=0,f=0,x=0;if(a!==0){x=qo(c,a-1,$f),f=c[x].offset;const h=or(s,a-1);u=h[0],d=h[1],c.length&&c[x].size===or(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:h,value:y}of Bl(s,a,1/0)){const v=h-u,b=v*d+f+v*i;c.push({index:h,offset:b,size:y}),u=h,f=b,d=y}return{lastIndex:u,lastOffset:f,lastSize:d,offsetTree:c}}function _k(t){return{index:t.index,value:t}}function Ok(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Bk={offsetHeight:"height",offsetWidth:"width"},br=st(([{log:t},{recalcInProgress:a}])=>{const s=nt(),i=nt(),c=pn(i,0),u=nt(),d=nt(),f=ye(0),x=ye([]),h=ye(void 0),y=ye(void 0),v=ye(void 0),b=ye(void 0),S=ye((k,O)=>va(k,Bk[O])),C=ye(void 0),E=ye(0),w=Tk(),N=pn(xe(s,We(x,t,E),gr(zk,w),Et()),w),T=pn(xe(x,Et(),gr((k,O)=>({current:O,prev:k.current}),{current:[],prev:[]}),we(({prev:k})=>k)),[]);Ae(xe(x,Ie(k=>k.length>0),We(N,E),we(([k,O,z])=>{const _=k.reduce(($,q,K)=>On($,q,ti(q,O.offsetTree,z)||K),Ol());return{...O,groupIndices:k,groupOffsetTree:_}})),N),Ae(xe(i,We(N),Ie(([k,{lastIndex:O}])=>k<O),we(([k,{lastIndex:O,lastSize:z}])=>[{endIndex:O,size:z,startIndex:k}])),s),Ae(h,y);const A=pn(xe(h,we(k=>k===void 0)),!0);Ae(xe(y,Ie(k=>k!==void 0&&xt(Lt(N).sizeTree)),we(k=>{const O=Lt(v),z=Lt(x).length>0;return O!==void 0&&O!==0?z?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:k,startIndex:1}]:[]:[{endIndex:0,size:k,startIndex:0}]})),s),Ae(xe(b,Ie(k=>k!==void 0&&k.length>0&&xt(Lt(N).sizeTree)),we(k=>{const O=[];let z=k[0],_=0;for(let $=1;$<k.length;$++){const q=k[$];q!==z&&(O.push({endIndex:$-1,size:z,startIndex:_}),z=q,_=$)}return O.push({endIndex:k.length-1,size:z,startIndex:_}),O})),s),Ae(xe(x,We(v,y),Ie(([,k,O])=>k!==void 0&&O!==void 0),we(([k,O,z])=>{const _=[];for(let $=0;$<k.length;$++){const q=k[$],K=k[$+1];_.push({startIndex:q,endIndex:q,size:O}),K!==void 0&&_.push({startIndex:q+1,endIndex:K-1,size:z})}return _})),s);const I=In(xe(s,We(N),gr(({sizes:k},[O,z])=>({changed:z!==k,sizes:z}),{changed:!1,sizes:w}),we(k=>k.changed)));ct(xe(f,gr((k,O)=>({diff:k.prev-O,prev:O}),{diff:0,prev:0}),we(k=>k.diff)),k=>{const{groupIndices:O}=Lt(N);if(k>0)Fe(a,!0),Fe(u,k+Tg(k,O));else if(k<0){const z=Lt(T);z.length>0&&(k-=Tg(-k,z)),Fe(d,k)}}),ct(xe(f,We(t)),([k,O])=>{k<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:f},Xt.ERROR)});const L=In(u);Ae(xe(u,We(N),we(([k,O])=>{const z=O.groupIndices.length>0,_=[],$=O.lastSize;if(z){const q=Js(O.sizeTree,0);let K=0,Q=0;for(;K<k;){const M=O.groupIndices[Q],B=O.groupIndices.length===Q+1?1/0:O.groupIndices[Q+1]-M-1;_.push({endIndex:M,size:q,startIndex:M}),_.push({endIndex:M+1+B-1,size:$,startIndex:M+1}),Q++,K+=B+1}const U=Fa(O.sizeTree);return K!==k&&U.shift(),U.reduce((M,{k:B,v:F})=>{let te=M.ranges;return M.prevSize!==0&&(te=[...M.ranges,{endIndex:B+k-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:B+k,prevSize:F,ranges:te}},{prevIndex:k,prevSize:0,ranges:_}).ranges}return Fa(O.sizeTree).reduce((q,{k:K,v:Q})=>({prevIndex:K+k,prevSize:Q,ranges:[...q.ranges,{endIndex:K+k-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:$,ranges:[]}).ranges})),s);const H=In(xe(d,We(N,E),we(([k,{offsetTree:O},z])=>{const _=-k;return ti(_,O,z)})));return Ae(xe(d,We(N,E),we(([k,O,z])=>{if(O.groupIndices.length>0){if(xt(O.sizeTree))return O;let $=Ol();const q=Lt(T);let K=0,Q=0,U=0;for(;K<-k;){U=q[Q];const M=q[Q+1]-U-1;Q++,K+=M+1}if($=Fa(O.sizeTree).reduce((M,{k:B,v:F})=>On(M,Math.max(0,B+k),F),$),K!==-k){const M=Js(O.sizeTree,U);$=On($,0,M);const B=or(O.sizeTree,-k+1)[1];$=On($,1,B)}return{...O,sizeTree:$,...gf(O.offsetTree,0,$,z)}}const _=Fa(O.sizeTree).reduce(($,{k:q,v:K})=>On($,Math.max(0,q+k),K),Ol());return{...O,sizeTree:_,...gf(O.offsetTree,0,_,z)}})),N),{beforeUnshiftWith:L,data:C,defaultItemSize:y,firstItemIndex:f,fixedItemSize:h,fixedGroupSize:v,gap:E,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:I,shiftWith:d,shiftWithOffset:H,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:A,unshiftWith:u}},Nt(ja,If),{singleton:!0});function Ik(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const xy=st(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=nt(),d=nt(),f=In(xe(u,we(Ik)));return Ae(xe(f,we(x=>x.totalCount)),s),Ae(xe(f,we(x=>x.groupIndices)),t),Ae(xe(Wt(c,a,i),Ie(([x,h])=>oc(h)),we(([x,h,y])=>or(h.groupOffsetTree,Math.max(x-y,0),"v")[0]),Et(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Nt(br,yn)),Sa=st(([{log:t}])=>{const a=ye(!1),s=In(xe(a,Ie(i=>i),Et()));return ct(a,i=>{i&&Lt(t)("props updated",{},Xt.DEBUG)}),{didMount:s,propsReady:a}},Nt(ja),{singleton:!0}),$k=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function gy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!$k)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const ii=st(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:f,scrollingInProgress:x,scrollTo:h,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=nt(),C=nt(),E=ye(0);let w=null,N=null,T=null;function A(){w!==null&&(w(),w=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Fe(x,!1)}return Ae(xe(S,We(s,v,i,E,f,d,b),We(t,u,c),we(([[I,L,H,k,O,z,_,$],q,K,Q])=>{const U=gy(I),{align:M,behavior:B,offset:F}=U,te=k-1,V=hy(U,L,te);let D=ti(V,L.offsetTree,q)+z;M==="end"?(D+=K+or(L.sizeTree,V)[1]-H+Q,V===te&&(D+=_)):M==="center"?D+=(K+or(L.sizeTree,V)[1]-H+Q)/2:D-=O,F!==void 0&&F!==0&&(D+=F);const W=X=>{A(),X?($("retrying to scroll to",{location:I},Xt.DEBUG),Fe(S,I)):(Fe(C,!0),$("list did not change, scroll successful",{},Xt.DEBUG))};if(A(),B==="smooth"){let X=!1;T=ct(a,ee=>{X=X||ee}),w=sr(y,()=>{W(X)})}else w=sr(xe(a,Uk(150)),W);return N=setTimeout(()=>{A()},1200),Fe(x,!0),$("scrolling from index to",{behavior:B,index:V,top:D},Xt.DEBUG),{behavior:B,top:D}})),h),{scrollTargetReached:C,scrollToIndex:S,topListHeight:E}},Nt(br,yn,ja),{singleton:!0});function Uk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Uf(t,a){t===0?a():requestAnimationFrame(()=>{Uf(t-1,a)})}function Hf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const oi=st(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const f=ye(!0),x=ye(0),h=ye(!0);return Ae(xe(d,We(x),Ie(([y,v])=>v!==0),xr(!1)),f),Ae(xe(d,We(x),Ie(([y,v])=>v!==0),xr(!1)),h),ct(xe(Wt(a,d),We(f,s,t,h),Ie(([[,y],v,{sizeTree:b},S,C])=>y&&(!xt(b)||_f(S))&&!v&&!C),We(x)),([,y])=>{sr(c,()=>{Fe(h,!0)}),Uf(4,()=>{sr(i,()=>{Fe(f,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:h,initialTopMostItemIndex:x,scrolledToInitialItem:f}},Nt(br,yn,ii,Sa),{singleton:!0});function vy(t,a){return Math.abs(t-a)<1.01}const ni="up",Ws="down",Hk="none",Pk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Vk=0,ci=st(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ye(!1),f=ye(!0),x=nt(),h=nt(),y=ye(4),v=ye(Vk),b=pn(xe(pf(xe(Be(c),Wa(1),xr(!0)),xe(Be(c),Wa(1),xr(!1),Cg(100))),Et()),!1),S=pn(xe(pf(xe(s,xr(!0)),xe(s,xr(!1),Cg(200))),Et()),!1);Ae(xe(Wt(Be(c),Be(v)),we(([T,A])=>T<=A),Et()),f),Ae(xe(f,Ur(50)),h);const C=In(xe(Wt(i,Be(u),Be(a),Be(t),Be(y)),gr((T,[{scrollHeight:A,scrollTop:I},L,H,k,O])=>{const z=I+L-A>-O,_={scrollHeight:A,scrollTop:I,viewportHeight:L};if(z){let q,K;return I>T.state.scrollTop?(q="SCROLLED_DOWN",K=T.state.scrollTop-I):(q="SIZE_DECREASED",K=T.state.scrollTop-I||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:K,state:_}}let $;return _.scrollHeight>T.state.scrollHeight?$="SIZE_INCREASED":L<T.state.viewportHeight?$="VIEWPORT_HEIGHT_DECREASING":I<T.state.scrollTop?$="SCROLLING_UPWARDS":$="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:$,state:_}},Pk),Et((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=pn(xe(i,gr((T,{scrollHeight:A,scrollTop:I,viewportHeight:L})=>{if(!vy(T.scrollHeight,A)){const H=A-(I+L)<1;return T.scrollTop!==I&&H?{changed:!0,jump:T.scrollTop-I,scrollHeight:A,scrollTop:I}:{changed:!0,jump:0,scrollHeight:A,scrollTop:I}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:I}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ie(T=>T.changed),we(T=>T.jump)),0);Ae(xe(C,we(T=>T.atBottom)),d),Ae(xe(d,Ur(50)),x);const w=ye(Ws);Ae(xe(i,we(({scrollTop:T})=>T),Et(),gr((T,A)=>Lt(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?ni:Ws,prevScrollTop:A},{direction:Ws,prevScrollTop:0}),we(T=>T.direction)),w),Ae(xe(i,Ur(50),xr(Hk)),w);const N=ye(0);return Ae(xe(b,Ie(T=>!T),xr(0)),N),Ae(xe(c,Ur(100),We(b),Ie(([T,A])=>A),gr(([T,A],[I])=>[A,I],[0,0]),we(([T,A])=>A-T)),N),{atBottomState:C,atBottomStateChange:x,atBottomThreshold:y,atTopStateChange:h,atTopThreshold:v,isAtBottom:d,isAtTop:f,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:w,scrollVelocity:N}},Nt(yn)),ri="top",ai="bottom",Rg="none";function Ag(t,a,s){return typeof t=="number"?s===ni&&a===ri||s===Ws&&a===ai?t:0:s===ni?a===ri?t.main:t.reverse:a===ai?t.main:t.reverse}function Lg(t,a){return typeof t=="number"?t:t[a]??0}const Pf=st(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=nt(),d=ye(0),f=ye(0),x=ye(0),h=pn(xe(Wt(Be(i),Be(c),Be(s),Be(u,ei),Be(x),Be(d),Be(a),Be(t),Be(f)),we(([y,v,b,[S,C],E,w,N,T,A])=>{const I=y-T,L=w+N,H=Math.max(b-I,0);let k=Rg;const O=Lg(A,ri),z=Lg(A,ai);return S-=T,S+=b+N,C+=b+N,C-=T,S>y+L-O&&(k=ni),C<y-H+v+z&&(k=Ws),k!==Rg?[Math.max(I-b-Ag(E,ri,k)-O,0),I-H-N+v+Ag(E,ai,k)+z]:null}),Ie(y=>y!==null),Et(ei)),[0,0]);return{increaseViewportBy:f,listBoundary:u,overscan:x,topListHeight:d,visibleRange:h}},Nt(yn),{singleton:!0});function Fk(t,a,s){if(oc(a)){const i=my(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Od={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Vo(t,a,s,i,c,u){const{lastIndex:d,lastOffset:f,lastSize:x}=c;let h=0,y=0;if(t.length>0){h=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=f+v*x+(v-1)*i,S=h,C=b-y;return{bottom:y,firstItemIndex:u,items:Mg(t,c,u),offsetBottom:C,offsetTop:h,top:S,topItems:Mg(a,c,u),topListHeight:a.reduce((E,w)=>w.size+E,0),totalCount:s}}function yy(t,a,s,i,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const f=t+d,x=Hf(a,f),h=Array.from({length:f}).map((y,v)=>({data:u[v+x],index:v+x,offset:0,size:0}));return Vo(h,[],f,c,s,i)}function Mg(t,a,s){if(t.length===0)return[];if(!oc(a))return t.map(h=>({...h,index:h.index+s,originalIndex:h.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let f,x=0;for(const h of t){(!f||f.end<h.index)&&(f=d.shift(),x=a.groupIndices.indexOf(f.start));let y;h.index===f.start?y={index:x,type:"group"}:y={groupIndex:x,index:h.index-(x+1)+s},u.push({...y,data:h.data,offset:h.offset,originalIndex:h.index,size:h.size})}return u}function zg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=st(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:f,visibleRange:x},{initialTopMostItemIndex:h,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:C}])=>{const E=ye([]),w=ye(0),N=nt(),T=ye(0);Ae(u.topItemsIndexes,E);const A=pn(xe(Wt(S,C,Be(x,ei),Be(c),Be(i),Be(h),y,Be(E),Be(a),Be(s),Be(T),t),Ie(([k,O,,z,,,,,,,,_])=>{const $=_!==void 0&&_.length!==z;return k&&!O&&!$}),we(([,,[k,O],z,_,$,q,K,Q,U,M,B])=>{var ge,Le;const F=_,{offsetTree:te,sizeTree:V}=F,D=Lt(w);if(z===0)return{...Od,totalCount:z};if(k===0&&O===0)return D===0?{...Od,totalCount:z}:yy(D,$,_,Q,U,B||[]);if(xt(V))return D>0?null:Vo(Fk(Hf($,z),F,B),[],z,U,F,Q);const W=[];if(K.length>0){const Ee=K[0],Me=K[K.length-1];let Pe=0;for(const ie of Bl(V,Ee,Me)){const fe=ie.value,he=Math.max(ie.start,Ee),be=Math.min(ie.end,Me);for(let je=he;je<=be;je++)W.push({data:B==null?void 0:B[je],index:je,offset:Pe,size:fe}),Pe+=fe}}if(!q)return Vo([],W,z,U,F,Q);const X=K.length>0?K[K.length-1]+1:0,ee=Mk(te,k,O,X);if(ee.length===0)return null;const de=z-1,le=ic([],Ee=>{for(const Me of ee){const Pe=Me.value;let ie=Pe.offset,fe=Me.start;const he=Pe.size;if(Pe.offset<k){fe+=Math.floor((k-Pe.offset+U)/(he+U));const je=fe-Me.start;ie+=je*he+je*U}fe<X&&(ie+=(X-fe)*he,fe=X);const be=Math.min(Me.end,de);for(let je=fe;je<=be&&!(ie>=O);je++)Ee.push({data:B==null?void 0:B[je],index:je,offset:ie,size:he}),ie+=he+U}}),ce=zg(M,ri),ne=zg(M,ai);if(le.length>0&&(ce>0||ne>0)){const Ee=le[0],Me=le[le.length-1];if(ce>0&&Ee.index>X){const Pe=Math.min(ce,Ee.index-X),ie=[];let fe=Ee.offset;for(let he=Ee.index-1;he>=Ee.index-Pe;he--){const be=((ge=Bl(V,he,he)[0])==null?void 0:ge.value)??Ee.size;fe-=be+U,ie.unshift({data:B==null?void 0:B[he],index:he,offset:fe,size:be})}le.unshift(...ie)}if(ne>0&&Me.index<de){const Pe=Math.min(ne,de-Me.index);let ie=Me.offset+Me.size+U;for(let fe=Me.index+1;fe<=Me.index+Pe;fe++){const he=((Le=Bl(V,fe,fe)[0])==null?void 0:Le.value)??Me.size;le.push({data:B==null?void 0:B[fe],index:fe,offset:ie,size:he}),ie+=he+U}}}return Vo(le,W,z,U,F,Q)}),Ie(k=>k!==null),Et()),Od);Ae(xe(t,Ie(_f),we(k=>k==null?void 0:k.length)),c),Ae(xe(A,we(k=>k.topListHeight)),v),Ae(v,f),Ae(xe(A,we(k=>[k.top,k.bottom])),d),Ae(xe(A,we(k=>k.items)),N);const I=In(xe(A,Ie(({items:k})=>k.length>0),We(c,t),Ie(([{items:k},O])=>k[k.length-1].originalIndex===O-1),we(([,k,O])=>[k-1,O]),Et(ei),we(([k])=>k))),L=In(xe(A,Ur(200),Ie(({items:k,topItems:O})=>k.length>0&&k[0].originalIndex===O.length),we(({items:k})=>k[0].index),Et())),H=In(xe(A,Ie(({items:k})=>k.length>0),we(({items:k})=>{let O=0,z=k.length-1;for(;k[O].type==="group"&&O<z;)O++;for(;k[z].type==="group"&&z>O;)z--;return{endIndex:k[z].index,startIndex:k[O].index}}),Et(fy)));return{endReached:I,initialItemCount:w,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:H,startReached:L,topItemsIndexes:E,...b}},Nt(br,xy,Pf,oi,ii,ci,Sa,If),{singleton:!0}),by=st(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=nt(),d=pn(xe(Wt(s,t,i,a,c),we(([f,x,h,y,v])=>f+x+h+y+v.offsetBottom+v.bottom)),0);return Ae(Be(d),u),{totalListHeight:d,totalListHeightChanged:u}},Nt(yn,Xa),{singleton:!0}),Gk=st(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ye(!1),i=pn(xe(Wt(s,t,a),Ie(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),Ur(0),Et()),0);return{alignToBottom:s,paddingTopAddition:i}},Nt(yn,by),{singleton:!0}),jy=st(()=>({context:ye(null)})),Wk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,Sy=st(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:f,viewportHeight:x},{scrollToIndex:h}])=>{const y=nt();return Ae(xe(y,We(a,x,s,u,c,i,f),We(t),we(([[v,b,S,C,E,w,N,T],A])=>{const{calculateViewLocation:I=Wk,done:L,...H}=v,k=hy(v,b,C-1),O=ti(k,b.offsetTree,A)+E+w,z=O+or(b.sizeTree,k)[1],_=T+w,$=T+S-N,q=I({itemBottom:z,itemTop:O,locationParams:H,viewportBottom:$,viewportTop:_});return q!==null?L&&sr(xe(d,Ie(K=>!K),Wa(Lt(d)?1:2)),L):L==null||L(),q}),Ie(v=>v!==null)),h),{scrollIntoView:y}},Nt(br,yn,ii,Xa,ja),{singleton:!0});function Dg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const qk=(t,a)=>typeof t=="function"?Dg(t(a)):a&&Dg(t),Yk=st(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:f},{didMount:x,propsReady:h},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const C=ye(!1),E=nt();let w=null;function N(L){Fe(d,{align:"end",behavior:L,index:"LAST"})}ct(xe(Wt(xe(Be(a),Wa(1)),x),We(Be(C),u,f,v),we(([[L,H],k,O,z,_])=>{let $=H&&z,q="auto";return $&&(q=qk(k,O||_),$=$&&q!==!1),{followOutputBehavior:q,shouldFollow:$,totalCount:L}}),Ie(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:H})=>{w!==null&&(w(),w=null),Lt(s)!==void 0?requestAnimationFrame(()=>{Lt(y)("following output to ",{totalCount:H},Xt.DEBUG),N(L)}):w=sr(t,()=>{Lt(y)("following output to ",{totalCount:H},Xt.DEBUG),N(L),w=null})});function T(L){const H=sr(c,k=>{L&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(Lt(y)("scrolling to bottom due to increased size",{},Xt.DEBUG),N("auto"))});setTimeout(H,100)}ct(xe(Wt(Be(C),a,h),Ie(([L,,H])=>L!==!1&&H),gr(({value:L},[,H])=>({refreshed:L===H,value:H}),{refreshed:!1,value:0}),Ie(({refreshed:L})=>L),We(C,a)),([,L])=>{Lt(f)&&T(L!==!1)}),ct(E,()=>{T(Lt(C)!==!1)}),ct(Wt(Be(C),c),([L,H])=>{L!==!1&&!H.atBottom&&H.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ye(null),I=nt();return Ae(pf(xe(Be(i),we(L=>(L==null?void 0:L.length)??0)),xe(Be(a))),I),ct(xe(Wt(xe(I,Wa(1)),x),We(Be(A),f,v,b),we(([[L,H],k,O,z,_])=>H&&O&&(k==null?void 0:k({context:_,totalCount:L,scrollingInProgress:z}))),Ie(L=>!!L),Ur(0)),L=>{w!==null&&(w(),w=null),Lt(s)!==void 0?requestAnimationFrame(()=>{Lt(y)("scrolling into view",{}),Fe(S,L)}):w=sr(t,()=>{Lt(y)("scrolling into view",{}),Fe(S,L),w=null})}),{autoscrollToBottom:E,followOutput:C,scrollIntoViewOnChange:A}},Nt(br,ci,ii,oi,Sa,ja,yn,jy,Sy)),Kk=st(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:f}])=>(Ae(xe(f,We(u),Ie(([,x])=>x!==0),We(c,i,a,s,t),we(([[,x],h,y,v,b,S=[]])=>yy(x,h,y,v,b,S))),d),{}),Nt(br,oi,Xa,Sa),{singleton:!0}),Xk=st(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ye(0);return ct(xe(t,We(i),Ie(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(xe(s,Wa(1),Ie(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:i}},Nt(Sa,yn,Xa),{singleton:!0}),ky=st(([{scrollVelocity:t}])=>{const a=ye(!1),s=nt(),i=ye(!1);return Ae(xe(t,We(i,a,s),Ie(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,f])=>{const{enter:x,exit:h}=u;if(d){if(h(c,f))return!1}else if(x(c,f))return!0;return d}),Et()),a),ct(xe(Wt(a,t,s),We(i)),([[c,u,d],f])=>{c&&f!==!1&&f!==void 0&&f.change&&f.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Nt(ci),{singleton:!0}),Vf=st(([{scrollContainerState:t,scrollTo:a}])=>{const s=nt(),i=nt(),c=nt(),u=ye(!1),d=ye(void 0);return Ae(xe(Wt(s,i),we(([{scrollTop:f,viewportHeight:x},{offsetTop:h,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,f-h),viewportHeight:x}))),t),Ae(xe(a,We(i),we(([f,{offsetTop:x}])=>({...f,top:f.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Nt(yn)),Qk=st(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:f,windowViewportRect:x}])=>{const h=nt(),y=ye(void 0),v=ye(null),b=ye(null);return Ae(f,v),Ae(x,b),ct(xe(h,We(a,i,d,v,b,s)),([S,C,E,w,N,T,A])=>{const I=Dk(C.sizeTree);w&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:I,scrollTop:E})}),Ae(xe(y,Ie(_f),we(Zk)),c),Ae(xe(u,We(y),Ie(([,S])=>S!==void 0),Et(),we(([,S])=>S.ranges)),t),{getState:h,restoreStateFrom:y}},Nt(br,yn,oi,Sa,Vf));function Zk(t){return{align:"start",index:0,offset:t.scrollTop}}const Jk=st(([{topItemsIndexes:t}])=>{const a=ye(0);return Ae(xe(a,Ie(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Nt(Xa));function wy(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const ew=wy(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),tw=st(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:f},{listState:x},{beforeUnshiftWith:h,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:C}])=>{const E=In(xe(x,We(d),gr(([,N,T,A],[{bottom:I,items:L,offsetBottom:H,totalCount:k},O])=>{const z=I+H;let _=0;return T===k&&N.length>0&&L.length>0&&(L[0].originalIndex===0&&N[0].originalIndex===0||(_=z-A,_!==0&&(_+=O))),[_,L,k,z]},[0,[],0,0]),Ie(([N])=>N!==0),We(i,f,s,c,S,C),Ie(([,N,T,A,,,I])=>!I&&!A&&N!==0&&T===ni),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Xt.DEBUG),N))));function w(N){N>0?(Fe(a,{behavior:"auto",top:-N}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-N}))}return ct(xe(E,We(t,u)),([N,T,A])=>{A&&ew()?Fe(t,T-N):w(-N)}),ct(xe(Wt(pn(u,!1),t,C),Ie(([N,T,A])=>!N&&!A&&T!==0),we(([N,T])=>T),Ur(1)),w),Ae(xe(v,we(N=>({top:-N}))),a),ct(xe(h,We(b,y),we(([N,{groupIndices:T,lastSize:A,sizeTree:I},L])=>{function H($){return $*(A+L)}if(T.length===0)return H(N);let k=0;const O=Js(I,0);let z=0,_=0;for(;z<N;){z++,k+=O;let $=T.length===_+1?1/0:T[_+1]-T[_]-1;z+$>N&&(k-=O,$=N-z+1),z+=$,k+=H($),_++}return k})),N=>{Fe(t,N),requestAnimationFrame(()=>{Fe(a,{top:N}),requestAnimationFrame(()=>{Fe(t,0),Fe(C,!1)})})}),{deviation:t}},Nt(yn,ci,Xa,br,ja,If)),nw=st(([t,a,s,i,c,u,d,f,x,h,y])=>({...t,...a,...s,...i,...c,...u,...d,...f,...x,...h,...y}),Nt(Pf,Kk,Sa,ky,by,Xk,Gk,Vf,Sy,ja,jy)),Cy=st(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:f,itemSize:x,sizeRanges:h,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:C,initialTopMostItemIndex:E,scrolledToInitialItem:w},N,T,A,I,{scrollToIndex:L},H,{topItemCount:k},{groupCounts:O},z])=>{const{listState:_,minOverscanItemCount:$,topItemsIndexes:q,rangeChanged:K,...Q}=I;return Ae(K,z.scrollSeekRangeChanged),Ae(xe(z.windowViewportRect,we(U=>U.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:f,initialItemFinalLocationReached:C,initialTopMostItemIndex:E,scrolledToInitialItem:w,sizeRanges:h,topItemCount:k,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:x,listState:_,minOverscanItemCount:$,scrollToIndex:L,statefulTotalCount:v,trackItemSizes:S,rangeChanged:K,...Q,...z,...N,sizes:y,...T}},Nt(br,oi,yn,Qk,Yk,Xa,ii,tw,Jk,xy,nw));function rw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const To=typeof document<"u"?Re.useLayoutEffect:Re.useEffect;function Ey(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),f=Re.createContext({});function x(w,N){w.propsReady!==void 0&&Fe(w.propsReady,!1);for(const T of i){const A=w[a.required[T]];Fe(A,N[T])}for(const T of c)if(T in N){const A=w[a.optional[T]];Fe(A,N[T])}w.propsReady!==void 0&&Fe(w.propsReady,!0)}function h(w){return u.reduce((N,T)=>(N[T]=A=>{const I=w[a.methods[T]];Fe(I,A)},N),{})}function y(w){return d.reduce((N,T)=>(N[T]=yk(w[a.events[T]]),N),{})}const v=Re.forwardRef(function(w,N){const{children:T,...A}=w,[I]=Re.useState(()=>ic(jk(t),k=>{x(k,A)})),[L]=Re.useState(wg(y,I));To(()=>{for(const k of d)k in A&&ct(L[k],A[k]);return()=>{Object.values(L).map(Of)}},[A,L,I]),To(()=>{x(I,A)}),Re.useImperativeHandle(N,kg(h(I)));const H=s;return r.jsx(f.Provider,{value:I,children:s!==void 0?r.jsx(H,{...rw([...i,...c,...d],A),children:T}):T})}),b=w=>{const N=Re.useContext(f);return Re.useCallback(T=>{Fe(N[w],T)},[N,w])},S=w=>{const N=Re.useContext(f)[w],T=Re.useCallback(A=>ct(N,A),[N]);return Re.useSyncExternalStore(T,()=>Lt(N),()=>Lt(N))},C=w=>{const N=Re.useContext(f)[w],[T,A]=Re.useState(wg(Lt,N));return To(()=>ct(N,I=>{I!==T&&A(kg(I))}),[N,T]),T},E=parseInt(Re.version)>=18?S:C;return{Component:v,useEmitter:(w,N)=>{const T=Re.useContext(f)[w];To(()=>ct(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const Ny=Re.createContext(void 0),Ty=Re.createContext(void 0),Bd="-webkit-sticky",_g="sticky",Ff=wy(()=>{if(typeof document>"u")return _g;const t=document.createElement("div");return t.style.position=Bd,t.style.position===Bd?Bd:_g}),Ry=typeof document<"u"?Re.useLayoutEffect:Re.useEffect;function Id(t){return"self"in t}function aw(t){return"body"in t}function Ay(t,a,s,i=Gl,c,u){const d=Re.useRef(null),f=Re.useRef(null),x=Re.useRef(null),h=Re.useCallback(b=>{let S,C,E;const w=b.target;if(aw(w)||Id(w)){const T=Id(w)?w:w.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,C=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?w.scrollLeft:w.scrollTop,S=u===!0?w.scrollWidth:w.scrollHeight,C=u===!0?w.offsetWidth:w.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:C})};b.suppressFlushSync===!0?N():vS.flushSync(N),f.current!==null&&(E===f.current||E<=0||E===S-C)&&(f.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Re.useEffect(()=>{const b=c||d.current;return i(c||d.current),h({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",h,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",h)}},[d,h,s,i,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 C=b.behavior==="smooth";let E,w,N;Id(S)?(w=Math.max(va(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(w=S[u===!0?"scrollWidth":"scrollHeight"],E=va(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=w-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),vy(E,w)||b.top===N){t({scrollHeight:w,scrollTop:N,viewportHeight:E}),C&&a(!0);return}C?(f.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.current=null,f.current=null,a(!0)},1e3)):f.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 Gf(t){return t}const lw=st(()=>{const t=ye(f=>`Item ${f}`),a=ye(f=>`Group ${f}`),s=ye({}),i=ye(Gf),c=ye("div"),u=ye(Gl),d=(f,x=null)=>pn(xe(s,we(h=>h[f]),Et()),x);return{components:s,computeItemKey:i,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),sw=st(([t,a])=>({...t,...a}),Nt(Cy,lw)),iw=({height:t})=>r.jsx("div",{style:{height:t}}),ow={overflowAnchor:"none",position:Ff(),zIndex:1},Ly={overflowAnchor:"none"},cw={...Ly,display:"inline-block",height:"100%"},Og=Re.memo(function({showTopList:t=!1}){const a=Ue("listState"),s=Jn("sizeRanges"),i=Ue("useWindowScroll"),c=Ue("customScrollParent"),u=Jn("windowScrollContainerState"),d=Jn("scrollContainerState"),f=c||i?u:d,x=Ue("itemContent"),h=Ue("context"),y=Ue("groupContent"),v=Ue("trackItemSizes"),b=Ue("itemSize"),S=Ue("log"),C=Jn("gap"),E=Ue("horizontalDirection"),{callbackRef:w}=wk(s,b,v,t?Gl:f,S,C,c,E,Ue("skipAnimationFrameInResizeObserver")),[N,T]=Re.useState(0);Wf("deviation",Q=>{N!==Q&&T(Q)});const A=Ue("EmptyPlaceholder"),I=Ue("ScrollSeekPlaceholder")??iw,L=Ue("ListComponent"),H=Ue("ItemComponent"),k=Ue("GroupComponent"),O=Ue("computeItemKey"),z=Ue("isSeeking"),_=Ue("groupIndices").length>0,$=Ue("alignToBottom"),q=Ue("initialItemFinalLocationReached"),K=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:$?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:$?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...fn(A,h)}):r.jsx(L,{...fn(L,h),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:K,children:(t?a.topItems:a.items).map(Q=>{const U=Q.originalIndex,M=O(U+a.firstItemIndex,Q.data,h);return z?m.createElement(I,{...fn(I,h),height:Q.size,index:Q.index,key:M,type:Q.type||"item",...Q.type==="group"?{}:{groupIndex:Q.groupIndex}}):Q.type==="group"?m.createElement(k,{...fn(k,h),"data-index":U,"data-item-index":Q.index,"data-known-size":Q.size,key:M,style:ow},y(Q.index,h)):m.createElement(H,{...fn(H,h),...pw(H,Q.data),"data-index":U,"data-item-group-index":Q.groupIndex,"data-item-index":Q.index,"data-known-size":Q.size,key:M,style:E?cw:Ly},_?x(Q.index,Q.groupIndex,Q.data,h):x(Q.index,Q.data,h))})})}),uw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},dw={outline:"none",overflowX:"auto",position:"relative"},cc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),fw={position:Ff(),top:0,width:"100%",zIndex:1};function fn(t,a){if(typeof t!="string")return{context:a}}function pw(t,a){return{item:typeof t=="string"?void 0:a}}const mw=Re.memo(function(){const t=Ue("HeaderComponent"),a=Jn("headerHeight"),s=Ue("HeaderFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),hw=Re.memo(function(){const t=Ue("FooterComponent"),a=Jn("footerHeight"),s=Ue("HeaderFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,Ue("skipAnimationFrameInResizeObserver")),c=Ue("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null});function My({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Re.memo(function({children:i,style:c,context:u,...d}){const f=s("scrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:C}=Ay(f,h,x,y,void 0,v);return t("scrollTo",C),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?dw:uw,...c},tabIndex:0,...d,...fn(x,u),children:i})})}function zy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Re.memo(function({children:i,style:c,context:u,...d}){const f=s("windowScrollContainerState"),x=a("ScrollerComponent"),h=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Re.useRef(null),C=a("scrollerRef"),{scrollByCallback:E,scrollerRef:w,scrollToCallback:N}=Ay(f,h,x,C,b);return Ry(()=>{var T;return w.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{w.current=null}},[w,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...fn(x,u),children:i})})}const xw=({children:t})=>{const a=Re.useContext(Ny),s=Jn("viewportHeight"),i=Jn("fixedItemHeight"),c=Ue("alignToBottom"),u=Ue("horizontalDirection"),d=Re.useMemo(()=>ay(s,x=>va(x,u?"width":"height")),[s,u]),f=Ka(d,!0,Ue("skipAnimationFrameInResizeObserver"));return Re.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:f,style:cc(c),children:t})},gw=({children:t})=>{const a=Re.useContext(Ny),s=Jn("windowViewportRect"),i=Jn("fixedItemHeight"),c=Ue("customScrollParent"),u=sy(s,c,Ue("skipAnimationFrameInResizeObserver")),d=Ue("alignToBottom");return Re.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:cc(d),children:t})},vw=({children:t})=>{const a=Ue("TopItemListComponent")??"div",s=Ue("headerHeight"),i={...fw,marginTop:`${s}px`},c=Ue("context");return r.jsx(a,{style:i,...fn(a,c),children:t})},yw=Re.memo(function(t){const a=Ue("useWindowScroll"),s=Ue("topItemsIndexes").length>0,i=Ue("customScrollParent"),c=Ue("context");return r.jsxs(i||a?Sw:jw,{...t,context:c,children:[s&&r.jsx(vw,{children:r.jsx(Og,{showTopList:!0})}),r.jsxs(i||a?gw:xw,{children:[r.jsx(mw,{}),r.jsx(Og,{}),r.jsx(hw,{})]})]})}),{Component:bw,useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}=Ey(sw,{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"}},yw),jw=My({useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}),Sw=zy({useEmitter:Wf,useEmitterValue:Ue,usePublisher:Jn}),kw=bw,ww=st(()=>{const t=ye(h=>r.jsxs("td",{children:["Item $",h]})),a=ye(null),s=ye(h=>r.jsxs("td",{colSpan:1e3,children:["Group ",h]})),i=ye(null),c=ye(null),u=ye({}),d=ye(Gf),f=ye(Gl),x=(h,y=null)=>pn(xe(u,we(v=>v[h]),Et()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Nt(Cy,ww);Ff();const Bg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cw={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Ig,floor:Yo,max:qs,min:$d,round:$g}=Math;function Ug(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Ew(t){return{...Cw,items:t}}function Ro(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Nw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Tw=st(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:f,scrollTo:x,scrollTop:h,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:C,propsReady:E},{customScrollParent:w,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:I},L])=>{const H=ye(0),k=ye(0),O=ye(Bg),z=ye({height:0,width:0}),_=ye({height:0,width:0}),$=nt(),q=nt(),K=ye(0),Q=ye(null),U=ye({column:0,row:0}),M=nt(),B=nt(),F=ye(!1),te=ye(0),V=ye(!0),D=ye(!1),W=ye(!1);ct(xe(C,We(te),Ie(([ne,ge])=>ge!==0)),()=>{Fe(V,!1)}),ct(xe(Wt(C,V,_,z,te,D),Ie(([ne,ge,Le,Ee,,Me])=>ne&&!ge&&Le.height!==0&&Ee.height!==0&&!Me)),([,,,,ne])=>{Fe(D,!0),Uf(1,()=>{Fe($,ne)}),sr(xe(h),()=>{Fe(a,[0,0]),Fe(V,!0)})}),Ae(xe(B,Ie(ne=>ne!=null&&ne.scrollTop>0),xr(0)),k),ct(xe(C,We(B),Ie(([,ne])=>ne!=null)),([,ne])=>{ne&&(Fe(z,ne.viewport),Fe(_,ne.item),Fe(U,ne.gap),ne.scrollTop>0&&(Fe(F,!0),sr(xe(h,Wa(1)),ge=>{Fe(F,!1)}),Fe(x,{top:ne.scrollTop})))}),Ae(xe(z,we(({height:ne})=>ne)),v),Ae(xe(Wt(Be(z,Ro),Be(_,Ro),Be(U,(ne,ge)=>ne!==void 0&&ne.column===ge.column&&ne.row===ge.row),Be(h)),we(([ne,ge,Le,Ee])=>({gap:Le,item:ge,scrollTop:Ee,viewport:ne}))),M),Ae(xe(Wt(Be(H),i,Be(U,Nw),Be(_,Ro),Be(z,Ro),Be(Q),Be(k),Be(F),Be(V),Be(te)),Ie(([,,,,,,,ne])=>!ne),we(([ne,[ge,Le],Ee,Me,Pe,ie,fe,,he,be])=>{const{column:je,row:Ge}=Ee,{height:ut,width:gt}=Me,{width:Ht}=Pe;if(fe===0&&(ne===0||Ht===0))return Bg;if(gt===0){const it=Hf(be,ne),bt=it+Math.max(fe-1,0);return Ew(Ug(it,bt,ie))}const Tt=Dy(Ht,gt,je);let qe,zt;he?ge===0&&Le===0&&fe>0?(qe=0,zt=fe-1):(qe=Tt*Yo((ge+Ge)/(ut+Ge)),zt=Tt*Ig((Le+Ge)/(ut+Ge))-1,zt=$d(ne-1,qs(zt,Tt-1)),qe=$d(zt,qs(0,qe))):(qe=0,zt=-1);const kt=Ug(qe,zt,ie),{bottom:vt,top:Zt}=Hg(Pe,Ee,Me,kt),ve=Ig(ne/Tt),rt=ve*ut+(ve-1)*Ge-vt;return{bottom:vt,itemHeight:ut,items:kt,itemWidth:gt,offsetBottom:rt,offsetTop:Zt,top:Zt}})),O),Ae(xe(Q,Ie(ne=>ne!==null),we(ne=>ne.length)),H),Ae(xe(Wt(z,_,O,U),Ie(([ne,ge,{items:Le}])=>Le.length>0&&ge.height!==0&&ne.height!==0),we(([ne,ge,{items:Le},Ee])=>{const{bottom:Me,top:Pe}=Hg(ne,Ee,ge,Le);return[Pe,Me]}),Et(ei)),a);const X=ye(!1);Ae(xe(h,We(X),we(([ne,ge])=>ge||ne!==0)),X);const ee=In(xe(Wt(O,H),Ie(([{items:ne}])=>ne.length>0),We(X),Ie(([[ne,ge],Le])=>{const Ee=ne.items[ne.items.length-1].index===ge-1;return(Le||ne.bottom>0&&ne.itemHeight>0&&ne.offsetBottom===0&&ne.items.length===ge)&&Ee}),we(([[,ne]])=>ne-1),Et())),de=In(xe(Be(O),Ie(({items:ne})=>ne.length>0&&ne[0].index===0),xr(0),Et())),le=In(xe(Be(O),We(F),Ie(([{items:ne},ge])=>ne.length>0&&!ge),we(([{items:ne}])=>({endIndex:ne[ne.length-1].index,startIndex:ne[0].index})),Et(fy),Ur(0)));Ae(le,S.scrollSeekRangeChanged),Ae(xe($,We(z,_,H,U),we(([ne,ge,Le,Ee,Me])=>{const Pe=gy(ne),{align:ie,behavior:fe,offset:he}=Pe;let be=Pe.index;be==="LAST"&&(be=Ee-1),be=qs(0,be,$d(Ee-1,be));let je=vf(ge,Me,Le,be);return ie==="end"?je=$g(je-ge.height+Le.height):ie==="center"&&(je=$g(je-ge.height/2+Le.height/2)),he!==void 0&&he!==0&&(je+=he),{behavior:fe,top:je}})),x);const ce=pn(xe(O,we(ne=>ne.offsetBottom+ne.bottom)),0);return Ae(xe(I,we(ne=>({height:ne.visibleHeight,width:ne.visibleWidth}))),z),{customScrollParent:w,data:Q,deviation:K,footerHeight:c,gap:U,headerHeight:u,increaseViewportBy:t,initialItemCount:k,itemDimensions:_,overscan:s,restoreStateFrom:B,scrollBy:d,scrollContainerState:f,scrollHeight:q,scrollTo:x,scrollToIndex:$,scrollTop:h,smoothScrollTargetReached:y,totalCount:H,useWindowScroll:N,viewportDimensions:z,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:I,...S,gridState:O,horizontalDirection:W,initialTopMostItemIndex:te,totalListHeight:ce,...b,endReached:ee,propsReady:E,rangeChanged:le,startReached:de,stateChanged:M,stateRestoreInProgress:F,...L}},Nt(Pf,yn,ci,ky,Sa,Vf,ja));function Dy(t,a,s){return qs(1,Yo((t+s)/(Yo(a)+s)))}function Hg(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=vf(t,a,s,i[0].index);return{bottom:vf(t,a,s,i[i.length-1].index)+c,top:u}}function vf(t,a,s,i){const c=Dy(t.width,s.width,a.column),u=Yo(i/c),d=u*s.height+qs(0,u-1)*a.row;return d>0?d+a.row:d}const Rw=st(()=>{const t=ye(v=>`Item ${v}`),a=ye({}),s=ye(null),i=ye("virtuoso-grid-item"),c=ye("virtuoso-grid-list"),u=ye(Gf),d=ye("div"),f=ye(Gl),x=(v,b=null)=>pn(xe(a,we(S=>S[v]),Et()),b),h=ye(!1),y=ye(!1);return Ae(Be(y),h),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:h,reportReadyState:y,ScrollerComponent:x("Scroller","div"),scrollerRef:f,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Aw=st(([t,a])=>({...t,...a}),Nt(Tw,Rw)),Lw=Re.memo(function(){const t=At("gridState"),a=At("listClassName"),s=At("itemClassName"),i=At("itemContent"),c=At("computeItemKey"),u=At("isSeeking"),d=er("scrollHeight"),f=At("ItemComponent"),x=At("ListComponent"),h=At("ScrollSeekPlaceholder"),y=At("context"),v=er("itemDimensions"),b=er("gap"),S=At("log"),C=At("stateRestoreInProgress"),E=er("reportReadyState"),w=Ka(Re.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:I,width:L}=A.getBoundingClientRect();v({height:I,width:L})}b({column:Pg("column-gap",getComputedStyle(N).columnGap,S),row:Pg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return Ry(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),C?null:r.jsx(x,{className:a,ref:w,...fn(x,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?r.jsx(h,{...fn(h,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):m.createElement(f,{...fn(f,y),className:s,"data-index":N.index,key:T},i(N.index,N.data,y))})})}),Mw=Re.memo(function(){const t=At("HeaderComponent"),a=er("headerHeight"),s=At("headerFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),zw=Re.memo(function(){const t=At("FooterComponent"),a=er("footerHeight"),s=At("headerFooterTag"),i=Ka(Re.useMemo(()=>u=>{a(va(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...fn(t,c)})}):null}),Dw=({children:t})=>{const a=Re.useContext(Ty),s=er("itemDimensions"),i=er("viewportDimensions"),c=Ka(Re.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Re.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:cc(!1),children:t})},_w=({children:t})=>{const a=Re.useContext(Ty),s=er("windowViewportRect"),i=er("itemDimensions"),c=At("customScrollParent"),u=sy(s,c,!1);return Re.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:cc(!1),children:t})},Ow=Re.memo(function({...t}){const a=At("useWindowScroll"),s=At("customScrollParent"),i=s||a?Iw:Bw,c=s||a?_w:Dw,u=At("context");return r.jsx(i,{...t,...fn(i,u),children:r.jsxs(c,{children:[r.jsx(Mw,{}),r.jsx(Lw,{}),r.jsx(zw,{})]})})}),{useEmitter:_y,useEmitterValue:At,usePublisher:er}=Ey(Aw,{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"}},Ow),Bw=My({useEmitter:_y,useEmitterValue:At,usePublisher:er}),Iw=zy({useEmitter:_y,useEmitterValue:At,usePublisher:er});function Pg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Xt.WARN),a==="normal"?0:parseInt(a??"0",10)}const $w={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Oy={source:"Own",installed:"Installed"};function Uw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function Hw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Vg({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=$w[t],[d,f]=m.useState(()=>Uw(u)),x=m.useCallback(()=>{f(b=>{const S=!b;return Hw(u,S),S})},[u]),h=Oy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:x,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(Vw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:h}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),i!=null&&i>0&&r.jsx(Pw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Pw({origin:t,updateCount:a}){const[s,i]=m.useState(!1),c=Oy[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>i(!0),onBlur:()=>i(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Vw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function qf(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Fw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:i,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),f=!!i&&t.trim()!==""&&!i.test(t);return m.useEffect(()=>{function x(h){var b;if(h.key!=="/")return;const y=h.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(h.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":f?!0:void 0,"aria-describedby":f?d:void 0,value:t,placeholder:s,onChange:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),f&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function Gw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Ww({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function qw({skillId:t,trackedForUpdates:a}){let s=null;try{s=m.useContext(qv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Yw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ui(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",f=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!f.startsWith("v")?`v${f}`:f,h=i==="sm"?10:12,y=i==="sm"?1:2,v=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Yw(c,f,u),C=t.title??S,E={display:"inline-flex",alignItems:"center",padding:`${y}px ${v}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:h,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(E.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":f,"data-version-source":c,title:C,style:E,children:x})}function Kw({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:u,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(ui,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(Gw,{target:t.symlinkTarget??null}),r.jsx(Ww,{skill:t}),r.jsx(qw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Ys=m.memo(Kw);function Xw({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((f,x)=>f.skill.localeCompare(x.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:d.map(f=>{const x=!!s&&s.plugin===f.plugin&&s.skill===f.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Ys,{skill:f,isSelected:x,onSelect:()=>i(f),onContextMenu:c,dirty:u==null?void 0:u.has(`${f.plugin}/${f.skill}`)})},`${f.plugin}/${f.skill}`)})})]})}function Qw(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Ud({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const f=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,h]=m.useState(()=>Qw(i,s)),y=d?!1:x,v=m.useCallback(()=>{h(C=>{const E=!C;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(E))}catch{}return E})},[i]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":f,role:"group","aria-label":`${f} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick: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:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:f}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(C=>r.jsx("div",{"data-vskill-plugin-skill":C.pluginNamespace??C.skill,children:c(C)},`${C.pluginNamespace??C.skill}`))})]})}function Fo({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:f}){const x=m.useRef(null),h=m.useRef(null),y=m.useRef(null);if(m.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var C;(C=h.current)==null||C.focus()}),()=>{var C,E;(E=(C=y.current)==null?void 0:C.focus)==null||E.call(C),y.current=null}},[t]),m.useEffect(()=>{if(!t)return;function C(E){if(E.key==="Escape"){E.preventDefault(),f();return}if(E.key==="Tab"&&x.current){const w=x.current.querySelectorAll("button:not([disabled])");if(w.length===0)return;const N=w[0],T=w[w.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[t,f]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:C=>{C.target===C.currentTarget&&f()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:x,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:h,type:"button","data-testid":"confirm-dialog-cancel",onClick:f,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:i})]})]})})}function Zw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Hd(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Jw({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=m.useState(!1),[u,d]=m.useState(null),[f,x]=m.useState(null),[h,y]=m.useState(!1),v=m.useRef(null);m.useEffect(()=>{if(!i)return;function C(E){v.current&&!v.current.contains(E.target)&&c(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[i]);async function b(C){d(C),x(null);try{const E=await fetch(`/api/plugins/${encodeURIComponent(t)}/${C}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),w=await E.json().catch(()=>({}));if(!E.ok||!w.ok){const N=w.error??`${C} failed (${E.status})`;x(N),C==="uninstall"&&Hd(`Failed to uninstall ${t}: ${N}`,"error");return}if(C==="uninstall"){const N=w.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Hd(N,"success")}Bn("skills"),ny(),s==null||s(),c(!1)}catch(E){const w=E instanceof Error?E.message:String(E);x(w),C==="uninstall"&&Hd(`Failed to uninstall ${t}: ${w}`,"error")}finally{d(null)}}function S(){y(!0)}return r.jsxs("div",{ref:v,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:C=>{C.stopPropagation(),c(E=>!E)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:C=>{C.currentTarget.style.color="var(--text-primary)",C.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:C=>{C.currentTarget.style.color="var(--text-tertiary)",C.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Pd,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Pd,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Pd,{onClick:S,disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),f&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:f})]}),r.jsx(Fo,{open:h,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{y(!1),c(!1)},onConfirm:()=>{y(!1),b("uninstall")}})]})}function Pd({onClick:t,disabled:a,busy:s,label:i,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}const eC=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function tC({anchorSkillDir:t,candidateLabel:a,initialName:s,initialDescription:i,onConverted:c,onCancel:u}){const[d,f]=m.useState(s),[x,h]=m.useState(i??""),[y,v]=m.useState(!1),[b,S]=m.useState(null),[C,E]=m.useState(null),w=eC.test(d),N=y||!w,T=m.useCallback(async A=>{if(A.preventDefault(),!N){v(!0),S(null),E(null);try{const I=await ke.convertToPlugin({anchorSkillDir:t,pluginName:d.trim(),description:x.trim()});c({pluginDir:I.pluginDir,manifestPath:I.manifestPath,validation:I.validation})}catch(I){if(I instanceof Ga){S(I.message);const L=I.details;L&&typeof L.stderr=="string"&&E(L.stderr)}else S(I instanceof Error?I.message:String(I));v(!1)}}},[N,t,d,x,c]);return r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"vskill-convert-dialog-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:A=>{A.target===A.currentTarget&&!y&&u()},children:r.jsxs("form",{onSubmit:T,style:{background:"var(--bg-primary, #fff)",color:"var(--text-primary, #111)",borderRadius:8,padding:20,width:"min(540px, 92vw)",boxShadow:"0 12px 48px rgba(0,0,0,0.25)",fontFamily:"var(--font-sans)"},children:[r.jsxs("h2",{id:"vskill-convert-dialog-title",style:{margin:0,fontSize:16,fontWeight:600},children:["Convert ",r.jsxs("span",{style:{fontFamily:"var(--font-mono)"},children:[a,"/"]})," to a plugin"]}),r.jsxs("p",{style:{marginTop:8,marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:["Writes ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:".claude-plugin/plugin.json"})," into this folder and validates it via ",r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:"claude plugin validate"}),". The skills already on disk will appear nested under the new plugin."]}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginBottom:4},children:"Plugin name"}),r.jsx("input",{type:"text",value:d,onChange:A=>f(A.target.value),disabled:y,autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontSize:13,fontFamily:"var(--font-mono)",boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),!w&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #c00)",marginTop:4},children:"Must be kebab-case (lowercase letters, digits, hyphens; 2–64 chars)."}),r.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,marginTop:12,marginBottom:4},children:"Description"}),r.jsx("input",{type:"text",value:x,onChange:A=>h(A.target.value),disabled:y,style:{width:"100%",padding:"6px 8px",fontSize:13,boxSizing:"border-box",border:"1px solid var(--border-subtle)",borderRadius:4}}),b&&r.jsxs("div",{role:"alert",style:{marginTop:12,padding:8,fontSize:12,background:"var(--color-error-bg, #fee)",color:"var(--color-error, #c00)",borderRadius:4},children:[r.jsx("div",{style:{fontWeight:500},children:b}),C&&r.jsx("pre",{style:{marginTop:6,padding:6,fontSize:11,fontFamily:"var(--font-mono)",whiteSpace:"pre-wrap",background:"rgba(0,0,0,0.04)",borderRadius:3,maxHeight:160,overflow:"auto"},children:C})]}),r.jsxs("div",{style:{marginTop:16,display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{type:"button",onClick:u,disabled:y,style:{padding:"6px 12px",fontSize:13,background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,cursor:y?"not-allowed":"pointer"},children:"Cancel"}),r.jsx("button",{type:"submit",disabled:N,style:{padding:"6px 12px",fontSize:13,background:"var(--color-accent, #2b6cb0)",color:"white",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",opacity:N?.5:1},children:y?"Converting…":"Convert"})]})]})})}function Fg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const f=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",h=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:x,borderLeft:`3px solid ${f}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:h?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[h&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:f,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(nC,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:f})})]});return h?r.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}):r.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 nC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function rC(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function aC(t){const a=t.key.split("+").map(f=>f.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const f of a.slice(0,-1)){const x=f.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function lC(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function sC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function yf(t,a={}){const{enabled:s=!0,target:i}=a,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(aC),m.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function f(x){const h=x,y=lC(h.target);for(const v of c.current){if(!sC(h,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(h);return}}}return d.addEventListener("keydown",f),()=>{d.removeEventListener("keydown",f)}},[s,i])}function By(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function iC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function oC({projectRoot:t}){const{status:a,loading:s}=By();if(s||!a||a.status==="github"||iC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const cC=200;function uC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function dC(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const d of t){const f=d.scopeV2??(d.scope==="installed"?"available-project":d.scope==="global"?"available-personal":"authoring-project");f==="available-project"?s.availableProject.push(d):f==="available-personal"?s.availablePersonal.push(d):f==="available-plugin"?s.availablePlugin.push(d):f==="authoring-plugin"?s.authoringPlugin.push(d):s.authoringProject.push(d)}function i(d){const f=d.filter(y=>qf(y,a)),x={};for(const y of f){const v=y.pluginName??y.plugin;(x[v]||(x[v]=[])).push(y)}const h=Object.entries(x).sort((y,v)=>y[0].localeCompare(v[0]));return{total:d.length,filtered:f.length,byPlugin:h}}const c=i(s.authoringProject),u=c.byPlugin.filter(([d,f])=>f.length>=2&&d.trim().length>=2).map(([d,f])=>({groupKey:d,skills:f,anchorSkillDir:f[0].dir}));return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:c,authoringPlugin:i(s.authoringPlugin),authoringCandidatePlugins:u}}function fC(t,a){const s=[],i=[],c=[];for(const d of t){const f=uC(d);f==="global"?c.push(d):f==="installed"?i.push(d):s.push(d)}function u(d){var y;const f=d.filter(v=>qf(v,a)),x={};for(const v of f)(x[y=v.plugin]||(x[y]=[])).push(v);const h=Object.entries(x).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:f.length,byPlugin:h}}return{own:u(s),installed:u(i),global:u(c)}}function pC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var h;const d=u.filter(y=>qf(y,a)),f={};for(const y of d)(f[h=y.plugin]||(f[h]=[])).push(y);const x=Object.entries(f).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function mC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:f,activeAgentId:x,outdatedByScope:h,topSlot:y,revealSkillId:v,onRevealComplete:b,dirtySkillIds:S,onSkillsChanged:C}){const[E,w]=m.useState(null),N=!!x||t.some(ce=>ce.scope!==void 0&&ce.scope!==null),T=x??"claude-cli",[A,I]=m.useState(""),L=m.useDeferredValue(A),H=m.useMemo(()=>fC(t,L),[t,L]),k=m.useMemo(()=>dC(t,L),[t,L]),O=T==="claude-code",{plugins:z}=pk(),_=O?{plugins:z??[]}:void 0,$=m.useMemo(()=>{const ce=new Map;for(const ne of(_==null?void 0:_.plugins)??[]){const ge=ce.get(ne.name);ce.set(ne.name,!!ge||!!ne.enabled)}return ce},[_==null?void 0:_.plugins]),[q,K]=m.useState(()=>bf(`vskill-sidebar-${T}-group-available-collapsed`)),[Q,U]=m.useState(()=>bf(`vskill-sidebar-${T}-group-authoring-collapsed`)),M=m.useCallback(ce=>{K(ce);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-available-collapsed`,String(ce))}catch{}},[T]),B=m.useCallback(ce=>{U(ce);try{window.localStorage.setItem(`vskill-sidebar-${T}-group-authoring-collapsed`,String(ce))}catch{}},[T]),{own:F,installed:te}=m.useMemo(()=>pC(t,L),[t,L]),D=H.own.filtered+H.installed.filtered+H.global.filtered>=cC,W=m.useMemo(()=>{const ce=ne=>{const ge=[];for(const[,Le]of ne){const Ee=[...Le].sort((Me,Pe)=>Me.skill.localeCompare(Pe.skill));ge.push(...Ee)}return ge};return N?[...ce(H.own.byPlugin),...ce(H.installed.byPlugin),...ce(H.global.byPlugin)]:[...ce(F.byPlugin),...ce(te.byPlugin)]},[N,H.own.byPlugin,H.installed.byPlugin,H.global.byPlugin,F.byPlugin,te.byPlugin]),X=m.useMemo(()=>a?W.findIndex(ce=>ce.plugin===a.plugin&&ce.skill===a.skill):-1,[W,a]),ee=m.useCallback(ce=>{if(W.length===0)return;const ne=X<0?ce>0?0:W.length-1:Math.min(Math.max(X+ce,0),W.length-1);s(W[ne])},[W,X,s]),de=m.useMemo(()=>{if(!v)return null;const[ce,ne]=v.split("/");if(!ce||!ne)return null;const ge=t.find(Me=>Me.plugin===ce&&Me.skill===ne);if(!ge)return{plugin:ce,skill:ne,bucket:null,pluginName:null};const Le=ge.source==="plugin"?"plugin":"project",Ee=Le==="plugin"?ge.pluginName??ce:null;return{plugin:ce,skill:ne,bucket:Le,pluginName:Ee}},[v,t]),le=m.useRef(null);return m.useEffect(()=>{if(!v){le.current=null;return}if(le.current===v)return;const ce=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),ne=document.querySelector(`[data-skill-id="${ce}"]`);ne&&(le.current=v,ne.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),yf([{key:"j",handler:()=>ee(1)},{key:"k",handler:()=>ee(-1)},{key:"Enter",handler:()=>{X>=0&&s(W[X])}}],{enabled:!i&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(Fw,{value:A,onChange:I}),i&&r.jsx(jC,{}),!i&&c&&r.jsx(SC,{error:c,onRetry:u}),!i&&!c&&N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Fg,{name:se.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:q,onToggle:M,count:k.availableProject.total+k.availablePersonal.total+k.availablePlugin.total}),!q&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:se.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${T}-available-project-collapsed`,count:k.availableProject.total,filteredCount:A?k.availableProject.filtered:null,updateCount:(h==null?void 0:h.installed)??(f==null?void 0:f.installed),headerRightSlot:O?r.jsx(oC,{projectRoot:T}):null,children:k.availableProject.filtered===0?r.jsx(Wg,{queryActive:!!A,agentId:T}):r.jsx($s,{items:k.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),r.jsx(Is,{label:se.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${T}-available-personal-collapsed`,count:k.availablePersonal.total,filteredCount:A?k.availablePersonal.filtered:null,updateCount:h==null?void 0:h.global,children:k.availablePersonal.filtered===0?r.jsx(xC,{queryActive:!!A,agentId:T}):r.jsx($s,{items:k.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),O&&r.jsxs(Is,{label:se.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-available-plugin-collapsed`,count:k.availablePlugin.total,filteredCount:A?k.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),k.availablePlugin.filtered===0?r.jsx(gC,{queryActive:!!A,hasInstalled:k.availablePlugin.total>0}):k.availablePlugin.byPlugin.map(([ce,ne])=>r.jsx(Ud,{pluginName:ce,skills:ne,persistKey:`vskill-plugin-available-${ce}-collapsed`,headerActionSlot:O?r.jsx(Jw,{pluginName:ce,enabled:$.get(ce)??!0}):void 0,renderSkill:ge=>r.jsx(Ys,{skill:ge,isSelected:(a==null?void 0:a.plugin)===ge.plugin&&(a==null?void 0:a.skill)===ge.skill,onSelect:()=>s(ge),onContextMenu:d,dirty:S==null?void 0:S.has(`${ge.plugin}/${ge.skill}`)})},`available-${ce}`))]})]}),r.jsx(bC,{}),r.jsx(Fg,{name:se.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:de?!1:Q,onToggle:B,count:k.authoringProject.total+k.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!Q||de)&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:se.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${T}-authoring-project-collapsed`,count:k.authoringProject.total,filteredCount:A?k.authoringProject.filtered:null,updateCount:(h==null?void 0:h.own)??(f==null?void 0:f.source),forceOpen:(de==null?void 0:de.bucket)==="project",children:k.authoringProject.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsxs(r.Fragment,{children:[k.authoringCandidatePlugins.map(ce=>r.jsx(Ud,{pluginName:ce.groupKey,skills:ce.skills,persistKey:`vskill-candidate-plugin-${ce.groupKey}-collapsed`,headerActionSlot:r.jsx("button",{type:"button",onClick:ne=>{ne.stopPropagation(),w({candidateLabel:ce.groupKey,initialName:ce.groupKey,anchorSkillDir:ce.anchorSkillDir})},title:"Write .claude-plugin/plugin.json into this folder so Claude Code recognizes it as a plugin",style:{fontSize:10,fontWeight:500,padding:"2px 8px",borderRadius:10,border:"1px solid var(--border-subtle, rgba(128,128,128,0.3))",background:"transparent",color:"var(--text-secondary)",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Not a plugin yet · Convert →"}),renderSkill:ne=>r.jsx(Ys,{skill:ne,isSelected:(a==null?void 0:a.plugin)===ne.plugin&&(a==null?void 0:a.skill)===ne.skill,onSelect:()=>s(ne),onContextMenu:d,dirty:S==null?void 0:S.has(`${ne.plugin}/${ne.skill}`)})},`candidate-${ce.groupKey}`)),r.jsx($s,{items:k.authoringProject.byPlugin.filter(([ce])=>!k.authoringCandidatePlugins.some(ne=>ne.groupKey===ce)),selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})]})}),O&&r.jsx(Is,{label:se.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${T}-authoring-plugin-collapsed`,count:k.authoringPlugin.total,filteredCount:A?k.authoringPlugin.filtered:null,forceOpen:(de==null?void 0:de.bucket)==="plugin",children:k.authoringPlugin.filtered===0?r.jsx(vC,{queryActive:!!A,hasSources:k.authoringPlugin.total>0,candidates:k.authoringCandidatePlugins,onPromote:ce=>w({candidateLabel:ce.groupKey,initialName:ce.groupKey,anchorSkillDir:ce.anchorSkillDir})}):k.authoringPlugin.byPlugin.map(([ce,ne])=>r.jsx(Ud,{pluginName:ce,skills:ne,persistKey:`vskill-plugin-authoring-${ce}-collapsed`,forceOpen:(de==null?void 0:de.bucket)==="plugin"&&de.pluginName===ce,renderSkill:ge=>r.jsx(Ys,{skill:ge,isSelected:(a==null?void 0:a.plugin)===ge.plugin&&(a==null?void 0:a.skill)===ge.skill,onSelect:()=>s(ge),onContextMenu:d,dirty:S==null?void 0:S.has(`${ge.plugin}/${ge.skill}`)})},`authoring-${ce}`))})]})]}),!i&&!c&&!N&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Vg,{origin:"source",count:F.total,filteredCount:A?F.filtered:null,updateCount:f==null?void 0:f.source,children:F.filtered===0?r.jsx(Gg,{queryActive:!!A}):r.jsx($s,{items:F.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})}),r.jsx(yC,{}),r.jsx(Vg,{origin:"installed",count:te.total,filteredCount:A?te.filtered:null,updateCount:f==null?void 0:f.installed,children:te.filtered===0?r.jsx(Wg,{queryActive:!!A}):r.jsx($s,{items:te.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:D,dirtySkillIds:S})})]}),E&&r.jsx(tC,{anchorSkillDir:E.anchorSkillDir,candidateLabel:E.candidateLabel,initialName:E.initialName,onCancel:()=>w(null),onConverted:ce=>{w(null),C==null||C(),ce.validation==="skipped"&&window.alert("Plugin manifest written, but schema validation was skipped because the 'claude' CLI is not on PATH. Install Claude Code to enable plugin schema validation.")}})]})}function bf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Is({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:f}){const[x,h]=m.useState(()=>bf(a)),y=d?!1:x,v=m.useCallback(()=>{h(S=>{const C=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(C))}catch{}return C})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:y?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),f]}),!y&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function hC(t){const a=[];for(const[s,i]of t){const c=[...i].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function $s({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=hC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(kw,{overscan:4,totalCount:d.length,itemContent:f=>{const x=d[f];if(!x)return null;if(x.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const h=x.skill,y=!!a&&a.plugin===h.plugin&&a.skill===h.skill;return r.jsx(Ys,{skill:h,isSelected:y,onSelect:()=>s(h),onContextMenu:i,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,f])=>r.jsx(Xw,{plugin:d,skills:f,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Gg({queryActive:t}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx($l,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Wg({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install <skill>"})," to add one."]})})}function xC({queryActive:t,agentId:a}){return t?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx($l,{children:"vskill install --global <skill>"})," to add one."]})})}function gC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(yr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx($l,{children:"Browse marketplaces…"})," above to add one."]})})}function vC({queryActive:t,hasSources:a,candidates:s,onPromote:i}){return t&&a?r.jsx(yr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsxs(r.Fragment,{children:[r.jsx(yr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx($l,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one, or ",r.jsx($l,{children:"vskill plugin new"})," from the terminal."]})}),s&&s.length>0&&r.jsxs("div",{style:{padding:"0 14px 12px",display:"flex",flexDirection:"column",gap:6},children:[r.jsxs("div",{style:{fontSize:11,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:2},children:["Candidate folders (",s.length,")"]}),s.map(c=>r.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(c),title:`Promote ${c.groupKey}/ to a Claude Code plugin`,style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,padding:"6px 8px",fontSize:12,background:"transparent",border:"1px dashed var(--border-subtle, rgba(128,128,128,0.35))",borderRadius:4,color:"var(--text-primary)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-mono)"},children:[r.jsxs("span",{children:[c.groupKey,"/ ",r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["(",c.skills.length," skills)"]})]}),r.jsx("span",{style:{fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-secondary)"},children:"Promote →"})]},`promote-${c.groupKey}`))]})]})}function yr({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function $l({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function yC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function bC(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function jC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(rC,{},t))})}function SC({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:kC(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function kC(t){const a=t.split(`
66
66
  `)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const Iy=240,$y=480,Uy="vskill-sidebar-width",Ks=320;function Yf(t){return Number.isFinite(t)?Math.round(Math.max(Iy,Math.min($y,t))):Ks}function wC(){try{const t=localStorage.getItem(Uy);if(!t)return Ks;const a=Number(t);return Number.isFinite(a)?Yf(a):Ks}catch{return Ks}}function CC(t){try{localStorage.setItem(Uy,String(Yf(t)))}catch{}}function EC({initialWidth:t,onChange:a}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),i=m.useRef(t);return m.useEffect(()=>{i.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const f=d.clientX-s.current.startX,x=Yf(s.current.startWidth+f);i.current=x,a(x)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,CC(i.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":Iy,"aria-valuemax":$y,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=i.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}const NC=/^[ MADRCU?!]{1,2} +/;function TC(t){return t.replace(NC,"")}function RC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function AC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>TC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const f=RC(s,d);if(f===null)continue;const x=`${u.plugin}/${u.skill}`;if(f===""){c.length>0&&i.add(x);continue}const h=f+"/";for(const y of c)if(y===f||y.startsWith(h)){i.add(x);break}}return i}const LC=5e3;function MC(t,a,s=LC){const[i,c]=m.useState([]),u=m.useRef(t);return u.current=t,m.useEffect(()=>{if(!a){c([]);return}let d=!1,f=null;const x=async()=>{try{const y=await ke.gitStatus();d||c(y.paths??[])}catch{d||c([])}d||(f=setTimeout(x,s))};x();const h=()=>{x()};return typeof window<"u"&&window.addEventListener("studio:content-saved",h),()=>{d=!0,f&&clearTimeout(f),typeof window<"u"&&window.removeEventListener("studio:content-saved",h)}},[a,s]),a?AC(u.current,i,a):new Set}function zC({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function Hy(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function Py(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(i,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Vd(){const[t,a]=m.useState([]),[s,i]=m.useState(!1),[c,u]=m.useState(!1),[d,f]=m.useState(null),x=m.useRef(null),h=m.useCallback(async(v,b)=>{a([]),i(!0),u(!1),f(null);const S=new AbortController;x.current=S;try{const C=Py(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:C,signal:S.signal});if(!E.ok||!E.body){let I=`HTTP ${E.status}`,L;try{L=await E.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(I=L.error)}catch{}throw Hy(E.status,L),new Error(I)}const w=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:I,value:L}=await w.read();if(I)break;T+=N.decode(L,{stream:!0});const H=T.split(`
67
67
  `);T=H.pop()||"";for(const k of H)if(k.startsWith("event: "))A=k.slice(7).trim();else if(k.startsWith("data: ")){try{const O=JSON.parse(k.slice(6)),z={event:A,data:O};A==="done"?(u(!0),a(_=>[..._,z])):a(_=>[..._,z])}catch{}A=""}}}catch(C){C.name!=="AbortError"&&f(C.message)}finally{i(!1),x.current=null}},[]),y=m.useCallback(()=>{var v;(v=x.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:h,stop:y}}function DC(t){const a=m.useRef(t);a.current=t;const[s,i]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(h,y,v)=>{var S;(S=c.current.get(h))==null||S.abort();const b=new AbortController;c.current.set(h,b),i(C=>{const E=new Set(C);return E.add(h),E});try{const C=Py(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:C,signal:b.signal});if(!E.ok||!E.body){let I=`HTTP ${E.status}`,L;try{L=await E.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(I=L.error)}catch{}throw Hy(E.status,L),new Error(I)}const w=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:I,value:L}=await w.read();if(I)break;T+=N.decode(L,{stream:!0});const H=T.split(`
68
68
  `);T=H.pop()||"";for(const k of H)if(k.startsWith("event: "))A=k.slice(7).trim();else if(k.startsWith("data: ")){try{const O=JSON.parse(k.slice(6)),z={event:A,data:O};a.current.onEvent(h,z)}catch{}A=""}}a.current.onDone(h)}catch(C){C.name!=="AbortError"&&a.current.onError(h,C.message)}finally{i(C=>{const E=new Set(C);return E.delete(h),E}),c.current.delete(h)}},[]),d=m.useCallback(h=>{var y;(y=c.current.get(h))==null||y.abort()},[]),f=m.useCallback(()=>{for(const h of c.current.values())h.abort()},[]),x=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:f,isAnyCaseRunning:x}}const _C={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationPromptsSource:null,activationPromptsCanonical:"",savingTestCases:!1,savingTestCasesError:null,savingTestCasesSuccess:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function OC(t,a){var s,i;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(f=>({assertion_id:f.id,text:f.text,pass:f.pass,reasoning:f.reasoning}))});const u=((i=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:i.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":{const c=a.prompts===t.activationPromptsCanonical;return{...t,activationPrompts:a.prompts,activationPromptsSource:c?t.activationPromptsSource:t.activationPromptsSource===null||t.activationPromptsSource==="skill-md"||t.activationPromptsSource==="ai-generated"?"user-typed":t.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...t,activationPromptsSource:a.source,activationPromptsCanonical:a.canonical??t.activationPromptsCanonical};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"SAVE_TEST_CASES_START":return{...t,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...t,savingTestCases:!1,savingTestCasesSuccess:`Saved ${a.count} test case${a.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:t.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...t,savingTestCases:!1,savingTestCasesError:a.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...t,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function BC(t){if(t==="unit"||t==="integration")return t}function IC(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const i={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===i.assertion_id)||t.assertions.push(i)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const Vy=m.createContext(null);function nr(){const t=m.useContext(Vy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function $C({plugin:t,skill:a,origin:s,children:i}){const c=s==="installed",{config:u}=Ya(),[d,f]=m.useReducer(OC,{..._C,plugin:t,skill:a}),x=m.useRef(new Set),h=m.useRef(new Set),y=m.useRef(new Map),v=m.useCallback((ie,fe)=>{let he=y.current.get(ie);he||(he={assertions:[]},y.current.set(ie,he)),IC(he,fe),f({type:"UPDATE_INLINE_RESULT",evalId:ie,result:{...he,assertions:[...he.assertions]}})},[]),b=m.useCallback(ie=>{if(h.current.has(ie))return;h.current.add(ie);const fe=y.current.get(ie)??{assertions:[]};f({type:"CASE_RUN_COMPLETE",caseId:ie,result:{...fe,assertions:[...fe.assertions]}}),x.current.has(ie)&&(x.current.delete(ie),x.current.size===0&&ke.getLatestBenchmark(t,a).then(he=>f({type:"BULK_RUN_COMPLETE",benchmark:he})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),S=m.useCallback((ie,fe)=>{h.current.has(ie)||(h.current.add(ie),f({type:"CASE_RUN_ERROR",caseId:ie,error:fe}),x.current.has(ie)&&(x.current.delete(ie),x.current.size===0&&ke.getLatestBenchmark(t,a).then(he=>f({type:"BULK_RUN_COMPLETE",benchmark:he})).catch(()=>f({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:C,stopCase:E,stopAll:w}=DC({onEvent:v,onDone:b,onError:S});m.useEffect(()=>()=>{w()},[w]);const N=m.useCallback(async()=>{try{const ie=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ie.ok){if(ie.status===404){f({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const fe=await ie.json();f({type:"ACTIVATION_HISTORY_LOADED",runs:fe.runs||[]})}catch{}},[t,a]);m.useEffect(()=>{let ie=!1;async function fe(){try{const[he,be,je]=await Promise.allSettled([ke.getSkillDetail(t,a),ke.getEvals(t,a),ke.getLatestBenchmark(t,a)]);if(ie)return;let Ge=null,ut=null;if(be.status==="fulfilled")Ge=be.value;else{const gt=be.reason;ut=(gt==null?void 0:gt.message)??"Failed to load test cases"}f({type:"INIT_DATA",skillContent:he.status==="fulfilled"?he.value.skillContent:"",evals:Ge,evalsError:ut,benchmark:je.status==="fulfilled"?je.value:null})}catch(he){ie||f({type:"SET_ERROR",error:he.message})}}return fe(),N(),()=>{ie=!0}},[t,a,N]);const T=m.useCallback(async ie=>{if(c)return;const fe=ie??d.skillContent;try{await ke.applyImprovement(t,a,fe),ie!==void 0&&ie!==d.skillContent&&f({type:"SET_CONTENT",content:ie}),f({type:"CONTENT_SAVED"})}catch(he){f({type:"SET_ERROR",error:he.message})}},[c,t,a,d.skillContent]),A=m.useCallback(async ie=>{if(!c)try{const fe=await ke.saveEvals(t,a,ie);f({type:"SET_EVALS",evals:fe})}catch(fe){f({type:"SET_ERROR",error:fe.message})}},[c,t,a]),I=m.useCallback((ie,fe="benchmark")=>{if(c)return;const he=d.caseRunStates.get(ie);if((he==null?void 0:he.status)==="running")return;y.current.delete(ie),h.current.delete(ie),f({type:"CASE_RUN_START",caseId:ie,mode:fe});const be=fe==="comparison"?{eval_ids:[ie]}:fe==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(be.provider=u.provider),u!=null&&u.model&&(be.model=u.model),fe==="comparison"){const je=`/api/skills/${t}/${a}/compare`;C(ie,je,be)}else{const je=`/api/skills/${t}/${a}/benchmark/case/${ie}`;C(ie,je,Object.keys(be).length>0?be:void 0)}},[c,t,a,d.caseRunStates,C,u]),L=m.useCallback((ie="benchmark")=>{var be;if(c)return;const fe=((be=d.evals)==null?void 0:be.evals)??[];if(fe.length===0)return;const he=fe.map(je=>je.id);for(const je of he)y.current.delete(je),h.current.delete(je);f({type:"BULK_RUN_START",caseIds:he,mode:ie}),x.current=new Set(he);for(const je of he){const Ge=ie==="comparison"?{eval_ids:[je]}:ie==="baseline"?{mode:"baseline"}:{};if(u!=null&&u.provider&&(Ge.provider=u.provider),u!=null&&u.model&&(Ge.model=u.model),ie==="comparison")C(je,`/api/skills/${t}/${a}/compare`,Ge);else{const ut=`/api/skills/${t}/${a}/benchmark/case/${je}`;C(je,ut,Object.keys(Ge).length>0?Ge:void 0)}}},[c,t,a,d.evals,C,u]),H=m.useCallback(ie=>{E(ie),f({type:"CASE_RUN_CANCEL",caseId:ie}),x.current.delete(ie),h.current.add(ie)},[E]),k=m.useCallback(()=>{w(),f({type:"CANCEL_ALL"}),x.current.clear()},[w]),O=m.useCallback(async(ie,fe)=>{f({type:"OPEN_IMPROVE",evalId:ie})},[]),z=m.useCallback(async(ie,fe)=>{try{await ke.applyImprovement(t,a,fe),f({type:"SET_CONTENT",content:fe}),f({type:"CONTENT_SAVED"}),f({type:"CLOSE_IMPROVE"}),I(ie,"benchmark")}catch(he){f({type:"SET_ERROR",error:he.message})}},[t,a,I]),_=Vd(),$=m.useRef(null),q=m.useRef(0);m.useEffect(()=>{const ie=_.events;for(let fe=q.current;fe<ie.length;fe++){const he=ie[fe],be=he.data;if(he.event==="progress"&&f({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),he.event==="done"){const je=be.improved,Ge=be.reasoning,ut=be.evalChanges??[];f({type:"AI_EDIT_RESULT",improved:je,reasoning:Ge,evalChanges:ut})}if(he.event==="error"){const je=be;f({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}q.current=ie.length},[_.events]),m.useEffect(()=>{_.error&&f({type:"AI_EDIT_ERROR",message:_.error})},[_.error]),m.useEffect(()=>()=>{_.stop()},[_.stop]);const K=m.useCallback(async(ie,fe,he)=>{c||(q.current=0,f({type:"AI_EDIT_LOADING"}),$.current=_.stop,_.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ie,content:d.skillContent,evals:d.evals??{skill_name:a,evals:[]},provider:fe,model:he}))},[c,t,a,d.skillContent,d.evals,_]),Q=m.useCallback(()=>{_.stop(),f({type:"AI_EDIT_ERROR",message:"Cancelled"})},[_]),U=m.useCallback(async()=>{const ie=d.aiEditResult;if(ie!=null&&ie.improved)try{if(await ke.applyImprovement(t,a,ie.improved),f({type:"SET_CONTENT",content:ie.improved}),f({type:"CONTENT_SAVED"}),d.aiEditEvalChanges.length>0&&Array.from(d.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:he}=await Vl(async()=>{const{mergeEvalChanges:Ge}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Ge}},[]),be=d.evals??{skill_name:a,evals:[]},je=he(be,d.aiEditEvalChanges,d.aiEditEvalSelections);try{const Ge=await ke.saveEvals(t,a,je);f({type:"SET_EVALS",evals:Ge})}catch(Ge){f({type:"SET_EVALS_RETRY",evalsFile:je}),f({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Ge.message}. You can retry from the AI Edit panel.`});return}}f({type:"CLOSE_AI_EDIT"})}catch(fe){f({type:"SET_ERROR",error:fe.message})}},[t,a,d.aiEditResult,d.evals,d.aiEditEvalChanges,d.aiEditEvalSelections]),M=m.useCallback(()=>{f({type:"CLOSE_AI_EDIT"})},[]),B=m.useCallback(ie=>{f({type:"TOGGLE_EVAL_CHANGE",index:ie})},[]),F=m.useCallback(()=>{f({type:"SELECT_ALL_EVAL_CHANGES"})},[]),te=m.useCallback(()=>{f({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(async()=>{const ie=d.aiEditEvalsRetry;if(ie)try{const fe=await ke.saveEvals(t,a,ie);f({type:"SET_EVALS",evals:fe}),f({type:"SET_ERROR",error:null}),f({type:"CLOSE_AI_EDIT"})}catch(fe){f({type:"SET_ERROR",error:`Retry failed: ${fe.message}`})}},[t,a,d.aiEditEvalsRetry]),D=m.useCallback(async()=>{try{const ie=await ke.getSkillDetail(t,a);f({type:"SET_CONTENT",content:ie.skillContent}),f({type:"CONTENT_SAVED"})}catch{}},[t,a]),W=Vd(),X=m.useRef(0);m.useEffect(()=>{const ie=W.events;for(let fe=X.current;fe<ie.length;fe++){const he=ie[fe],be=he.data;if(he.event==="progress"&&f({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:be.phase,message:be.message}}),he.event==="done"){const je=be;ke.saveEvals(t,a,je).then(Ge=>f({type:"GENERATE_EVALS_DONE",evals:Ge})).catch(Ge=>f({type:"SET_ERROR",error:Ge.message}))}he.event==="error"&&f({type:"GENERATE_EVALS_ERROR",classified:be})}X.current=ie.length},[W.events,t,a]),m.useEffect(()=>{W.error&&f({type:"SET_ERROR",error:W.error})},[W.error]),m.useEffect(()=>()=>{W.stop()},[W.stop]);const ee=m.useCallback(async ie=>{if(c)return;X.current=0,f({type:"GENERATE_EVALS_START"});const fe={};u!=null&&u.provider&&(fe.provider=u.provider),u!=null&&u.model&&(fe.model=u.model);const he=BC(ie==null?void 0:ie.testType);he&&(fe.testType=he),W.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(fe).length>0?fe:void 0)},[c,t,a,W,u]),de=Vd(),le=m.useRef(0);m.useEffect(()=>()=>{de.stop()},[de.stop]),m.useEffect(()=>{const ie=de.events;for(let fe=le.current;fe<ie.length;fe++){const he=ie[fe];if(he.event==="classifying"){const be=he.data;f({type:"ACTIVATION_CLASSIFYING",index:be.index,total:be.total})}if(he.event==="prompt_result"&&f({type:"ACTIVATION_RESULT",result:he.data}),he.event==="done"){ce.current&&(clearTimeout(ce.current),ce.current=null);const be=he.data;if(be.error)f({type:"ACTIVATION_ERROR",error:be.error});else{f({type:"ACTIVATION_DONE",summary:be});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(u==null?void 0:u.model)||"unknown",provider:(u==null?void 0:u.provider)||"unknown",promptCount:be.total,summary:{precision:be.precision,recall:be.recall,reliability:be.reliability,tp:be.tp,tn:be.tn,fp:be.fp,fn:be.fn}};f({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...d.activationHistory??[]]})}}}le.current=ie.length},[de.events,u,d.activationHistory]),m.useEffect(()=>{de.error&&(ce.current&&(clearTimeout(ce.current),ce.current=null),f({type:"ACTIVATION_ERROR",error:de.error}))},[de.error]);const ce=m.useRef(null),ne=m.useCallback(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null),de.stop(),f({type:"ACTIVATION_CANCEL",totalPrompts:0})},[de]),ge=m.useCallback(ie=>{const he=ie.trim().split(`
@@ -118,5 +118,5 @@ You are an expert at...
118
118
  }`})]})]}),document.body)}function FT({title:t,onClose:a}){return r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:se.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":se.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function GT({content:t}){var a,s;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(i=>r.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:i},i))}),t.envVars.length>0&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:se.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(i=>r.jsx("li",{children:r.jsx(qT,{name:i})},i))})]}),t.keyUrl&&r.jsx(YT,{href:t.keyUrl,label:se.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:se.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((i,c)=>r.jsx(nf,{code:i},`install-${c}`)),(s=t.start)==null?void 0:s.map((i,c)=>r.jsx(nf,{code:i},`start-${c}`)),t.pullExample&&r.jsx(nf,{code:t.pullExample})]})]}),r.jsx("footer",{style:{marginTop:8},children:r.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[se.setupDrawer.learnMore," →"]})})]})}function WT(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:se.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:se.setupDrawer.fallbackBody})]})}function qT({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),r.jsx("button",{type:"button",onClick:a,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:se.setupDrawer.copy})]})}function nf({code:t}){return r.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function YT({href:t,label:a,testId:s}){return r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer","data-testid":s,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[a," →"]})}function KT(){const[t,a]=m.useState(!1),[s,i]=m.useState(null),c=m.useRef(null),u=m.useCallback((f,x)=>{var h;c.current=typeof document<"u"?document.activeElement:null,(h=x==null?void 0:x.beforeOpen)==null||h.call(x),i(f),a(!0)},[]),d=m.useCallback(()=>{a(!1);const f=c.current;f&&"focus"in f&&typeof f.focus=="function"&&queueMicrotask(()=>f.focus())},[]);return m.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function XT(t){const a=[],s=[],i=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(i.has(u))continue;i.add(u);const d=t.filter(f=>c.sharedFolderGroup.includes(f.id));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((f,x)=>f+x.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function QT({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:i,onSwitch:c,onOpenSetup:u,onClose:d}){const f=m.useRef(null);m.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),m.useEffect(()=>{const y=b=>{f.current&&!f.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const x=m.useMemo(()=>XT(t),[t]),h=t.find(y=>y.id===s)??t.find(y=>y.id===a)??t[0];return typeof document>"u"?null:rc.createPortal(r.jsxs("div",{ref:f,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":se.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[r.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[x.detected.length===0&&x.notDetected.length===0&&r.jsx(yv,{}),x.detected.map(y=>y.kind==="aggregate"?r.jsx(JT,{row:y,onFocus:()=>{var v;return i(((v=y.consumers[0])==null?void 0:v.id)??a??"")}},y.key):r.jsx(ZT,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===a,onClick:()=>i(y.agent.id)},y.key)),x.notDetected.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:se.scopePicker.notDetectedSubheading}),x.notDetected.map(y=>r.jsx(eR,{agent:y.agent},y.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:h?r.jsx(tR,{agent:h,activeAgentId:a,onSwitch:()=>c(h.id)}):r.jsx(yv,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
119
119
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
120
120
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
121
- }`})]}),document.body)}function ZT({agent:t,focused:a,active:s,onClick:i}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:i,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function JT({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function eR({agent:t}){const a=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function tR({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":se.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":rR(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(_o,{label:se.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(_o,{label:se.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(_o,{label:se.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(_o,{label:se.scopePicker.statsLastSync,value:t.lastSync?nR(t.lastSync):"—"})]}),r.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function _o({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function yv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function nR(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function rR(t){switch(t){case"ok":return se.scopePicker.statsHealthOk;case"stale":return se.scopePicker.statsHealthStale;case"missing":return se.scopePicker.statsHealthMissing}}function aR(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function lR({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=m.useState(!1),[d,f]=m.useState(null),x=m.useRef(null),h=m.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=m.useMemo(()=>h?h.health==="ok"?"var(--color-ok, #22c55e)":h.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[h]),v=m.useCallback(()=>{var S;u(!1),(S=x.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(h==null?void 0:h.displayName)??"Select agent"}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(h==null?void 0:h.installedCount)??0," · ",(h==null?void 0:h.globalCount)??0," · ",(h==null?void 0:h.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(QT,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:f,onSwitch:b,onOpenSetup:S=>{i(S),v()},onClose:v})]})}const vb="vskill-ccode-banner-dismissed",sR=new Set(["claude-cli","claude-code"]);function iR(){try{return sessionStorage.getItem(vb)==="true"}catch{return!1}}function oR(){try{sessionStorage.setItem(vb,"true")}catch{}}function cR({activeAgentId:t}){const[a,s]=m.useState(()=>iR()),i=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{oR(),s(!0)},[]);return!t||!sR.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[se.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:se.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function uR(){const[t,a]=m.useState(null),[s,i]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const f=await ke.getAgents();a(f),i("ready"),u(null)}catch(f){i("error"),u(f.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const f=()=>void d();return window.addEventListener("studio:agent-changed",f),()=>window.removeEventListener("studio:agent-changed",f)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Oo="workspace",dR=["skills","agents"];async function fR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function pR(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function mR(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function hR(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function rf(){for(const t of dR)Bn(t)}function xR(){const{data:t,loading:a,error:s,revalidate:i}=qa(Oo,fR),c=t,u=c==null?void 0:c.projects.find(h=>h.id===c.activeProjectId),d=m.useCallback(async h=>{await pR(h),Bn(Oo),rf()},[]),f=m.useCallback(async h=>{await mR(h),Bn(Oo),rf()},[]),x=m.useCallback(async h=>{await hR(h),Bn(Oo),rf()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:f,removeProject:x,revalidate:i}}function gR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),[S,C]=m.useState(null),[E,w]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),I=(t==null?void 0:t.projects)??[],L=I.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(_){A.current&&!A.current.contains(_.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function H(){b(null);const z=h.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(""),x(!1)}catch(_){const $=_ instanceof Error?_.message:String(_);/does not exist/i.test($)?b(`Path not found on disk: ${z}`):/Duplicate/i.test($)?b("That project is already registered."):b($)}}async function k(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),x(!0)}catch{}else x(!0)}function O(z){if(z.length<=50)return z;const _=z.split("/");return _.length<=4?z:`${_.slice(0,3).join("/")}/…/${_.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(L==null?void 0:L.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(L==null?void 0:L.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L?L.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[I.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),I.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:I.map(z=>{const _=c?c(z.path):!1,$=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":_?"true":"false",onMouseEnter:()=>C(z.id),onMouseLeave:()=>C(K=>K===z.id?null:K),onClick:()=>{if(!_){if($){d(!1);return}w(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:q&&!_?"var(--surface-2, rgba(0,0,0,0.04))":$?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:_?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:$?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:$?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),$&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),_&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:K=>{K.stopPropagation(),i(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:K=>{K.currentTarget.style.color="var(--color-error, #b91c1c)",K.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:K=>{K.currentTarget.style.color="var(--text-tertiary)",K.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:f?8:6},children:[!f&&r.jsxs("button",{type:"button",onClick:()=>void k(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),f&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:h,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&H(),z.key==="Escape"&&(x(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{x(!1),b(null),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"}),r.jsx("button",{type:"button",onClick:()=>void H(),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&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>w(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${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"}),r.jsx("button",{type:"button",onClick:()=>w(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function vR(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function yR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=m.useState(""),[d,f]=m.useState(0),x=m.useMemo(()=>vR(a,c),[a,c]);m.useEffect(()=>{t||(u(""),f(0))},[t]),m.useEffect(()=>{d>=x.length&&f(0)},[x.length,d]);const h=y=>{if(y.key==="Escape"){y.preventDefault(),i();return}if(y.key==="ArrowDown"){y.preventDefault(),f(v=>Math.min(v+1,Math.max(x.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),f(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=x[d];v&&(s(v.id),i())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:i}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:h,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.map((y,v)=>r.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:()=>f(v),onClick:()=>{s(y.id),i()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const bv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function bR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,f]=m.useState("destination"),[x,h]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[C,E]=m.useState(""),[w,N]=m.useState([]),[T,A]=m.useState(!1),[I,L]=m.useState(null);if(m.useEffect(()=>{t&&(f("destination"),h(s),v(""),S(""),E(""),L(null))},[t,s]),m.useEffect(()=>{if(!t)return;let U=!0;return fetch("/api/authoring/plugins").then(M=>M.json()).then(M=>{U&&N(M.plugins??[])}).catch(()=>{}),()=>{U=!1}},[t]),m.useEffect(()=>{if(!t)return;function U(M){M.key==="Escape"&&(M.preventDefault(),a())}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[t,a]),!t)return null;const H=w.length>0,k=i&&H,O=i,z=bv.test(y),_=x==="existing-plugin"?b.length>0:bv.test(b),$=!T&&z&&(x==="standalone"||_),q=jR(c,x,b,y);async function K(){L(null),A(!0);try{const B=new URLSearchParams;B.set("mode",x),B.set("skillName",y),b&&B.set("pluginName",b);const F=await fetch(`/api/authoring/skill-exists?${B.toString()}`),te=await F.json();if(!F.ok){L(te.error??`Check failed: ${F.status}`);return}if(te.exists){L(`Skill '${y}' already exists${te.path?` at ${te.path}`:""}`);return}}catch(B){L(B instanceof Error?B.message:String(B));return}finally{A(!1)}const U=new URLSearchParams;U.set("mode",x),U.set("skillName",y),C.trim()&&U.set("description",C.trim()),b&&U.set("pluginName",b);const M=`#/create?${U.toString()}`;typeof window<"u"&&(window.location.hash=M),a()}async function Q(){L(null),A(!0);try{const U=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:y,description:C.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),M=await U.json();if(!U.ok||!M.ok){L(M.error??`Create failed: ${U.status}`);return}Bn("skills"),u==null||u({mode:x,skillName:y,pluginName:M.pluginName??null,skillMdPath:M.skillMdPath}),a()}catch(U){L(U instanceof Error?U.message:String(U))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(af,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>h("standalone")}),r.jsx(af,{title:"Add to existing plugin",subtitle:k?`${w.length} plugin source${w.length===1?"":"s"} in this project`:i?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!k,selected:x==="existing-plugin",onClick:()=>k&&h("existing-plugin")}),r.jsx(af,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:x==="new-plugin",onClick:()=>O&&h("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(Bo,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:U=>S(U.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:Io(!b||_)})}),x==="existing-plugin"&&r.jsx(Bo,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:U=>S(U.target.value),style:{...Io(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),w.map(U=>r.jsx("option",{value:U.name,children:U.name},U.path))]})}),r.jsx(Bo,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:U=>v(U.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:Io(!y||z)})}),r.jsx(Bo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:C,onChange:U=>E(U.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Io(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map((U,M)=>r.jsx("div",{children:U},M))]}),I&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:I})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:lf,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>f("details"),style:jv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>f("destination"),style:lf,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void K(),disabled:!$,style:{...lf,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void Q(),disabled:!$,style:{...jv,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function af({title:t,subtitle:a,description:s,icon:i,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:i}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Bo({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function Io(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 jv={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"},lf={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 jR(t,a,s,i){const c=i||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function yb(t){return t.trim().toLowerCase()}function SR(t,a){const s=yb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function kR(t,a){const s=yb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function wR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=m.useState(null),[f,x]=m.useState([]),[h,y]=m.useState(null),[v,b]=m.useState(null),[S,C]=m.useState(!1),[E,w]=m.useState(null),[N,T]=m.useState(""),[A,I]=m.useState("");m.useEffect(()=>{h?T(""):I("")},[h]);const L=m.useMemo(()=>SR(f,N),[f,N]),H=m.useMemo(()=>kR((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(C(!0),w(null),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);x(k.marketplaces??[])}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>C(!1)))},[t]),m.useEffect(()=>{if(!h){b(null);return}C(!0),w(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(h)}`).then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);b(k)}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>C(!1))},[h]),m.useEffect(()=>{if(!t)return;function k(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[h&&r.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"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:h?(v==null?void 0:v.name)??h:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!h&&!S&&f.length===0&&!E&&r.jsx(CR,{}),!h&&f.length>0&&r.jsx(Sv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!h&&f.length>0&&L.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!h&&L.map(k=>r.jsxs("button",{type:"button",onClick:()=>y(k.name),style:NR,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:k.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.source})]},k.name)),h&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(Sv,{value:A,onChange:I,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&H.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),H.map(k=>{const O=c.has(k.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[k.name,k.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:k.version}),k.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:k.category})]}),k.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:k.description})]}),O&&i?r.jsx("button",{type:"button",disabled:u===k.name,onClick:async()=>{d(k.name);try{await i(k.name)}finally{d(null)}},"aria-label":`Uninstall ${k.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===k.name?"wait":"pointer",opacity:u===k.name?.6:1,fontFamily:"inherit"},children:u===k.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(k.name,h),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"})]})},k.name)})]})]}),!h&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(ER,{onAdded:()=>{Bn("marketplaces"),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>x(k.marketplaces??[]))}})})]})]}):null}function Sv({value:t,onChange:a,placeholder:s,ariaLabel:i,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":i,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function CR(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function ER({onAdded:t}){const[a,s]=m.useState(""),[i,c]=m.useState(!1),[u,d]=m.useState(null);async function f(){const x=a.trim();if(x){c(!0),d(null);try{const h=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),y=await h.json().catch(()=>({}));if(!h.ok||!y.ok){d(y.error??`Add failed (${h.status})`);return}s(""),t()}catch(h){d(h instanceof Error?h.message:String(h))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&f()},placeholder:"anthropics/claude-plugins-official",disabled:i,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void f(),disabled:i||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:i||!a.trim()?"not-allowed":"pointer",opacity:i||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const NR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},sf=12;function TR({job:t,onDone:a}){const[s,i]=m.useState([]),[c,u]=m.useState("running"),[d,f]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;i([]),u("running"),f(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const C=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!C.ok||!C.body){u("failed"),a({ok:!1,code:C.status,lines:[`HTTP ${C.status}`]});return}const E=C.body.getReader(),w=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=w.decode(T,{stream:!0});const I=N.split(/\n\n/);N=I.pop()??"";for(const L of I){const H=L.match(/^data:\s*(.*)$/m);if(H)try{const k=JSON.parse(H[1]);k.type==="stdout"&&k.line?(b=[...b,k.line].slice(-sf),i(b)):k.type==="stderr"&&k.line?(b=[...b,`⚠ ${k.line}`].slice(-sf),i(b)):k.type==="done"?(S=k.ok?"ok":"failed",u(S),ny(),Bn("skills"),a({ok:k.ok??!1,code:k.code??null,lines:b})):k.type==="error"&&k.error&&(b=[...b,`✘ ${k.error}`].slice(-sf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(C){if(C.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,C instanceof Error?C.message:String(C)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const x=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",h=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${x}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>f(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:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(RR,{}):h}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-primary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
122
- `)})]})}function RR(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const AR=3e3,LR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function kv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function MR(){const{toast:t}=ac(),a=m.useRef(new Map),s=m.useCallback(i=>{if(!kv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<AR)return;a.current.set(i.provider,c);const d=LR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return m.useEffect(()=>{function i(c){const u=c.detail;!u||!kv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const bb="vskill.studio.prefs";function jb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Sb(){const t=jb();if(!t)return{};try{const a=t.getItem(bb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function zR(t,a){const s=jb();if(s)try{const c={...Sb(),[t]:a};s.setItem(bb,JSON.stringify(c))}catch{}}function DR(t,a){const i=Sb()[t];return i===void 0?a:i}const wv={open:!1,x:0,y:0,skill:null};function _R(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ha(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function OR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function BR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ha(se.toasts.permissionDenied,"error");return}Ha(se.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ha(se.actions.editPlaceholder,"info");return;case"run-benchmark":Ha(se.toasts.benchmarkQueued,"info");return;case"duplicate":Ha(se.toasts.skillDuplicated,"info");return;case"update":Ha(se.toasts.skillUpdated,"info");return;case"uninstall":Ha(se.actions.editPlaceholder,"info");return;case"delete":OR(a);return;default:return}}function IR(t){return t.startsWith("#/create")}function $R(t){return t.startsWith("#/updates")}function kb(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function UR(){return kb(IR)}function HR(){return kb($R)}function PR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function VR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function FR(){const[t,a]=m.useState("⌘⇧K");m.useEffect(()=>{a(PR())},[]);const s=VR();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const GR=m.lazy(()=>Vl(()=>import("./FindSkillsPalette-DSW-Zyl_.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),WR=m.lazy(()=>Vl(()=>import("./SkillDetailPanel-CPhEDst2.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),qR=m.lazy(()=>Vl(()=>import("./CreateSkillPage-B9MwTYPn.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),YR=m.lazy(()=>Vl(()=>Promise.resolve().then(()=>qN),void 0).then(t=>({default:t.UpdatesPanel})));function KR(){return r.jsx(qS,{children:r.jsx(FS,{children:r.jsxs(G2,{children:[r.jsx(XR,{}),r.jsx(OT,{})]})})})}function XR(){var jr,rn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:f}=Ya(),{resolvedTheme:x,setTheme:h}=ty(),{toast:y}=ac(),[v,b]=m.useState(()=>wC()),[S]=m.useState(!0),[C,E]=m.useState(!1),[w,N]=m.useState(!1),[T,A]=m.useState(()=>typeof window>"u"?"overview":Nf(window.location.search).tab),[I,L]=m.useState(()=>{if(typeof window>"u")return"";const ae=Nf(window.location.search);return ae.mode?ae.mode:ae.view?ae.view:xb(ae.tab,window.location.search)}),H=m.useCallback(ae=>{A(Se=>(Se!==ae&&L(Xs(ae)),ae))},[]);m.useEffect(()=>{if(typeof window>"u")return;const ae=()=>{const Se=new URLSearchParams(window.location.search),Ne=Se.get("tab"),Bt=Se.get("panel"),St=Jo(Ne)??Jo(Bt);if(!St)return;const Jt=new URLSearchParams(window.location.search);Jt.delete("panel"),Jt.delete("sub"),St.tab==="overview"?Jt.delete("tab"):Jt.set("tab",St.tab),Jt.delete("mode"),Jt.delete("view"),St.mode&&Jt.set("mode",St.mode),St.view&&Jt.set("view",St.view);const Vr=Jt.toString(),dr=`${window.location.pathname}${Vr?"?"+Vr:""}${window.location.hash}`,Qe=`${window.location.pathname}${window.location.search}${window.location.hash}`;dr!==Qe&&window.history.replaceState(null,"",dr),A(St.tab),St.mode?L(St.mode):St.view?L(St.view):L(Xs(St.tab))};return ae(),window.addEventListener("popstate",ae),()=>window.removeEventListener("popstate",ae)},[]),m.useEffect(()=>{if(typeof window>"u")return;const ae=new URLSearchParams(window.location.search);ae.delete("panel"),ae.delete("sub"),T==="overview"?ae.delete("tab"):ae.set("tab",T),ae.delete("mode"),ae.delete("view"),!(I===Xs(T))&&I&&(T==="run"?ae.set("mode",I):T==="history"&&ae.set("view",I));const Ne=ae.toString(),Bt=`${window.location.pathname}${Ne?"?"+Ne:""}${window.location.hash}`,St=`${window.location.pathname}${window.location.search}${window.location.hash}`;Bt!==St&&window.history.replaceState(null,"",Bt)},[T,I]);const[k,O]=m.useState(wv),z=m.useCallback((ae,Se)=>{O(_R(ae,Se))},[]),_=uR(),[$,q]=m.useState(()=>DR("activeAgent",null)),K=m.useCallback(ae=>{q(ae),zR("activeAgent",ae),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ae}}))},[]);m.useEffect(()=>{var ae;!$&&((ae=_.response)!=null&&ae.suggested)&&K(_.response.suggested)},[$,(jr=_.response)==null?void 0:jr.suggested,K]);const Q=m.useMemo(()=>_.response?aR(_.response):[],[_.response]),{workspace:U,switchProject:M,addProject:B,removeProject:F,activeProject:te}=xR(),[V,D]=m.useState(!1),[W,X]=m.useState(!1),[ee,de]=m.useState("standalone"),le=m.useCallback((ae="standalone")=>{de(ae),X(!0)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;le((Ne==null?void 0:Ne.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ae),()=>window.removeEventListener("studio:request-create-skill",ae)},[le]);const[ce,ne]=m.useState(!1),[ge,Le]=m.useState(null),[Ee,Me]=m.useState(null);m.useEffect(()=>{function ae(){ne(!0)}return window.addEventListener("studio:open-marketplace",ae),()=>window.removeEventListener("studio:open-marketplace",ae)},[]);const Pe=m.useMemo(()=>{const ae=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&ae.add(Se.pluginName);return ae},[t.skills]);yf([{key:"p",meta:!0,handler:ae=>{var Ne;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Ne=ae==null?void 0:ae.preventDefault)==null||Ne.call(ae),D(Bt=>!Bt))}}],{enabled:!0});const ie=KT(),fe=ie.open;m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.provider&&fe(Ne.provider)}return window.addEventListener("studio:open-setup-drawer",ae),()=>window.removeEventListener("studio:open-setup-drawer",ae)},[fe]);const he=m.useCallback(()=>{O(wv)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.message&&y({message:Ne.message,severity:Ne.severity??"info"})}return window.addEventListener("studio:toast",ae),()=>window.removeEventListener("studio:toast",ae)},[y]),MR();const[be,je]=m.useState(!1),[Ge,ut]=m.useState(void 0);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;ut(Ne==null?void 0:Ne.provider),je(!0)}return window.addEventListener("studio:open-settings",ae),()=>window.removeEventListener("studio:open-settings",ae)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${v}px`)},[v]),m.useEffect(()=>{function ae(){i()}return window.addEventListener("studio:content-saved",ae),()=>window.removeEventListener("studio:content-saved",ae)},[i]);const[gt,Ht]=m.useState(null),[Tt,qe]=m.useState(()=>new Set),zt=m.useRef(!1),kt=m.useMemo(()=>Zw(),[]),vt=m.useCallback(ae=>`${ae.plugin}/${ae.skill}`,[]),Zt=m.useCallback(ae=>{qe(Se=>{const Ne=new Set(Se);return Ne.add(vt(ae)),Ne})},[vt]),ve=m.useCallback(ae=>{qe(Se=>{const Ne=new Set(Se);return Ne.delete(vt(ae)),Ne})},[vt]),rt=vv({delayMs:1e4,onCommit:ae=>{i(),ve(ae)},onFailure:(ae,Se)=>{ve(ae),y({message:`Couldn't delete ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:se.actions.retry,onInvoke:()=>{Zt(ae),rt.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.skill&&Ht(Ne.skill)}return window.addEventListener("studio:request-delete",ae),()=>window.removeEventListener("studio:request-delete",ae)},[]);const[it,bt]=m.useState(null),Mt=vv({delayMs:250,apiCall:(ae,Se)=>api.uninstallSkill(ae,Se),onCommit:ae=>{i(),ve(ae)},onFailure:(ae,Se)=>{ve(ae),y({message:`Couldn't uninstall ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:se.actions.retry,onInvoke:()=>{Zt(ae),Mt.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.skill&&bt(Ne.skill)}return window.addEventListener("studio:request-uninstall",ae),()=>window.removeEventListener("studio:request-uninstall",ae)},[]);const et=m.useCallback(()=>{const ae=it;if(bt(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};Zt(Se),Mt.enqueueDelete(Se),y({message:`Uninstalled ${ae.skill}. Sent to your ${kt}.`,severity:"info",durationMs:4e3})},[it,Zt,Mt,y,kt]),bn=m.useCallback(()=>{bt(null)},[]),qt=m.useCallback(()=>{const ae=gt;if(Ht(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};Zt(Se),rt.enqueueDelete(Se);const Ne=zt.current?"":`Sent to your ${kt}. Open Trash to restore. `;zt.current=!0,y({message:`${Ne}Deleted ${ae.skill}`,severity:"info",durationMs:1e4,action:{label:se.actions.undo,onInvoke:()=>{rt.cancelDelete(vt(Se)),ve(Se)}}})},[gt,Zt,ve,rt,y,kt,vt]),mn=m.useCallback(()=>{Ht(null)},[]),un=m.useMemo(()=>t.skills.filter(ae=>!Tt.has(vt(ae))),[t.skills,Tt,vt]),ur=MC(un,(te==null?void 0:te.path)??null),Nn=m.useMemo(()=>t.selectedSkill?t.skills.find(ae=>ae.plugin===t.selectedSkill.plugin&&ae.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Un=m.useCallback(ae=>{a({plugin:ae.plugin,skill:ae.skill,origin:ae.origin})},[a]),Tn=m.useMemo(()=>{if(!t.selectedSkill)return"";const ae=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ae})`},[t.selectedSkill]),[jt,Oe]=m.useState(null);yf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>E(ae=>!ae)},{key:"cmd+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(ae=>!ae)},{key:"ctrl+b",handler:()=>N(ae=>!ae)},{key:"e",handler:()=>y({message:se.actions.editPlaceholder,severity:"info"})}]);const Ye=UR(),hn=HR()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(YR,{})}):Ye?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(qR,{})}):r.jsx(TT,{selectedSkillInfo:Nn,activeDetailTab:T,onDetailTabChange:H,activeDetailSub:I,onDetailSubChange:L,allSkills:t.skills,onSelectSkill:Un});return r.jsxs(r.Fragment,{children:[r.jsx(YS,{sidebarWidth:v,sidebarHidden:w||t.isMobile&&t.mobileView==="detail",banner:r.jsx(zC,{connected:S}),liveMessage:Tn,topRail:r.jsx(K2,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>le("standalone"),projectPickerSlot:U&&U.projects.length>0?r.jsx(gR,{workspace:U,onSwitch:M,onAdd:B,onRemove:F}):void 0,findSkillsSlot:r.jsx(FR,{})}),sidebar:r.jsx(mC,{skills:un,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Un,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:$,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:ur,onSkillsChanged:i,topSlot:_.status==="ready"&&Q.length>0?r.jsxs(r.Fragment,{children:[r.jsx(lR,{agents:Q,activeAgentId:$,onActiveAgentChange:K,onOpenSetup:ae=>ie.open(ae)}),r.jsx(cR,{activeAgentId:$})]}):null}),resizeHandle:r.jsx(EC,{initialWidth:v??Ks,onChange:b}),main:hn,statusBar:r.jsx(sk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(rn=f==null?void 0:f.providers)==null?void 0:rn.map(ae=>{const Se=ae.id;return{id:Se,label:ae.label,available:ae.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(IT,{open:C,onClose:()=>E(!1)}),r.jsx(VT,{open:ie.isOpen,providerKey:ie.providerKey,onClose:ie.close}),r.jsx(UT,{state:k,onClose:he,onAction:(ae,Se)=>BR(ae,Se)}),r.jsx(m.Suspense,{fallback:null,children:r.jsx(GR,{onSelect:ae=>{const Se=ae.name.split("/");Se.length===3&&Oe({owner:Se[0],repo:Se[1],slug:Se[2],displayName:ae.displayName??ae.name})}})}),jt&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(WR,{selectedSkill:jt,onClose:()=>Oe(null)})}),r.jsx(yR,{open:V,projects:(U==null?void 0:U.projects)??[],onSwitch:ae=>{M(ae)},onClose:()=>D(!1)}),r.jsx(bR,{open:W,onClose:()=>X(!1),initialMode:ee,isClaudeCode:$==="claude-code",projectRoot:(te==null?void 0:te.path)??(f==null?void 0:f.projectName)??"",onCreated:ae=>{i(),setTimeout(()=>{u(ae.pluginName??"",ae.skillName)},500)}}),r.jsx(wR,{open:ce,onClose:()=>ne(!1),installedNames:Pe,onInstall:(ae,Se)=>{Le({plugin:ae,marketplace:Se,ref:`${ae}@${Se}`}),ne(!1)},onUninstall:async ae=>{if(await new Promise(Ne=>{Me({plugin:ae,resolve:Ne})}))try{const Ne=await fetch(`/api/plugins/${encodeURIComponent(ae)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Bt=await Ne.json().catch(()=>({}));if(!Ne.ok||!Bt.ok){y({message:Bt.error??`Uninstall failed (${Ne.status})`,severity:"error"});return}const St=Bt.fallback==="orphan-cache-removed"?`Removed orphaned ${ae}.`:`Uninstalled ${ae}.`;y({message:St,severity:"success"}),i()}catch(Ne){y({message:Ne instanceof Error?Ne.message:String(Ne),severity:"error"})}}}),r.jsx(Qv,{open:be,onClose:()=>je(!1),initialProvider:Ge,onToast:ae=>y({message:ae,severity:"info"})}),r.jsx(TR,{job:ge,onDone:ae=>{ae.ok&&(i(),setTimeout(()=>Le(null),3e3))}}),r.jsx(Fo,{open:gt!==null,title:gt?`Delete "${gt.skill}"?`:"",body:`It will be sent to your ${kt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:qt,onCancel:mn}),r.jsx(Fo,{open:it!==null,title:it?`Uninstall "${it.skill}"?`:"",body:`It will be sent to your ${kt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:et,onCancel:bn}),r.jsx(Fo,{open:Ee!==null,title:Ee?`Uninstall ${Ee.plugin}?`:"",body:Ee?`This removes the ${Ee.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ee==null||Ee.resolve(!0),Me(null)},onCancel:()=>{Ee==null||Ee.resolve(!1),Me(null)}})]})}const Cv="vskill.migrations.scope-rename.v1",QR={own:"authoring-project",installed:"available-project",global:"available-personal"},ZR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function JR(t){if(t.getItem(Cv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(ZR);if(!c)continue;const[,u,d]=c,f=QR[d];if(!f)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${f}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Cv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{JR(window.localStorage)}catch{}H0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(oS,{children:r.jsx(tk,{children:r.jsx(KR,{})})})}));export{fc as E,Fv as L,di as P,Re as R,VN as S,t4 as T,Vl as _,cr as a,Sb as b,UN as c,uc as d,ac as e,ke as f,DR as g,ib as h,r as j,m as r,Zo as t,Ya as u,zR as w};
121
+ }`})]}),document.body)}function ZT({agent:t,focused:a,active:s,onClick:i}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:i,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function JT({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function eR({agent:t}){const a=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function tR({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":se.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":rR(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(_o,{label:se.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(_o,{label:se.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(_o,{label:se.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(_o,{label:se.scopePicker.statsLastSync,value:t.lastSync?nR(t.lastSync):"—"})]}),r.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function _o({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function yv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function nR(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function rR(t){switch(t){case"ok":return se.scopePicker.statsHealthOk;case"stale":return se.scopePicker.statsHealthStale;case"missing":return se.scopePicker.statsHealthMissing}}function aR(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function lR({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=m.useState(!1),[d,f]=m.useState(null),x=m.useRef(null),h=m.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=m.useMemo(()=>h?h.health==="ok"?"var(--color-ok, #22c55e)":h.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[h]),v=m.useCallback(()=>{var S;u(!1),(S=x.current)==null||S.focus()},[]),b=m.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(h==null?void 0:h.displayName)??"Select agent"}),r.jsxs("span",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(h==null?void 0:h.installedCount)??0," · ",(h==null?void 0:h.globalCount)??0," · ",(h==null?void 0:h.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(QT,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:f,onSwitch:b,onOpenSetup:S=>{i(S),v()},onClose:v})]})}const vb="vskill-ccode-banner-dismissed",sR=new Set(["claude-cli","claude-code"]);function iR(){try{return sessionStorage.getItem(vb)==="true"}catch{return!1}}function oR(){try{sessionStorage.setItem(vb,"true")}catch{}}function cR({activeAgentId:t}){const[a,s]=m.useState(()=>iR()),i=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{oR(),s(!0)},[]);return!t||!sR.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[se.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:se.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function uR(){const[t,a]=m.useState(null),[s,i]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const f=await ke.getAgents();a(f),i("ready"),u(null)}catch(f){i("error"),u(f.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const f=()=>void d();return window.addEventListener("studio:agent-changed",f),()=>window.removeEventListener("studio:agent-changed",f)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Oo="workspace",dR=["skills","agents"];async function fR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function pR(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function mR(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function hR(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function rf(){for(const t of dR)Bn(t)}function xR(){const{data:t,loading:a,error:s,revalidate:i}=qa(Oo,fR),c=t,u=c==null?void 0:c.projects.find(h=>h.id===c.activeProjectId),d=m.useCallback(async h=>{await pR(h),Bn(Oo),rf()},[]),f=m.useCallback(async h=>{await mR(h),Bn(Oo),rf()},[]),x=m.useCallback(async h=>{await hR(h),Bn(Oo),rf()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:f,removeProject:x,revalidate:i}}function gR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=m.useState(!1),[f,x]=m.useState(!1),[h,y]=m.useState(""),[v,b]=m.useState(null),[S,C]=m.useState(null),[E,w]=m.useState(null),[N,T]=m.useState(!1),A=m.useRef(null),I=(t==null?void 0:t.projects)??[],L=I.find(z=>z.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function z(_){A.current&&!A.current.contains(_.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[u]);async function H(){b(null);const z=h.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(""),x(!1)}catch(_){const $=_ instanceof Error?_.message:String(_);/does not exist/i.test($)?b(`Path not found on disk: ${z}`):/Duplicate/i.test($)?b("That project is already registered."):b($)}}async function k(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const z=await window.showDirectoryPicker();y(z.name),x(!0)}catch{}else x(!0)}function O(z){if(z.length<=50)return z;const _=z.split("/");return _.length<=4?z:`${_.slice(0,3).join("/")}/…/${_.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(z=>!z),"aria-expanded":u,"aria-haspopup":"menu",title:(L==null?void 0:L.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(L==null?void 0:L.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L?L.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[I.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),I.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:I.map(z=>{const _=c?c(z.path):!1,$=z.id===(t==null?void 0:t.activeProjectId),q=S===z.id;return r.jsxs("li",{role:"menuitem","data-stale":_?"true":"false",onMouseEnter:()=>C(z.id),onMouseLeave:()=>C(K=>K===z.id?null:K),onClick:()=>{if(!_){if($){d(!1);return}w(z)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:_?"not-allowed":"pointer",background:q&&!_?"var(--surface-2, rgba(0,0,0,0.04))":$?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:_?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:z.colorDot,boxShadow:$?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:$?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),$&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:z.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(z.path)}),_&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${z.name}`,onClick:K=>{K.stopPropagation(),i(z.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:K=>{K.currentTarget.style.color="var(--color-error, #b91c1c)",K.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:K=>{K.currentTarget.style.color="var(--text-tertiary)",K.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},z.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:f?8:6},children:[!f&&r.jsxs("button",{type:"button",onClick:()=>void k(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:z=>{z.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:z=>{z.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),f&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:h,onChange:z=>y(z.target.value),onKeyDown:z=>{z.key==="Enter"&&H(),z.key==="Escape"&&(x(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{x(!1),b(null),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"}),r.jsx("button",{type:"button",onClick:()=>void H(),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&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>w(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:z=>z.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${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"}),r.jsx("button",{type:"button",onClick:()=>w(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function vR(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function yR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=m.useState(""),[d,f]=m.useState(0),x=m.useMemo(()=>vR(a,c),[a,c]);m.useEffect(()=>{t||(u(""),f(0))},[t]),m.useEffect(()=>{d>=x.length&&f(0)},[x.length,d]);const h=y=>{if(y.key==="Escape"){y.preventDefault(),i();return}if(y.key==="ArrowDown"){y.preventDefault(),f(v=>Math.min(v+1,Math.max(x.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),f(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=x[d];v&&(s(v.id),i())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:i}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:h,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.map((y,v)=>r.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:()=>f(v),onClick:()=>{s(y.id),i()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const bv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function bR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,f]=m.useState("destination"),[x,h]=m.useState(s),[y,v]=m.useState(""),[b,S]=m.useState(""),[C,E]=m.useState(""),[w,N]=m.useState([]),[T,A]=m.useState(!1),[I,L]=m.useState(null);if(m.useEffect(()=>{t&&(f("destination"),h(s),v(""),S(""),E(""),L(null))},[t,s]),m.useEffect(()=>{if(!t)return;let U=!0;return fetch("/api/authoring/plugins").then(M=>M.json()).then(M=>{U&&N(M.plugins??[])}).catch(()=>{}),()=>{U=!1}},[t]),m.useEffect(()=>{if(!t)return;function U(M){M.key==="Escape"&&(M.preventDefault(),a())}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[t,a]),!t)return null;const H=w.length>0,k=i&&H,O=i,z=bv.test(y),_=x==="existing-plugin"?b.length>0:bv.test(b),$=!T&&z&&(x==="standalone"||_),q=jR(c,x,b,y);async function K(){L(null),A(!0);try{const B=new URLSearchParams;B.set("mode",x),B.set("skillName",y),b&&B.set("pluginName",b);const F=await fetch(`/api/authoring/skill-exists?${B.toString()}`),te=await F.json();if(!F.ok){L(te.error??`Check failed: ${F.status}`);return}if(te.exists){L(`Skill '${y}' already exists${te.path?` at ${te.path}`:""}`);return}}catch(B){L(B instanceof Error?B.message:String(B));return}finally{A(!1)}const U=new URLSearchParams;U.set("mode",x),U.set("skillName",y),C.trim()&&U.set("description",C.trim()),b&&U.set("pluginName",b);const M=`#/create?${U.toString()}`;typeof window<"u"&&(window.location.hash=M),a()}async function Q(){L(null),A(!0);try{const U=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:y,description:C.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),M=await U.json();if(!U.ok||!M.ok){L(M.error??`Create failed: ${U.status}`);return}Bn("skills"),u==null||u({mode:x,skillName:y,pluginName:M.pluginName??null,skillMdPath:M.skillMdPath}),a()}catch(U){L(U instanceof Error?U.message:String(U))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(af,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>h("standalone")}),r.jsx(af,{title:"Add to existing plugin",subtitle:k?`${w.length} plugin source${w.length===1?"":"s"} in this project`:i?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!k,selected:x==="existing-plugin",onClick:()=>k&&h("existing-plugin")}),r.jsx(af,{title:"Plugin (multi-skill)",subtitle:O?"Bundle related skills under one Claude Code plugin":"Claude Code only",description:"Creates <folder>/.claude-plugin/plugin.json and <folder>/skills/<first>/SKILL.md.",icon:"📦",disabled:!O,selected:x==="new-plugin",onClick:()=>O&&h("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(Bo,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:U=>S(U.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:Io(!b||_)})}),x==="existing-plugin"&&r.jsx(Bo,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:U=>S(U.target.value),style:{...Io(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),w.map(U=>r.jsx("option",{value:U.name,children:U.name},U.path))]})}),r.jsx(Bo,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:U=>v(U.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:Io(!y||z)})}),r.jsx(Bo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:C,onChange:U=>E(U.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Io(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map((U,M)=>r.jsx("div",{children:U},M))]}),I&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:I})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:lf,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>f("details"),style:jv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>f("destination"),style:lf,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void K(),disabled:!$,style:{...lf,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void Q(),disabled:!$,style:{...jv,opacity:$?1:.5,cursor:$?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function af({title:t,subtitle:a,description:s,icon:i,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:i}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function Bo({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function Io(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 jv={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"},lf={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 jR(t,a,s,i){const c=i||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function yb(t){return t.trim().toLowerCase()}function SR(t,a){const s=yb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function kR(t,a){const s=yb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function wR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=m.useState(null),[f,x]=m.useState([]),[h,y]=m.useState(null),[v,b]=m.useState(null),[S,C]=m.useState(!1),[E,w]=m.useState(null),[N,T]=m.useState(""),[A,I]=m.useState("");m.useEffect(()=>{h?T(""):I("")},[h]);const L=m.useMemo(()=>SR(f,N),[f,N]),H=m.useMemo(()=>kR((v==null?void 0:v.plugins)??[],A),[v,A]);return m.useEffect(()=>{t&&(C(!0),w(null),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);x(k.marketplaces??[])}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>C(!1)))},[t]),m.useEffect(()=>{if(!h){b(null);return}C(!0),w(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(h)}`).then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);b(k)}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>C(!1))},[h]),m.useEffect(()=>{if(!t)return;function k(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[h&&r.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"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:h?(v==null?void 0:v.name)??h:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!h&&!S&&f.length===0&&!E&&r.jsx(CR,{}),!h&&f.length>0&&r.jsx(Sv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!h&&f.length>0&&L.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!h&&L.map(k=>r.jsxs("button",{type:"button",onClick:()=>y(k.name),style:NR,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:k.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.source})]},k.name)),h&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(Sv,{value:A,onChange:I,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&H.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),H.map(k=>{const O=c.has(k.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[k.name,k.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:k.version}),k.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:k.category})]}),k.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:k.description})]}),O&&i?r.jsx("button",{type:"button",disabled:u===k.name,onClick:async()=>{d(k.name);try{await i(k.name)}finally{d(null)}},"aria-label":`Uninstall ${k.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===k.name?"wait":"pointer",opacity:u===k.name?.6:1,fontFamily:"inherit"},children:u===k.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(k.name,h),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"})]})},k.name)})]})]}),!h&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(ER,{onAdded:()=>{Bn("marketplaces"),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>x(k.marketplaces??[]))}})})]})]}):null}function Sv({value:t,onChange:a,placeholder:s,ariaLabel:i,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":i,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function CR(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function ER({onAdded:t}){const[a,s]=m.useState(""),[i,c]=m.useState(!1),[u,d]=m.useState(null);async function f(){const x=a.trim();if(x){c(!0),d(null);try{const h=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),y=await h.json().catch(()=>({}));if(!h.ok||!y.ok){d(y.error??`Add failed (${h.status})`);return}s(""),t()}catch(h){d(h instanceof Error?h.message:String(h))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&f()},placeholder:"anthropics/claude-plugins-official",disabled:i,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void f(),disabled:i||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:i||!a.trim()?"not-allowed":"pointer",opacity:i||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const NR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},sf=12;function TR({job:t,onDone:a}){const[s,i]=m.useState([]),[c,u]=m.useState("running"),[d,f]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;i([]),u("running"),f(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const C=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!C.ok||!C.body){u("failed"),a({ok:!1,code:C.status,lines:[`HTTP ${C.status}`]});return}const E=C.body.getReader(),w=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=w.decode(T,{stream:!0});const I=N.split(/\n\n/);N=I.pop()??"";for(const L of I){const H=L.match(/^data:\s*(.*)$/m);if(H)try{const k=JSON.parse(H[1]);k.type==="stdout"&&k.line?(b=[...b,k.line].slice(-sf),i(b)):k.type==="stderr"&&k.line?(b=[...b,`⚠ ${k.line}`].slice(-sf),i(b)):k.type==="done"?(S=k.ok?"ok":"failed",u(S),ny(),Bn("skills"),a({ok:k.ok??!1,code:k.code??null,lines:b})):k.type==="error"&&k.error&&(b=[...b,`✘ ${k.error}`].slice(-sf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(C){if(C.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,C instanceof Error?C.message:String(C)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const x=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",h=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${x}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>f(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:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(RR,{}):h}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-primary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
122
+ `)})]})}function RR(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const AR=3e3,LR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function kv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function MR(){const{toast:t}=ac(),a=m.useRef(new Map),s=m.useCallback(i=>{if(!kv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<AR)return;a.current.set(i.provider,c);const d=LR[i.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:i.provider}}))}}})},[t]);return m.useEffect(()=>{function i(c){const u=c.detail;!u||!kv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const bb="vskill.studio.prefs";function jb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Sb(){const t=jb();if(!t)return{};try{const a=t.getItem(bb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function zR(t,a){const s=jb();if(s)try{const c={...Sb(),[t]:a};s.setItem(bb,JSON.stringify(c))}catch{}}function DR(t,a){const i=Sb()[t];return i===void 0?a:i}const wv={open:!1,x:0,y:0,skill:null};function _R(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ha(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function OR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function BR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ha(se.toasts.permissionDenied,"error");return}Ha(se.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ha(se.actions.editPlaceholder,"info");return;case"run-benchmark":Ha(se.toasts.benchmarkQueued,"info");return;case"duplicate":Ha(se.toasts.skillDuplicated,"info");return;case"update":Ha(se.toasts.skillUpdated,"info");return;case"uninstall":Ha(se.actions.editPlaceholder,"info");return;case"delete":OR(a);return;default:return}}function IR(t){return t.startsWith("#/create")}function $R(t){return t.startsWith("#/updates")}function kb(t){const[a,s]=m.useState(()=>typeof window<"u"&&t(window.location.hash));return m.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function UR(){return kb(IR)}function HR(){return kb($R)}function PR(){var i,c;if(typeof navigator>"u")return"⌘⇧K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function VR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function FR(){const[t,a]=m.useState("⌘⇧K");m.useEffect(()=>{a(PR())},[]);const s=VR();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const GR=m.lazy(()=>Vl(()=>import("./FindSkillsPalette-BBj-hoqE.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),WR=m.lazy(()=>Vl(()=>import("./SkillDetailPanel-Xymi4aZg.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),qR=m.lazy(()=>Vl(()=>import("./CreateSkillPage-D9ZsmNub.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),YR=m.lazy(()=>Vl(()=>Promise.resolve().then(()=>qN),void 0).then(t=>({default:t.UpdatesPanel})));function KR(){return r.jsx(qS,{children:r.jsx(FS,{children:r.jsxs(G2,{children:[r.jsx(XR,{}),r.jsx(OT,{})]})})})}function XR(){var jr,rn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:f}=Ya(),{resolvedTheme:x,setTheme:h}=ty(),{toast:y}=ac(),[v,b]=m.useState(()=>wC()),[S]=m.useState(!0),[C,E]=m.useState(!1),[w,N]=m.useState(!1),[T,A]=m.useState(()=>typeof window>"u"?"overview":Nf(window.location.search).tab),[I,L]=m.useState(()=>{if(typeof window>"u")return"";const ae=Nf(window.location.search);return ae.mode?ae.mode:ae.view?ae.view:xb(ae.tab,window.location.search)}),H=m.useCallback(ae=>{A(Se=>(Se!==ae&&L(Xs(ae)),ae))},[]);m.useEffect(()=>{if(typeof window>"u")return;const ae=()=>{const Se=new URLSearchParams(window.location.search),Ne=Se.get("tab"),Bt=Se.get("panel"),St=Jo(Ne)??Jo(Bt);if(!St)return;const Jt=new URLSearchParams(window.location.search);Jt.delete("panel"),Jt.delete("sub"),St.tab==="overview"?Jt.delete("tab"):Jt.set("tab",St.tab),Jt.delete("mode"),Jt.delete("view"),St.mode&&Jt.set("mode",St.mode),St.view&&Jt.set("view",St.view);const Vr=Jt.toString(),dr=`${window.location.pathname}${Vr?"?"+Vr:""}${window.location.hash}`,Qe=`${window.location.pathname}${window.location.search}${window.location.hash}`;dr!==Qe&&window.history.replaceState(null,"",dr),A(St.tab),St.mode?L(St.mode):St.view?L(St.view):L(Xs(St.tab))};return ae(),window.addEventListener("popstate",ae),()=>window.removeEventListener("popstate",ae)},[]),m.useEffect(()=>{if(typeof window>"u")return;const ae=new URLSearchParams(window.location.search);ae.delete("panel"),ae.delete("sub"),T==="overview"?ae.delete("tab"):ae.set("tab",T),ae.delete("mode"),ae.delete("view"),!(I===Xs(T))&&I&&(T==="run"?ae.set("mode",I):T==="history"&&ae.set("view",I));const Ne=ae.toString(),Bt=`${window.location.pathname}${Ne?"?"+Ne:""}${window.location.hash}`,St=`${window.location.pathname}${window.location.search}${window.location.hash}`;Bt!==St&&window.history.replaceState(null,"",Bt)},[T,I]);const[k,O]=m.useState(wv),z=m.useCallback((ae,Se)=>{O(_R(ae,Se))},[]),_=uR(),[$,q]=m.useState(()=>DR("activeAgent",null)),K=m.useCallback(ae=>{q(ae),zR("activeAgent",ae),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ae}}))},[]);m.useEffect(()=>{var ae;!$&&((ae=_.response)!=null&&ae.suggested)&&K(_.response.suggested)},[$,(jr=_.response)==null?void 0:jr.suggested,K]);const Q=m.useMemo(()=>_.response?aR(_.response):[],[_.response]),{workspace:U,switchProject:M,addProject:B,removeProject:F,activeProject:te}=xR(),[V,D]=m.useState(!1),[W,X]=m.useState(!1),[ee,de]=m.useState("standalone"),le=m.useCallback((ae="standalone")=>{de(ae),X(!0)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;le((Ne==null?void 0:Ne.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ae),()=>window.removeEventListener("studio:request-create-skill",ae)},[le]);const[ce,ne]=m.useState(!1),[ge,Le]=m.useState(null),[Ee,Me]=m.useState(null);m.useEffect(()=>{function ae(){ne(!0)}return window.addEventListener("studio:open-marketplace",ae),()=>window.removeEventListener("studio:open-marketplace",ae)},[]);const Pe=m.useMemo(()=>{const ae=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&ae.add(Se.pluginName);return ae},[t.skills]);yf([{key:"p",meta:!0,handler:ae=>{var Ne;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Ne=ae==null?void 0:ae.preventDefault)==null||Ne.call(ae),D(Bt=>!Bt))}}],{enabled:!0});const ie=KT(),fe=ie.open;m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.provider&&fe(Ne.provider)}return window.addEventListener("studio:open-setup-drawer",ae),()=>window.removeEventListener("studio:open-setup-drawer",ae)},[fe]);const he=m.useCallback(()=>{O(wv)},[]);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.message&&y({message:Ne.message,severity:Ne.severity??"info"})}return window.addEventListener("studio:toast",ae),()=>window.removeEventListener("studio:toast",ae)},[y]),MR();const[be,je]=m.useState(!1),[Ge,ut]=m.useState(void 0);m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;ut(Ne==null?void 0:Ne.provider),je(!0)}return window.addEventListener("studio:open-settings",ae),()=>window.removeEventListener("studio:open-settings",ae)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${v}px`)},[v]),m.useEffect(()=>{function ae(){i()}return window.addEventListener("studio:content-saved",ae),()=>window.removeEventListener("studio:content-saved",ae)},[i]);const[gt,Ht]=m.useState(null),[Tt,qe]=m.useState(()=>new Set),zt=m.useRef(!1),kt=m.useMemo(()=>Zw(),[]),vt=m.useCallback(ae=>`${ae.plugin}/${ae.skill}`,[]),Zt=m.useCallback(ae=>{qe(Se=>{const Ne=new Set(Se);return Ne.add(vt(ae)),Ne})},[vt]),ve=m.useCallback(ae=>{qe(Se=>{const Ne=new Set(Se);return Ne.delete(vt(ae)),Ne})},[vt]),rt=vv({delayMs:1e4,onCommit:ae=>{i(),ve(ae)},onFailure:(ae,Se)=>{ve(ae),y({message:`Couldn't delete ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:se.actions.retry,onInvoke:()=>{Zt(ae),rt.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.skill&&Ht(Ne.skill)}return window.addEventListener("studio:request-delete",ae),()=>window.removeEventListener("studio:request-delete",ae)},[]);const[it,bt]=m.useState(null),Mt=vv({delayMs:250,apiCall:(ae,Se)=>api.uninstallSkill(ae,Se),onCommit:ae=>{i(),ve(ae)},onFailure:(ae,Se)=>{ve(ae),y({message:`Couldn't uninstall ${ae.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:se.actions.retry,onInvoke:()=>{Zt(ae),Mt.enqueueDelete(ae)}}})}});m.useEffect(()=>{function ae(Se){if(!(Se instanceof CustomEvent))return;const Ne=Se.detail;Ne!=null&&Ne.skill&&bt(Ne.skill)}return window.addEventListener("studio:request-uninstall",ae),()=>window.removeEventListener("studio:request-uninstall",ae)},[]);const et=m.useCallback(()=>{const ae=it;if(bt(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};Zt(Se),Mt.enqueueDelete(Se),y({message:`Uninstalled ${ae.skill}. Sent to your ${kt}.`,severity:"info",durationMs:4e3})},[it,Zt,Mt,y,kt]),bn=m.useCallback(()=>{bt(null)},[]),qt=m.useCallback(()=>{const ae=gt;if(Ht(null),!ae)return;const Se={plugin:ae.plugin,skill:ae.skill};Zt(Se),rt.enqueueDelete(Se);const Ne=zt.current?"":`Sent to your ${kt}. Open Trash to restore. `;zt.current=!0,y({message:`${Ne}Deleted ${ae.skill}`,severity:"info",durationMs:1e4,action:{label:se.actions.undo,onInvoke:()=>{rt.cancelDelete(vt(Se)),ve(Se)}}})},[gt,Zt,ve,rt,y,kt,vt]),mn=m.useCallback(()=>{Ht(null)},[]),un=m.useMemo(()=>t.skills.filter(ae=>!Tt.has(vt(ae))),[t.skills,Tt,vt]),ur=MC(un,(te==null?void 0:te.path)??null),Nn=m.useMemo(()=>t.selectedSkill?t.skills.find(ae=>ae.plugin===t.selectedSkill.plugin&&ae.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Un=m.useCallback(ae=>{a({plugin:ae.plugin,skill:ae.skill,origin:ae.origin})},[a]),Tn=m.useMemo(()=>{if(!t.selectedSkill)return"";const ae=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ae})`},[t.selectedSkill]),[jt,Oe]=m.useState(null);yf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>E(ae=>!ae)},{key:"cmd+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>h(x==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(ae=>!ae)},{key:"ctrl+b",handler:()=>N(ae=>!ae)},{key:"e",handler:()=>y({message:se.actions.editPlaceholder,severity:"info"})}]);const Ye=UR(),hn=HR()?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(YR,{})}):Ye?r.jsx(m.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(qR,{})}):r.jsx(TT,{selectedSkillInfo:Nn,activeDetailTab:T,onDetailTabChange:H,activeDetailSub:I,onDetailSubChange:L,allSkills:t.skills,onSelectSkill:Un});return r.jsxs(r.Fragment,{children:[r.jsx(YS,{sidebarWidth:v,sidebarHidden:w||t.isMobile&&t.mobileView==="detail",banner:r.jsx(zC,{connected:S}),liveMessage:Tn,topRail:r.jsx(K2,{projectName:(f==null?void 0:f.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>le("standalone"),projectPickerSlot:U&&U.projects.length>0?r.jsx(gR,{workspace:U,onSwitch:M,onAdd:B,onRemove:F}):void 0,findSkillsSlot:r.jsx(FR,{})}),sidebar:r.jsx(mC,{skills:un,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Un,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:z,outdatedByOrigin:c,activeAgentId:$,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:ur,onSkillsChanged:i,topSlot:_.status==="ready"&&Q.length>0?r.jsxs(r.Fragment,{children:[r.jsx(lR,{agents:Q,activeAgentId:$,onActiveAgentChange:K,onOpenSetup:ae=>ie.open(ae)}),r.jsx(cR,{activeAgentId:$})]}):null}),resizeHandle:r.jsx(EC,{initialWidth:v??Ks,onChange:b}),main:hn,statusBar:r.jsx(sk,{projectPath:(f==null?void 0:f.root)??null,modelName:(f==null?void 0:f.model)??null,health:f!=null&&f.error?"degraded":"ok",providers:(rn=f==null?void 0:f.providers)==null?void 0:rn.map(ae=>{const Se=ae.id;return{id:Se,label:ae.label,available:ae.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(IT,{open:C,onClose:()=>E(!1)}),r.jsx(VT,{open:ie.isOpen,providerKey:ie.providerKey,onClose:ie.close}),r.jsx(UT,{state:k,onClose:he,onAction:(ae,Se)=>BR(ae,Se)}),r.jsx(m.Suspense,{fallback:null,children:r.jsx(GR,{onSelect:ae=>{const Se=ae.name.split("/");Se.length===3&&Oe({owner:Se[0],repo:Se[1],slug:Se[2],displayName:ae.displayName??ae.name})}})}),jt&&r.jsx(m.Suspense,{fallback:null,children:r.jsx(WR,{selectedSkill:jt,onClose:()=>Oe(null)})}),r.jsx(yR,{open:V,projects:(U==null?void 0:U.projects)??[],onSwitch:ae=>{M(ae)},onClose:()=>D(!1)}),r.jsx(bR,{open:W,onClose:()=>X(!1),initialMode:ee,isClaudeCode:$==="claude-code",projectRoot:(te==null?void 0:te.path)??(f==null?void 0:f.projectName)??"",onCreated:ae=>{i(),setTimeout(()=>{u(ae.pluginName??"",ae.skillName)},500)}}),r.jsx(wR,{open:ce,onClose:()=>ne(!1),installedNames:Pe,onInstall:(ae,Se)=>{Le({plugin:ae,marketplace:Se,ref:`${ae}@${Se}`}),ne(!1)},onUninstall:async ae=>{if(await new Promise(Ne=>{Me({plugin:ae,resolve:Ne})}))try{const Ne=await fetch(`/api/plugins/${encodeURIComponent(ae)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Bt=await Ne.json().catch(()=>({}));if(!Ne.ok||!Bt.ok){y({message:Bt.error??`Uninstall failed (${Ne.status})`,severity:"error"});return}const St=Bt.fallback==="orphan-cache-removed"?`Removed orphaned ${ae}.`:`Uninstalled ${ae}.`;y({message:St,severity:"success"}),i()}catch(Ne){y({message:Ne instanceof Error?Ne.message:String(Ne),severity:"error"})}}}),r.jsx(Qv,{open:be,onClose:()=>je(!1),initialProvider:Ge,onToast:ae=>y({message:ae,severity:"info"})}),r.jsx(TR,{job:ge,onDone:ae=>{ae.ok&&(i(),setTimeout(()=>Le(null),3e3))}}),r.jsx(Fo,{open:gt!==null,title:gt?`Delete "${gt.skill}"?`:"",body:`It will be sent to your ${kt}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:qt,onCancel:mn}),r.jsx(Fo,{open:it!==null,title:it?`Uninstall "${it.skill}"?`:"",body:`It will be sent to your ${kt} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:et,onCancel:bn}),r.jsx(Fo,{open:Ee!==null,title:Ee?`Uninstall ${Ee.plugin}?`:"",body:Ee?`This removes the ${Ee.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{Ee==null||Ee.resolve(!0),Me(null)},onCancel:()=>{Ee==null||Ee.resolve(!1),Me(null)}})]})}const Cv="vskill.migrations.scope-rename.v1",QR={own:"authoring-project",installed:"available-project",global:"available-personal"},ZR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function JR(t){if(t.getItem(Cv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(ZR);if(!c)continue;const[,u,d]=c,f=QR[d];if(!f)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${f}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Cv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{JR(window.localStorage)}catch{}H0.createRoot(document.getElementById("root")).render(r.jsx(m.StrictMode,{children:r.jsx(oS,{children:r.jsx(tk,{children:r.jsx(KR,{})})})}));export{fc as E,Fv as L,di as P,Re as R,VN as S,t4 as T,Vl as _,cr as a,Sb as b,UN as c,uc as d,ac as e,ke as f,DR as g,ib as h,r as j,m as r,Zo as t,Ya as u,zR as w};