vskill 0.5.108 → 0.5.109

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-QP4FPm7W.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-mzfSdGtx.js","assets/CreateSkillPage-CjeJOSY4.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-Bwk3qR7G.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-3xE9OCOe.js","assets/CreateSkillPage-BEdLsGoc.js"])))=>i.map(i=>d[i]);
2
2
  /* empty css */(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function nv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var sd={exports:{}},ws={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -62,7 +62,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
62
62
  `);d=b.pop()??"";for(const k of b)if(k.startsWith("event: "))h=k.slice(7).trim();else if(k.startsWith("data: ")){let S={};try{S=JSON.parse(k.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const w={type:h,...S};r==null||r(w),w.type==="done"&&(g=w),w.type==="error"&&(p=w)}h=""}}if(p){const y=new Ls(p.message,500);throw y.code=p.code,y}if(!g)throw new Ls("Transfer stream ended without 'done' event",500);return g}function Gj(t,r){if(!r.length)return t;const s=new Map;for(const o of r){const c=o.name.split("/").pop()||o.name;s.set(c,o)}return t.map(o=>{const c=s.get(o.skill);if(!c)return o;const u={...o,updateAvailable:c.updateAvailable,currentVersion:c.installed,latestVersion:c.latest??void 0};return typeof c.trackedForUpdates=="boolean"&&(u.trackedForUpdates=c.trackedForUpdates),u})}function Wj(t){const[r,s]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return m.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),r}const qj=500,Gd="vskill.updates.seenLastId";function Yj(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Gd)}catch{return null}}function gd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Gd):window.localStorage.setItem(Gd,t)}catch{}}function Kj(){let t=new Map;const r=new Set,s=new Set,o=[];let c=Yj();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(r))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>qj){const g=o.shift();g&&s.delete(g)}c=h,gd(h)}}return{getSnapshot(){return t},subscribe(h){return r.add(h),()=>{r.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,gd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,gd(null),u()}}}const Rr=Kj(),Xj=3e5,Qj=500,Zj=15e3,Jj=6e4,eS=6e4,tS="/api/v1/skills/stream";function $x(t){const r=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;r.set(o,s)}return r}function Vx(t){let r=0;for(const s of t)s.updateAvailable&&r++;return r}function nS(t){if(!t||typeof t!="object")return!1;const r=t;return r.type==="skill.updated"&&typeof r.eventId=="string"&&typeof r.skillId=="string"&&typeof r.version=="string"}function aS(t){const r=(t==null?void 0:t.intervalMs)??Xj,s=(t==null?void 0:t.debounceMs)??Qj,o=(t==null?void 0:t.timeoutMs)??Zj,c=(t==null?void 0:t.staleAfterMs)??Jj,u=(t==null?void 0:t.disconnectFallbackMs)??eS,d=(t==null?void 0:t.streamUrlBase)??tS,h=m.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=m.useMemo(()=>{const _=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return _.length===0?"":[..._].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[p,y]=m.useState([]),[v,b]=m.useState(()=>new Map),[k,S]=m.useState(0),[w,C]=m.useState(!1),[T,N]=m.useState(null),[M,H]=m.useState(null),L=m.useRef(null),F=m.useRef(null),E=m.useRef(null),O=m.useRef(null),R=m.useRef(!0),[D,I]=m.useState(()=>h?"connecting":"fallback"),q=m.useRef(D);q.current=D;const X=m.useSyncExternalStore(_=>Rr.subscribe(_),()=>Rr.getSnapshot(),()=>Rr.getSnapshot()),Y=X.size,U=m.useCallback(async()=>{C(!0);const _=new AbortController,P=setTimeout(()=>_.abort(),o);try{const ee=await Promise.race([Ee.getSkillUpdates(),new Promise((re,xe)=>{_.signal.addEventListener("abort",()=>{xe(new Error("TIMEOUT"))})})]);if(ee==="TIMEOUT")throw new Error("TIMEOUT");if(!R.current)return;y(ee),b($x(ee)),S(Vx(ee)),F.current=Date.now(),N(F.current),H(null)}catch(ee){if(!R.current)return;H(ee instanceof Error?ee:new Error(String(ee)))}finally{clearTimeout(P),R.current&&C(!1)}},[o]),z=m.useCallback(()=>{if(L.current)return L.current;const _=U().finally(()=>{L.current=null});return L.current=_,_},[U]),B=m.useCallback(()=>{E.current==null&&(E.current=setInterval(()=>{z()},r))},[r,z]),V=m.useCallback(()=>{E.current!=null&&(clearInterval(E.current),E.current=null)},[]);m.useEffect(()=>{R.current=!0,(F.current==null||Date.now()-F.current>c)&&z(),(typeof document>"u"||document.visibilityState!=="hidden")&&B();const ee=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){V();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&z(),B()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",ee),()=>{R.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",ee),O.current&&clearTimeout(O.current),V()}},[]);const W=m.useCallback(async _=>{if(_.length!==0)try{const P=await Ee.checkSkillUpdates(_);if(!R.current||P.length===0)return;const ee=Date.now(),re=P.filter(ce=>ce.skillId&&ce.eventId&&ce.version).map(ce=>({skillId:ce.skillId,version:ce.version,eventId:ce.eventId,publishedAt:ce.publishedAt,diffSummary:ce.diffSummary,receivedAt:ee}));re.length>0&&Rr.mergeBulk(re);const xe=P.filter(ce=>typeof ce.trackedForUpdates=="boolean"||typeof ce.updateAvailable=="boolean").map(ce=>({name:ce.name??ce.skillId,installed:ce.installed??"",latest:ce.latest??null,updateAvailable:ce.updateAvailable??!1,trackedForUpdates:typeof ce.trackedForUpdates=="boolean"?ce.trackedForUpdates:void 0}));xe.length>0&&y(ce=>{const ye=new Map;for(const Re of ce)ye.set(Re.name.split("/").pop()||Re.name,Re);let ue=0;for(const Re of xe){const Le=Re.name.split("/").pop()||Re.name,ae=ye.get(Le);if(ae){const fe={...ae};ae.trackedForUpdates===void 0&&Re.trackedForUpdates!==void 0&&(fe.trackedForUpdates=Re.trackedForUpdates),ye.set(Le,fe)}else ye.set(Le,{name:Re.name,installed:Re.installed??"",latest:Re.latest??null,updateAvailable:Re.updateAvailable??!1,trackedForUpdates:Re.trackedForUpdates}),ue+=1}if(ue===0&&ye.size===ce.length)return ce;const je=[...ye.values()];return b($x(je)),S(Vx(je)),je})}catch{}},[]);m.useEffect(()=>{const _=h||g;if(!_){I("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){I("fallback");return}I("connecting");const P=_.split(","),ee=`${d}?skills=${encodeURIComponent(_)}`;let re=null,xe=null,ce=null;const ye=()=>{xe==null&&(xe=setTimeout(()=>{xe=null,R.current&&q.current!=="connected"&&I("fallback")},u))},ue=()=>{xe!=null&&(clearTimeout(xe),xe=null)};ye();const je=1e3,Re=()=>{R.current&&ce==null&&(ce=setTimeout(()=>{if(ce=null,!!R.current&&!(re&&re.readyState!==EventSource.CLOSED)){if(re)try{re.close()}catch{}fe()}},je))},Le=me=>{if(!R.current)return;let he;try{he=JSON.parse(me.data)}catch{return}if(!nS(he)||Rr.ingest(he)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${he.skillId} updated to ${he.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:he.skillId,version:he.version,eventId:he.eventId}}))}},ae=()=>{R.current&&(Rr.clearSeen(),W(P))},fe=()=>{R.current&&(re=new EventSource(ee),re.onopen=()=>{R.current&&(ue(),I("connected"))},re.onerror=()=>{R.current&&(ye(),re&&re.readyState===EventSource.CLOSED&&Re())},re.onmessage=Le,re.addEventListener("gone",ae))};return fe(),()=>{if(ue(),ce!=null&&(clearTimeout(ce),ce=null),re){try{re.removeEventListener("gone",ae)}catch{}try{re.close()}catch{}}}},[h,g,d,u,W]),m.useEffect(()=>{if(!g)return;const _=g.split(",");W(_)},[g,W]);const de=m.useCallback(_=>{Rr.dismiss(_)},[]);return{updates:p,updatesMap:v,updateCount:k,isRefreshing:w,lastFetchAt:T,error:M,refresh:z,updatesById:X,pushUpdateCount:Y,status:D,dismiss:de}}const rS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function lS(t,r){switch(r.type){case"SELECT_SKILL":return{...t,selectedSkill:r.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:r.mode,selectedSkill:r.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:r.query};case"SET_SKILLS":return{...t,skills:r.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:r.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:r.loading};case"SET_MOBILE":return{...t,isMobile:r.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:r.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:r.skill,revealSkillId:`${r.skill.plugin}/${r.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Sv=m.createContext(null),kv=Sv;function Zn(){const t=m.useContext(kv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function sS({children:t}){const[r,s]=m.useReducer(lS,rS),o=Wj("(max-width: 767px)");m.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=m.useState(()=>{try{const D=window.localStorage.getItem("vskill.studio.prefs");if(!D)return null;const I=JSON.parse(D);return typeof I.activeAgent=="string"?I.activeAgent:null}catch{return null}});m.useEffect(()=>{function D(I){if(!(I instanceof CustomEvent))return;const q=I.detail;q!=null&&q.agentId&&u(q.agentId)}return window.addEventListener("studio:agent-changed",D),()=>window.removeEventListener("studio:agent-changed",D)},[]);const d=m.useCallback(()=>{s({type:"SET_SKILLS_LOADING",loading:!0});const D=c?{agent:c}:void 0;Ee.getSkills(D).then(I=>{s({type:"SET_SKILLS",skills:I});const X=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(X){const[,Y,U]=X,z=I.find(B=>B.plugin===Y&&B.skill===U);z&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:U,origin:z.origin}})}}).catch(I=>s({type:"SET_SKILLS_ERROR",error:I.message}))},[c]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(D=>{s({type:"SELECT_SKILL",skill:D}),window.location.hash=`/skills/${D.plugin}/${D.skill}`},[]),g=m.useRef(r.skills);m.useEffect(()=>{g.current=r.skills},[r.skills]);const p=m.useCallback((D,I)=>{const q=g.current,X=D?q.find(z=>z.plugin===D&&z.skill===I):q.find(z=>z.skill===I&&z.source!=="plugin");if(!D&&!X){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${I}" not yet in state — skipping reveal`);return}const Y=(X==null?void 0:X.plugin)??D,U=(X==null?void 0:X.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:I,origin:U}}),window.location.hash=`/skills/${Y}/${I}`},[]),y=m.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),v=m.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),b=m.useCallback(D=>{s({type:"SET_MODE",mode:D})},[]),k=m.useCallback(D=>{s({type:"SET_SEARCH",query:D})},[]),S=m.useCallback(D=>{s({type:"SET_MOBILE_VIEW",view:D})},[]),w=m.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),C=m.useMemo(()=>{const D=[];for(const I of r.skills)I.origin==="installed"&&D.push(`${I.plugin}/${I.skill}`);return D},[r.skills]),T=m.useMemo(()=>r.skills.map(D=>`${D.plugin}/${D.skill}`),[r.skills]),N=aS({skillIds:C,trackingSkillIds:T}),M=m.useMemo(()=>{const D=r.skills.map(I=>{if(!I.updateAvailable&&I.latestVersion===void 0&&I.trackedForUpdates===void 0)return I;const q={...I};return delete q.updateAvailable,delete q.currentVersion,delete q.latestVersion,delete q.trackedForUpdates,q});return Gj(D,N.updates)},[r.skills,N.updates]),H=m.useMemo(()=>{const D={source:0,installed:0};for(const I of M)I.updateAvailable&&(D[I.origin]+=1);return D},[M]),L=m.useMemo(()=>({...r,skills:M}),[r,M]),F=N.updateCount,E=N.refresh,O=N.isRefreshing,R=m.useMemo(()=>({state:L,selectSkill:h,clearSelection:v,setMode:b,setSearch:k,setMobileView:S,refreshSkills:d,updateCount:F,dismissUpdateNotification:w,updates:N.updates,outdatedByOrigin:H,isRefreshingUpdates:O,refreshUpdates:E,revealSkill:p,clearReveal:y,updatesById:N.updatesById,pushUpdateCount:N.pushUpdateCount,updateStreamStatus:N.status,dismissPushUpdate:N.dismiss}),[L,h,v,b,k,S,d,F,w,N.updates,H,O,E,p,y,N.updatesById,N.pushUpdateCount,N.status,N.dismiss]);return a.jsx(kv.Provider,{value:R,children:t})}const iS={config:null,loading:!0};function oS(t,r){switch(r.type){case"SET_CONFIG":return{config:r.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const wv=m.createContext(null);function _r(){const t=m.useContext(wv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function cS({children:t}){const[r,s]=m.useReducer(oS,iS),o=m.useCallback(()=>{Ee.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);m.useEffect(()=>{o()},[o]);const c=m.useCallback(async(d,h)=>{const g=await Ee.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=m.useMemo(()=>({config:r.config,loading:r.loading,updateConfig:c,refreshConfig:o}),[r,c,o]);return a.jsx(wv.Provider,{value:u,children:t})}function uS({topRail:t,sidebar:r,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const p={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return a.jsxs("div",{className:"studio-shell",style:p,children:[u,a.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),a.jsxs("div",{style:y,children:[!g&&a.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:r}),!g&&c,a.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),a.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),a.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Px=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],dS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},fS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},pS={"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"},mS={"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 hS(t,r){var h,g;const s=dS[t.id]??null,o=fS[t.id]??null,c=s?!!((h=r==null?void 0:r.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=r==null?void 0:r.binaries)!=null&&g[o]):!0,d=t.models.map(p=>({id:p.id,displayName:p.label,billingMode:mS[t.id]??"per-token",...p.pricing?{pricing:p.pricing}:{},...p.resolvedId?{resolvedId:p.resolvedId}:{}}));return{id:t.id,displayName:xS(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:pS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function xS(t,r){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??r}function gS(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Px){const c=r.get(o);c&&s.push(c)}for(const o of t)Px.includes(o.id)||s.push(o);return s}function vS(t){const[r,s]=m.useState(null),[o,c]=m.useState("loading"),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null),y=m.useRef(0),v=m.useRef(t==null?void 0:t.onStaleCatalog),b=m.useRef(t==null?void 0:t.onSetActiveError);m.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const k=m.useCallback(async()=>{try{const N=await fetch("/api/config");if(!N.ok)throw new Error(`/api/config returned ${N.status}`);const M=await N.json(),H=gS((M.providers||[]).map(L=>hS(L,M.detection)));s({agents:H,activeAgent:M.provider??null,activeModel:M.model??null}),c("ready"),d(null)}catch(N){c("error"),d(N.message)}},[]);m.useEffect(()=>{k()},[k]);const S=m.useCallback(async()=>{var M;const N=Date.now();if(!(N-y.current<5*6e4))try{const H=await fetch("/api/openrouter/models");if(!H.ok){H.status!==400&&g(`OpenRouter catalog fetch failed (${H.status})`);return}const L=await H.json();y.current=N,g(null),s(O=>{if(!O)return O;const R=O.agents.map(D=>{if(D.id!=="openrouter")return D;const I=L.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...D,models:I,catalogAgeMs:L.ageSec?L.ageSec*1e3:0,cacheStale:!!L.stale}});return{...O,agents:R}});const F=L.ageSec??0;(L.stale===!0||F>600)&&((M=v.current)==null||M.call(v,"openrouter",F*1e3))}catch(H){g(`OpenRouter catalog unreachable: ${H.message}`)}},[]),w=m.useCallback(N=>{p.current=N,N==="openrouter"&&S()},[S]),C=m.useCallback(()=>{y.current=0,k()},[k]),T=m.useCallback(async(N,M)=>{var F,E;let H;try{H=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:N,model:M})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${N}: ${O.message}`);return}if(H.ok){s(O=>O&&{...O,activeAgent:N,activeModel:M});return}let L=`Failed to set ${N} (${H.status})`;try{const O=await H.json();O&&typeof O.error=="string"&&(L=O.error)}catch{}(E=b.current)==null||E.call(b,L)},[]);return{status:o,catalog:r,error:u,openRouterError:h,focusAgent:w,refresh:C,activeAgentId:(r==null?void 0:r.activeAgent)??null,activeModelId:(r==null?void 0:r.activeModel)??null,setActive:T}}function vd({variant:t,label:r,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return a.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":r,...c?{title:c}:{},children:r})}function Wd({unlocked:t=!1,size:r=10}){return t?a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):a.jsxs("svg",{width:r,height:r,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),a.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const yS={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <plugin> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,r)=>`${t} of ${r}`},bS={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"},jS={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"},SS={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"},kS={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"},wS={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"},CS={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."},ES={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},NS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},TS={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},RS={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"},AS={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)."}},MS={subscriptionBilling:"· subscription",free:"· free"},LS={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`},zS={providersLabel:"Providers",providerSummary:(t,r)=>`${t}/${r} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},DS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},_S={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.`},OS={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"},BS={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."},IS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},HS={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"}},te={sidebar:yS,shell:bS,detail:jS,actions:SS,palette:kS,shortcuts:wS,toasts:CS,connection:ES,forms:NS,errors:TS,picker:RS,providers:AS,models:MS,settings:LS,statusBar:zS,scopePicker:DS,scopeSection:_S,claudeCodeLabel:OS,setupDrawer:BS,setupProviders:HS,scopeLabels:IS},US=new Set(["claude-cli","claude-code"]);function Fx(t){return US.has(t)}const Gx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function $S({agents:t,activeAgentId:r,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Gx.has(g.id)),h=t.filter(g=>!Gx.has(g.id));return a.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>a.jsx(Wx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&a.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>a.jsx(Wx,{agent:g,isActive:g.id===r,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Wx({agent:t,isActive:r,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=te,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},p=Fx(t.id),y={minHeight:36,height:p?"auto":36,padding:p?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:r?500:400,color:"var(--text-primary)"};return r&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),a.jsxs("div",{role:"option","aria-selected":r,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&a.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&a.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),a.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Fx(t.id)&&a.jsx("span",{"data-testid":"claude-code-billing-label",title:te.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:te.claudeCodeLabel.compactLabel})]}),a.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?a.jsx(Wd,{unlocked:!0,size:10}):a.jsx(Wd,{size:10})}),r&&a.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:te.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&a.jsx(vd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&a.jsx(vd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&a.jsx(vd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&a.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function VS(t,r,s,o){const d=t>=80,h=m.useRef(null),[g,p]=m.useState(0),y=m.useCallback(k=>{p(k.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=m.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const k=Math.max(0,Math.floor(g/r)-4),S=Math.ceil(s/r)+8,w=Math.min(t,k+S);return{visibleStart:k,visibleEnd:w}},[d,g,r,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*r,offsetTop:v*r,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Cv=44,PS=352,FS=60,qx=480;function GS(t){var u,d;const r=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return r?`${r} ctx ${te.models.subscriptionBilling}`:te.models.subscriptionBilling.trim();if(t.billingMode==="free")return r?`local · ${r} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return r?`${r} ctx · ${c}`:c}function WS(t,r){if(!r)return t;const s=r.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function qS({agent:t,activeModelId:r,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=m.useState(""),[h,g]=m.useState(""),p=m.useRef(null);if(m.useEffect(()=>{const b=setTimeout(()=>g(u),FS);return()=>clearTimeout(b)},[u]),m.useEffect(()=>{t.id==="openrouter"&&t.available&&p.current&&p.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return a.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:qx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[a.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:te.providers.openrouter.emptyCardBody}),a.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:te.providers.openrouter.addKeyCta})]});const y=m.useMemo(()=>WS(t.models,h),[t.models,h]),v=VS(y.length,Cv,PS);return a.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:qx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&a.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:a.jsx("input",{ref:p,type:"text",placeholder:te.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":te.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?a.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[a.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:te.picker.noMatches(h)}),a.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:te.picker.clearSearch})]}):y.length===0?a.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:te.picker.noModelsYet}):a.jsx("div",{...v.containerProps,children:a.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:a.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,k)=>{const S=v.visibleStart+k;return a.jsx(KS,{model:b,isActive:b.id===r,isFocused:s===S,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function YS(t,r,s){return r&&r.toLowerCase().includes(t.toLowerCase())?r:s??null}function KS({model:t,isActive:r,isFocused:s,onSelect:o,resolvedModel:c}){const u=GS(t),d=YS(t.id,c,t.resolvedId),h=d!==null,g=r?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",p=r?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return a.jsxs("button",{type:"button",role:"option","aria-selected":r,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Cv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:p,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[a.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&a.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Yx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function XS(){const[t,r]=m.useState(null),[s,o]=m.useState(!0),[c,u]=m.useState(null),d=m.useCallback(async()=>{o(!0);try{const p=await fetch("/api/settings/keys");if(!p.ok)throw new Error(`GET /api/settings/keys returned ${p.status}`);const y=await p.json();r({...Yx,...y}),u(null)}catch(p){u(p.message),r(Yx)}finally{o(!1)}},[]);m.useEffect(()=>{d()},[d]);const h=m.useCallback(async(p,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:p,key:y})});if(!v.ok){const k=await v.json().catch(()=>({error:v.statusText}));throw new Error(k.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=m.useCallback(async p=>{const y=await fetch(`/api/settings/keys/${p}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${p} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function QS({onMigrated:t,fetchImpl:r}){const[s,o]=m.useState({kind:"loading"}),c=r??globalThis.fetch,u=m.useCallback(async()=>{var p;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((p=v.darwinKeys)==null?void 0:p.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);m.useEffect(()=>{u()},[u]);const d=m.useCallback(async()=>{o({kind:"working"});try{const p=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!p.ok){o({kind:"error",message:`Migration failed (${p.status})`});return}const y=await p.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(p){o({kind:"error",message:p.message})}},[c,u,t]),h=m.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return a.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsx("span",{style:{flex:1},children:s.message}),a.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:yd,children:"Retry"})]});const g=s.kind==="working";return a.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),a.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),a.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...yd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),a.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...yd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const yd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},ZS=[{id:"anthropic",name:te.providers.anthropic.name,keyIssuanceUrl:te.providers.anthropic.keyIssuanceUrl,prefix:te.providers.anthropic.keyPrefix,placeholder:`Paste ${te.providers.anthropic.name} key`},{id:"openai",name:te.providers.openai.name,keyIssuanceUrl:te.providers.openai.keyIssuanceUrl,prefix:te.providers.openai.keyPrefix,placeholder:te.providers.openai.pastePlaceholder},{id:"openrouter",name:te.providers.openrouter.name,keyIssuanceUrl:te.providers.openrouter.keyIssuanceUrl,prefix:te.providers.openrouter.keyPrefix,placeholder:`Paste ${te.providers.openrouter.name} key`}];function JS(t){const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?`${Math.round(r/6e4)}m ago`:r<864e5?`${Math.round(r/36e5)}h ago`:new Date(t).toLocaleString()}function Ev({open:t,onClose:r,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=XS(),g=m.useRef(null),p=m.useRef(null),[y,v]=m.useState(null);m.useEffect(()=>{if(!t)return;let k=!1;return(async()=>{try{const S=await fetch("/api/settings/storage-path");if(!S.ok)throw new Error(`GET /api/settings/storage-path returned ${S.status}`);const w=await S.json();k||v(w.path??null)}catch{k||v(null)}})(),()=>{k=!0}},[t]),m.useEffect(()=>{if(!t)return;const k=document.activeElement,S=setTimeout(()=>{var T;const w=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(T=g.current)==null?void 0:T.querySelector(w);C==null||C.focus()},0);return()=>{var w;clearTimeout(S),(w=k==null?void 0:k.focus)==null||w.call(k)}},[t,s]),m.useEffect(()=>{if(!t)return;const k=S=>{if(S.key==="Escape"){S.preventDefault(),r();return}if(S.key==="Tab"&&g.current){const w=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(w.length===0)return;const C=w[0],T=w[w.length-1];S.shiftKey&&document.activeElement===C?(S.preventDefault(),T.focus()):!S.shiftKey&&document.activeElement===T&&(S.preventDefault(),C.focus())}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[t,r]);const b=m.useCallback(async()=>{var k,S;if(y)try{await((S=(k=navigator.clipboard)==null?void 0:k.writeText)==null?void 0:S.call(k,y)),o==null||o(te.settings.pathCopied)}catch{}},[o,y]);return t?a.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:k=>{k.target===k.currentTarget&&r()},children:a.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:k=>k.stopPropagation(),children:[a.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:te.settings.title}),a.jsx(QS,{onMigrated:()=>{h()}}),a.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:te.settings.banner}),a.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[a.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:te.settings.sectionApiKeys}),ZS.map(k=>a.jsx(e2,{providerId:k.id,providerName:k.name,keyIssuanceUrl:k.keyIssuanceUrl,prefix:k.prefix,placeholder:k.placeholder,metadata:c==null?void 0:c[k.id],onSave:async S=>{const w=await u(k.id,S);return o==null||o(te.settings.keySaved(k.name)),w},onRemove:async()=>{await d(k.id),o==null||o(te.settings.keyRemoved(k.name))},inputRef:k.id===(s??"anthropic")?p:void 0},k.id))]}),a.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[a.jsx("span",{style:{flex:1},children:y?te.settings.storagePath(y):te.settings.storagePathFallback}),a.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Mr,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:te.settings.copyPath})]}),a.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:a.jsx("button",{type:"button",onClick:r,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function e2({providerId:t,providerName:r,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[p,y]=m.useState(""),[v,b]=m.useState(!1),[k,S]=m.useState(!1),[w,C]=m.useState(!1),[T,N]=m.useState(null),M=p.trim(),H=M.length===0,L=M.length>0&&!M.startsWith(o),F=m.useCallback(async()=>{if(H)return;S(!0);const R=M;y("");try{const D=await d(R);D.warning?N(D.warning):N(null)}finally{S(!1)}},[H,d,M]),E=m.useCallback(async()=>{var R;try{if(!((R=navigator.clipboard)!=null&&R.readText))return;const D=await navigator.clipboard.readText();y(D)}catch{}},[]),O=m.useCallback(async()=>{C(!1),await h()},[h]);return a.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsx("strong",{style:{fontSize:13},children:r}),a.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{ref:g,type:v?"text":"password",value:p,onChange:R=>{y(R.target.value),N(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),a.jsx("button",{type:"button",onClick:()=>b(!v),style:Mr,children:v?te.settings.hide:te.settings.show}),a.jsx("button",{type:"button",onClick:E,style:Mr,children:te.settings.paste})]}),L&&a.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:Kx,children:te.settings.prefixWarn(r)}),T&&a.jsx("div",{role:"status",style:Kx,children:T}),a.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[a.jsx("button",{type:"button",onClick:F,disabled:H||k,"data-testid":`save-${t}`,style:{...Mr,background:H?"var(--surface-2)":"var(--accent, var(--color-accent))",color:H?"var(--text-muted)":"white",cursor:H?"not-allowed":"pointer"},children:te.settings.save}),(u==null?void 0:u.stored)&&a.jsx(a.Fragment,{children:w?a.jsxs(a.Fragment,{children:[a.jsx("span",{style:{fontSize:12},children:te.settings.removeConfirm(r)}),a.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Mr,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),a.jsx("button",{type:"button",onClick:()=>C(!1),style:Mr,children:"Cancel"})]}):a.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Mr,color:"var(--text-muted)"},children:te.settings.remove})}),a.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?te.settings.keyStoredAt(JS(u.updatedAt)):te.settings.noKey})]})]})}const Mr={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},Kx={fontSize:11,color:"var(--warning, var(--text-muted))"};function t2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function n2({onToast:t}){const{status:r,catalog:s,focusAgent:o,setActive:c}=vS({onStaleCatalog:(D,I)=>{const q=Math.round(I/6e4);t==null||t(`Using cached ${D} catalog (${q} min old)`)},onSetActiveError:D=>t==null?void 0:t(D)}),[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(),[v,b]=m.useState(null),[k,S]=m.useState("agents"),[w,C]=m.useState(0),T=m.useRef(null);m.useRef(null),m.useEffect(()=>{var D;s&&!v&&b(s.activeAgent??((D=s.agents[0])==null?void 0:D.id)??null)},[s,v]);const N=(s==null?void 0:s.agents)??[],M=m.useMemo(()=>N.find(D=>D.id===v)??N[0],[N,v]);m.useEffect(()=>{C(0)},[v]);const H=m.useCallback(()=>{var D;d(!0),S("agents"),b((s==null?void 0:s.activeAgent)??((D=N[0])==null?void 0:D.id)??null),C(0)},[s,N]),L=m.useCallback(()=>{var D;d(!1),(D=T.current)==null||D.focus()},[]);m.useEffect(()=>{const D=I=>{var X;if(!(I.metaKey||I.ctrlKey)||I.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(I.preventDefault(),d(Y=>!Y))};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]),m.useEffect(()=>{if(!u)return;const D=q=>{if(q.key==="Escape"){q.preventDefault(),L();return}if(q.key==="ArrowDown"){q.preventDefault(),I(1);return}if(q.key==="ArrowUp"){q.preventDefault(),I(-1);return}if(q.key==="ArrowRight"&&k==="agents"){q.preventDefault(),S("models"),C(X=>{const Y=((M==null?void 0:M.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,Y)))});return}if(q.key==="ArrowLeft"&&k==="models"){q.preventDefault(),S("agents");return}if(q.key==="Enter"){if(q.preventDefault(),k==="agents"&&M)S("models"),C(0);else if(k==="models"&&M){const X=Math.max(0,Math.min(M.models.length-1,w)),Y=M.models[X];Y&&(c(M.id,Y.id),L())}return}};function I(q){if(k==="agents"){const X=N.findIndex(U=>U.id===v),Y=N[Math.max(0,Math.min(N.length-1,X+q))];Y&&(b(Y.id),o(Y.id));return}if(k==="models"&&M){const X=M.models.length;if(X===0)return;C(Y=>{const U=Y+q;return Math.max(0,Math.min(X-1,U))})}}return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[u,k,N,v,M,w,L,o,c]);const F=m.useCallback(D=>{y(D==="anthropic"||D==="openrouter"?D:void 0),g(!0),d(!1)},[]),E=N.find(D=>D.id===(s==null?void 0:s.activeAgent)),O=E==null?void 0:E.models.find(D=>D.id===(s==null?void 0:s.activeModel)),R=m.useMemo(()=>{if(r!=="ready"||!s)return"Loading…";const D=(E==null?void 0:E.displayName)??"Agent",I=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${D} · ${I}`},[r,s,E,O]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:T,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?L():H(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:E!=null&&E.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),a.jsx("span",{children:R})]}),u&&typeof document<"u"&&Bo.createPortal(a.jsxs(a2,{reducedMotion:t2(),onClickOutside:L,children:[a.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[a.jsx($S,{agents:N,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:D=>{b(D),o(D)},onSelect:D=>{b(D),o(D),S("models")},onOpenSettings:F}),M&&a.jsx(qS,{agent:M,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:k==="models"?w:-1,onSelect:D=>{c(M.id,D),L()},onOpenSettings:F})]}),a.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[a.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:te.picker.settingsButton}),a.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:te.picker.footerHint})]})]}),document.body),a.jsx(Ev,{open:h,onClose:()=>g(!1),initialProvider:p,onToast:t})]})}function a2({children:t,reducedMotion:r,onClickOutside:s}){const o=m.useRef(null);return m.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),a.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:r?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,a.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
63
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
64
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
- }`})]})}function Xx(){typeof window>"u"||(window.location.hash="#/")}function r2({onHome:t}){const[r,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Xx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Xx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const l2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",s2=m.lazy(()=>Io(()=>import("./UpdateDropdown-QP4FPm7W.js"),__vite__mapDeps([0,1])));function i2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=Zn(),d=m.useMemo(()=>{if(!u||u.size===0)return;const S=new Map;for(const[w,C]of u)C.diffSummary&&S.set(w,C.diffSummary);return S.size>0?S:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),k=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":k,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(S=>!S),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:l2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(m.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(s2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:S=>{const w=S.name.split("/"),C=w.length>=2?w[w.length-2]:w[0],T=w[w.length-1];c({plugin:C,skill:T,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function Qx(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function o2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(r2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(Zx,{segment:"origin",onClick:()=>Qx({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(Jx,{}),a.jsx(Zx,{segment:"plugin",onClick:()=>Qx({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(Jx,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(n2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(i2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function Zx({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function Jx(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Ho="vskill-theme";function Nv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function c2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function u2(t){try{const r=t.getItem(Ho);return Nv(r)}catch{return"auto"}}function d2(t,r){try{t.setItem(Ho,r)}catch{}}function f2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function p2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Tv=m.createContext(null);function m2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?u2(c):"auto"),[p,y]=m.useState(()=>p2(u)),v=m.useMemo(()=>c2(h,p),[h,p]);m.useEffect(()=>{d&&f2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const S=u("(prefers-color-scheme: dark)"),w=T=>y(T.matches);if(typeof S.addEventListener=="function")return S.addEventListener("change",w),()=>S.removeEventListener("change",w);const C=S;return C.addListener(w),()=>C.removeListener(w)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const S=w=>{w.key===Ho&&g(Nv(w.newValue))};return window.addEventListener("storage",S),()=>window.removeEventListener("storage",S)},[]),m.useEffect(()=>{if(!u||!d)return;let S;try{S=u("(prefers-contrast: more)")}catch{return}const w=N=>{N?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};w(S.matches);const C=N=>w(N.matches);if(typeof S.addEventListener=="function")return S.addEventListener("change",C),()=>S.removeEventListener("change",C);const T=S;return T.addListener(C),()=>T.removeListener(C)},[u,d]);const b=m.useCallback(S=>{g(S),c&&d2(c,S)},[c]),k=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Tv.Provider,{value:k,children:o})}function Rv(){const t=m.useContext(Tv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const eg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function h2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of eg){const c=r.get(o);c&&s.push(c)}for(const o of t)eg.includes(o.id)||s.push(o);return s}function x2(t){const[r,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function g2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=h2(t),c=x2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":te.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:te.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(tg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(tg,{p:g,onClick:h,compact:!0},g.id))})}function tg({p:t,onClick:r,compact:s}){const o=t.available?te.statusBar.unlocked(t.label):t.kind==="cli-install"?te.statusBar.lockedCli(t.label):te.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Wd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function v2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Ho)}catch{return null}}function y2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=Rv(),v=v2()==="auto",b=b2(h,g,v),k=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(ng,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(j2,{color:k}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(ng,{}),a.jsx(g2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(S2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function b2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function j2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function S2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ko=new Map,Lr=new Map,As=new Map;function on(t){ko.delete(t),Lr.delete(t);const r=As.get(t);if(r)for(const s of r)s()}function Ml(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>on(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(k=>k+1)};return As.has(t)||As.set(t,new Set),As.get(t).add(b),()=>{var k;(k=As.get(t))==null||k.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=ko.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Lr.has(t)){const C=Lr.get(t),T=()=>{d.current&&h.current===t&&u(N=>N+1)};C.subscribers.push(T);return}const S={promise:Promise.resolve(),subscribers:[]},w=r().then(C=>{ko.set(t,{data:C,fetchedAt:Date.now()}),Lr.delete(t),d.current&&h.current===t&&u(T=>T+1);for(const T of S.subscribers)T()},C=>{Lr.delete(t),d.current&&h.current===t&&u(T=>T+1);for(const T of S.subscribers)T();throw C});S.promise=w,Lr.set(t,S)},[t,r,o,c]);const p=ko.get(t),y=c&&!p&&Lr.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}const Uo=0,cr=1,Ll=2,Av=4;function ag(t){return()=>t}function k2(t){t()}function Mv(t,r){return s=>t(r(s))}function rg(t,r){return()=>t(r)}function w2(t,r){return s=>t(r,s)}function mf(t){return t!==void 0}function C2(...t){return()=>{t.map(k2)}}function zl(){}function $o(t,r){return r(t),t}function E2(t,r){return r(t)}function kt(...t){return t}function lt(t,r){return t(cr,r)}function Fe(t,r){t(Uo,r)}function hf(t){t(Ll)}function Et(t){return t(Av)}function Te(t,r){return lt(t,w2(r,Uo))}function Kn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function lg(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Lv(t,r){return t===r}function St(t=Lv){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function _e(t){return r=>s=>{t(s)&&r(s)}}function Se(t){return r=>Mv(r,t)}function ra(t){return r=>()=>{r(t)}}function pe(t,...r){const s=N2(...r);return((o,c)=>{switch(o){case Ll:hf(t);return;case cr:return lt(t,s(c))}})}function la(t,r){return s=>o=>{s(r=t(r,o))}}function Dr(t){return r=>s=>{t>0?t--:r(s)}}function Ra(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Ge(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;lt(u,g=>{const p=s;s|=h,r[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function N2(...t){return r=>t.reduceRight(E2,r)}function T2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=lt(t,u),r):(o(),zl);case Ll:o(),s=null;return}}}function ge(t){let r=t;const s=Qe();return((o,c)=>{switch(o){case Uo:r=c;break;case cr:{c(r);break}case Av:return r}return s(o,c)})}function tn(t,r){return $o(ge(r),s=>Te(t,s))}function Qe(){const t=[];return((r,s)=>{switch(r){case Uo:t.slice().forEach(o=>{o(s)});return;case Ll:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function En(t){return $o(Qe(),r=>Te(t,r))}function nt(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:R2(),singleton:s}}const R2=()=>Symbol();function A2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Bt(...t){const r=Qe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;lt(u,g=>{s[d]=g,o|=h,o===c&&Fe(r,s)})}),function(u,d){switch(u){case Ll:{hf(r);return}case cr:return o===c&&d(s),lt(r,d)}}}function De(t,r=Lv){return pe(t,St(r))}function qd(...t){return function(r,s){switch(r){case Ll:return;case cr:return C2(...t.map(o=>lt(o,s)))}}}const Ut={DEBUG:0,INFO:1,WARN:2,ERROR:3},M2={[Ut.DEBUG]:"debug",[Ut.ERROR]:"error",[Ut.INFO]:"log",[Ut.WARN]:"warn"},L2=()=>typeof globalThis>"u"?window:globalThis,ur=nt(()=>{const t=ge(Ut.ERROR);return{log:ge((r,s,o=Ut.INFO)=>{const c=L2().VIRTUOSO_LOG_LEVEL??Et(t);o>=c&&console[M2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function Or(t,r,s){return xf(t,r,s).callbackRef}function xf(t,r,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function z2(t,r,s,o,c,u,d,h,g){const p=Ne.useCallback(y=>{const v=D2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const k=b.lastElementChild.dataset.viewportType==="window";let S;k&&(S=b.ownerDocument.defaultView);const w=d?h?d.scrollLeft:d.scrollTop:k?h?S.scrollX||S.document.documentElement.scrollLeft:S.scrollY||S.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:k?h?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,T=d?h?d.offsetWidth:d.offsetHeight:k?h?S.innerWidth:S.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(w,0),viewportHeight:T}),u==null||u(h?sg("column-gap",getComputedStyle(y).columnGap,c):sg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return xf(p,s,g)}function D2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Ut.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function sg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Ut.WARN),r==="normal"?0:parseInt(r??"0",10)}function zv(t,r,s){const o=Ne.useRef(null),c=Ne.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(r){const k=r.getBoundingClientRect(),S=p.top-k.top;b=k.height-Math.max(0,S),v=S+r.scrollTop}else{const k=d.current.ownerDocument.defaultView;b=k.innerHeight-Math.max(0,p.top),v=p.top+k.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=xf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=nt(()=>{const t=Qe(),r=Qe(),s=ge(0),o=Qe(),c=ge(0),u=Qe(),d=Qe(),h=ge(0),g=ge(0),p=ge(0),y=ge(0),v=Qe(),b=Qe(),k=ge(!1),S=ge(!1),w=ge(!1);return Te(pe(t,Se(({scrollTop:C})=>C)),r),Te(pe(t,Se(({scrollHeight:C})=>C)),d),Te(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:S,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:k,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Bs={lvl:0};function Dv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ht(t){return t===Bs}function Is(t,r){if(!ht(t))return r===t.k?t.v:r<t.k?Is(t.l,r):Is(t.r,r)}function Qn(t,r,s="k"){if(ht(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Qn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Qn(t.l,r,s)}function Cn(t,r,s){return ht(t)?Bv(r,s,1):r===t.k?Ht(t,{k:r,v:s}):r<t.k?ig(Ht(t,{l:Cn(t.l,r,s)})):ig(Ht(t,{r:Cn(t.r,r,s)}))}function Cl(){return Bs}function El(t,r,s){if(ht(t))return[];const o=Qn(t,r)[0];return _2(Kd(t,o,s))}function Yd(t,r){if(ht(t))return Bs;const{k:s,l:o,r:c}=t;if(r===s){if(ht(o))return c;if(ht(c))return o;const[u,d]=Ov(o);return wo(Ht(t,{k:u,l:_v(o),v:d}))}return r<s?wo(Ht(t,{l:Yd(o,r)})):wo(Ht(t,{r:Yd(c,r)}))}function zr(t){return ht(t)?[]:[...zr(t.l),{k:t.k,v:t.v},...zr(t.r)]}function Kd(t,r,s){if(ht(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Kd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Kd(u,r,s))),h}function wo(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(bd(r))return Iv(Ht(t,{lvl:s-1}));if(!ht(r)&&!ht(r.r))return Ht(r.r,{l:Ht(r,{r:r.r.l}),lvl:s,r:Ht(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(bd(t))return Xd(Ht(t,{lvl:s-1}));if(!ht(o)&&!ht(o.l)){const c=o.l,u=bd(c)?o.lvl-1:o.lvl;return Ht(c,{l:Ht(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:Xd(Ht(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Ht(t,r){return Bv(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function _v(t){return ht(t.r)?t.l:wo(Ht(t,{r:_v(t.r)}))}function bd(t){return ht(t)||t.lvl>t.r.lvl}function Ov(t){return ht(t.r)?[t.k,t.v]:Ov(t.r)}function Bv(t,r,s,o=Bs,c=Bs){return{k:t,l:o,lvl:s,r:c,v:r}}function ig(t){return Xd(Iv(t))}function Iv(t){const{l:r}=t;return!ht(r)&&r.lvl===t.lvl?Ht(r,{r:Ht(t,{l:r.r})}):t}function Xd(t){const{lvl:r,r:s}=t;return!ht(s)&&!ht(s.r)&&s.lvl===r&&s.r.lvl===r?Ht(s,{l:Ht(t,{r:s.l}),lvl:r+1}):t}function _2(t){return Dv(t,({k:r,v:s})=>({index:r,value:s}))}function Hv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Hs(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const gf=nt(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Uv(t,r,s){return t[Ro(t,r,s)]}function Ro(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function O2(t,r,s,o){const c=Ro(t,r,o),u=Ro(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Vo(t){return!ht(t.groupOffsetTree)}function vf({index:t},r){return r===t?0:r<t?-1:1}function B2(){return{groupIndices:[],groupOffsetTree:Cl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Cl()}}function I2(t,r){let s=ht(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ht(t)){t=Cn(t,0,u);continue}const h=El(t,d-1,c+1);if(h.some(G2(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Yd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=Cn(t,c+1,b));p&&(t=Cn(t,d,u))}return[t,s]}function H2(t){return typeof t.groupIndex<"u"}function U2({offset:t},r){return r===t?0:r<t?-1:1}function Us(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Uv(r,t,vf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function $v(t,r){if(!Vo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Vv(t,r,s){if(H2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=$v(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function $2(t,r,s,o=0){return o>0&&(r=Math.max(r,Uv(t,o,vf).offset)),Dv(O2(t,r,s,U2),F2)}function V2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Ut.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ht(u)&&r.length===2){const b=r[0].size,k=r[1].size;d=s.reduce((S,w)=>Cn(Cn(S,w,b),w+1,k),d)}else[d,h]=I2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=Qd(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,k)=>Cn(b,k,Us(k,v,c)),Cl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function P2(t){return zr(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function og(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function Qd(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Ro(c,r-1,vf),h=c[g].offset;const p=Qn(s,r-1);u=p[0],d=p[1],c.length&&c[g].size===Qn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of El(s,r,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function F2(t){return{index:t.index,value:t}}function G2(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const W2={offsetHeight:"height",offsetWidth:"width"},ia=nt(([{log:t},{recalcInProgress:r}])=>{const s=Qe(),o=Qe(),c=tn(o,0),u=Qe(),d=Qe(),h=ge(0),g=ge([]),p=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),k=ge((E,O)=>ir(E,W2[O])),S=ge(void 0),w=ge(0),C=B2(),T=tn(pe(s,Ge(g,t,w),la(V2,C),St()),C),N=tn(pe(g,St(),la((E,O)=>({current:O,prev:E.current}),{current:[],prev:[]}),Se(({prev:E})=>E)),[]);Te(pe(g,_e(E=>E.length>0),Ge(T,w),Se(([E,O,R])=>{const D=E.reduce((I,q,X)=>Cn(I,q,Us(q,O.offsetTree,R)||X),Cl());return{...O,groupIndices:E,groupOffsetTree:D}})),T),Te(pe(o,Ge(T),_e(([E,{lastIndex:O}])=>E<O),Se(([E,{lastIndex:O,lastSize:R}])=>[{endIndex:O,size:R,startIndex:E}])),s),Te(p,y);const M=tn(pe(p,Se(E=>E===void 0)),!0);Te(pe(y,_e(E=>E!==void 0&&ht(Et(T).sizeTree)),Se(E=>{const O=Et(v),R=Et(g).length>0;return O!==void 0&&O!==0?R?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:E,startIndex:1}]:[]:[{endIndex:0,size:E,startIndex:0}]})),s),Te(pe(b,_e(E=>E!==void 0&&E.length>0&&ht(Et(T).sizeTree)),Se(E=>{const O=[];let R=E[0],D=0;for(let I=1;I<E.length;I++){const q=E[I];q!==R&&(O.push({endIndex:I-1,size:R,startIndex:D}),R=q,D=I)}return O.push({endIndex:E.length-1,size:R,startIndex:D}),O})),s),Te(pe(g,Ge(v,y),_e(([,E,O])=>E!==void 0&&O!==void 0),Se(([E,O,R])=>{const D=[];for(let I=0;I<E.length;I++){const q=E[I],X=E[I+1];D.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&D.push({startIndex:q+1,endIndex:X-1,size:R})}return D})),s);const H=En(pe(s,Ge(T),la(({sizes:E},[O,R])=>({changed:R!==E,sizes:R}),{changed:!1,sizes:C}),Se(E=>E.changed)));lt(pe(h,la((E,O)=>({diff:E.prev-O,prev:O}),{diff:0,prev:0}),Se(E=>E.diff)),E=>{const{groupIndices:O}=Et(T);if(E>0)Fe(r,!0),Fe(u,E+og(E,O));else if(E<0){const R=Et(N);R.length>0&&(E-=og(-E,R)),Fe(d,E)}}),lt(pe(h,Ge(t)),([E,O])=>{E<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Ut.ERROR)});const L=En(u);Te(pe(u,Ge(T),Se(([E,O])=>{const R=O.groupIndices.length>0,D=[],I=O.lastSize;if(R){const q=Is(O.sizeTree,0);let X=0,Y=0;for(;X<E;){const z=O.groupIndices[Y],B=O.groupIndices.length===Y+1?1/0:O.groupIndices[Y+1]-z-1;D.push({endIndex:z,size:q,startIndex:z}),D.push({endIndex:z+1+B-1,size:I,startIndex:z+1}),Y++,X+=B+1}const U=zr(O.sizeTree);return X!==E&&U.shift(),U.reduce((z,{k:B,v:V})=>{let W=z.ranges;return z.prevSize!==0&&(W=[...z.ranges,{endIndex:B+E-1,size:z.prevSize,startIndex:z.prevIndex}]),{prevIndex:B+E,prevSize:V,ranges:W}},{prevIndex:E,prevSize:0,ranges:D}).ranges}return zr(O.sizeTree).reduce((q,{k:X,v:Y})=>({prevIndex:X+E,prevSize:Y,ranges:[...q.ranges,{endIndex:X+E-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),s);const F=En(pe(d,Ge(T,w),Se(([E,{offsetTree:O},R])=>{const D=-E;return Us(D,O,R)})));return Te(pe(d,Ge(T,w),Se(([E,O,R])=>{if(O.groupIndices.length>0){if(ht(O.sizeTree))return O;let I=Cl();const q=Et(N);let X=0,Y=0,U=0;for(;X<-E;){U=q[Y];const z=q[Y+1]-U-1;Y++,X+=z+1}if(I=zr(O.sizeTree).reduce((z,{k:B,v:V})=>Cn(z,Math.max(0,B+E),V),I),X!==-E){const z=Is(O.sizeTree,U);I=Cn(I,0,z);const B=Qn(O.sizeTree,-E+1)[1];I=Cn(I,1,B)}return{...O,sizeTree:I,...Qd(O.offsetTree,0,I,R)}}const D=zr(O.sizeTree).reduce((I,{k:q,v:X})=>Cn(I,Math.max(0,q+E),X),Cl());return{...O,sizeTree:D,...Qd(O.offsetTree,0,D,R)}})),T),{beforeUnshiftWith:L,data:S,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:w,groupIndices:g,heightEstimates:b,itemSize:k,listRefresh:H,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:T,statefulTotalCount:c,totalCount:o,trackItemSizes:M,unshiftWith:u}},kt(ur,gf),{singleton:!0});function q2(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const Pv=nt(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Qe(),d=Qe(),h=En(pe(u,Se(q2)));return Te(pe(h,Se(g=>g.totalCount)),s),Te(pe(h,Se(g=>g.groupIndices)),t),Te(pe(Bt(c,r,o),_e(([g,p])=>Vo(p)),Se(([g,p,y])=>Qn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),St(),Se(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},kt(ia,cn)),dr=nt(([{log:t}])=>{const r=ge(!1),s=En(pe(r,_e(o=>o),St()));return lt(r,o=>{o&&Et(t)("props updated",{},Ut.DEBUG)}),{didMount:s,propsReady:r}},kt(ur),{singleton:!0}),Y2=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Fv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!Y2)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Ws=nt(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const k=Qe(),S=Qe(),w=ge(0);let C=null,T=null,N=null;function M(){C!==null&&(C(),C=null),N!==null&&(N(),N=null),T&&(clearTimeout(T),T=null),Fe(g,!1)}return Te(pe(k,Ge(s,v,o,w,h,d,b),Ge(t,u,c),Se(([[H,L,F,E,O,R,D,I],q,X,Y])=>{const U=Fv(H),{align:z,behavior:B,offset:V}=U,W=E-1,de=Vv(U,L,W);let _=Us(de,L.offsetTree,q)+R;z==="end"?(_+=X+Qn(L.sizeTree,de)[1]-F+Y,de===W&&(_+=D)):z==="center"?_+=(X+Qn(L.sizeTree,de)[1]-F+Y)/2:_-=O,V!==void 0&&V!==0&&(_+=V);const P=ee=>{M(),ee?(I("retrying to scroll to",{location:H},Ut.DEBUG),Fe(k,H)):(Fe(S,!0),I("list did not change, scroll successful",{},Ut.DEBUG))};if(M(),B==="smooth"){let ee=!1;N=lt(r,re=>{ee=ee||re}),C=Kn(y,()=>{P(ee)})}else C=Kn(pe(r,K2(150)),P);return T=setTimeout(()=>{M()},1200),Fe(g,!0),I("scrolling from index to",{behavior:B,index:de,top:_},Ut.DEBUG),{behavior:B,top:_}})),p),{scrollTargetReached:S,scrollToIndex:k,topListHeight:w}},kt(ia,cn,ur),{singleton:!0});function K2(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function yf(t,r){t===0?r():requestAnimationFrame(()=>{yf(t-1,r)})}function bf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const qs=nt(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),g=ge(0),p=ge(!0);return Te(pe(d,Ge(g),_e(([y,v])=>v!==0),ra(!1)),h),Te(pe(d,Ge(g),_e(([y,v])=>v!==0),ra(!1)),p),lt(pe(Bt(r,d),Ge(h,s,t,p),_e(([[,y],v,{sizeTree:b},k,S])=>y&&(!ht(b)||mf(k))&&!v&&!S),Ge(g)),([,y])=>{Kn(c,()=>{Fe(p,!0)}),yf(4,()=>{Kn(o,()=>{Fe(h,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},kt(ia,cn,Ws,dr),{singleton:!0});function Gv(t,r){return Math.abs(t-r)<1.01}const $s="up",zs="down",X2="none",Q2={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Z2=0,Ys=nt(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),g=Qe(),p=Qe(),y=ge(4),v=ge(Z2),b=tn(pe(qd(pe(De(c),Dr(1),ra(!0)),pe(De(c),Dr(1),ra(!1),lg(100))),St()),!1),k=tn(pe(qd(pe(s,ra(!0)),pe(s,ra(!1),lg(200))),St()),!1);Te(pe(Bt(De(c),De(v)),Se(([N,M])=>N<=M),St()),h),Te(pe(h,Ra(50)),p);const S=En(pe(Bt(o,De(u),De(r),De(t),De(y)),la((N,[{scrollHeight:M,scrollTop:H},L,F,E,O])=>{const R=H+L-M>-O,D={scrollHeight:M,scrollTop:H,viewportHeight:L};if(R){let q,X;return H>N.state.scrollTop?(q="SCROLLED_DOWN",X=N.state.scrollTop-H):(q="SIZE_DECREASED",X=N.state.scrollTop-H||N.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:D}}let I;return D.scrollHeight>N.state.scrollHeight?I="SIZE_INCREASED":L<N.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":H<N.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:D}},Q2),St((N,M)=>N!==void 0&&N.atBottom===M.atBottom))),w=tn(pe(o,la((N,{scrollHeight:M,scrollTop:H,viewportHeight:L})=>{if(!Gv(N.scrollHeight,M)){const F=M-(H+L)<1;return N.scrollTop!==H&&F?{changed:!0,jump:N.scrollTop-H,scrollHeight:M,scrollTop:H}:{changed:!0,jump:0,scrollHeight:M,scrollTop:H}}return{changed:!1,jump:0,scrollHeight:M,scrollTop:H}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),_e(N=>N.changed),Se(N=>N.jump)),0);Te(pe(S,Se(N=>N.atBottom)),d),Te(pe(d,Ra(50)),g);const C=ge(zs);Te(pe(o,Se(({scrollTop:N})=>N),St(),la((N,M)=>Et(k)?{direction:N.direction,prevScrollTop:M}:{direction:M<N.prevScrollTop?$s:zs,prevScrollTop:M},{direction:zs,prevScrollTop:0}),Se(N=>N.direction)),C),Te(pe(o,Ra(50),ra(X2)),C);const T=ge(0);return Te(pe(b,_e(N=>!N),ra(0)),T),Te(pe(c,Ra(100),Ge(b),_e(([N,M])=>M),la(([N,M],[H])=>[M,H],[0,0]),Se(([N,M])=>M-N)),T),{atBottomState:S,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:w,scrollDirection:C,scrollVelocity:T}},kt(cn)),Vs="top",Ps="bottom",cg="none";function ug(t,r,s){return typeof t=="number"?s===$s&&r===Vs||s===zs&&r===Ps?t:0:s===$s?r===Vs?t.main:t.reverse:r===Ps?t.main:t.reverse}function dg(t,r){return typeof t=="number"?t:t[r]??0}const jf=nt(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Qe(),d=ge(0),h=ge(0),g=ge(0),p=tn(pe(Bt(De(o),De(c),De(s),De(u,Hs),De(g),De(d),De(r),De(t),De(h)),Se(([y,v,b,[k,S],w,C,T,N,M])=>{const H=y-N,L=C+T,F=Math.max(b-H,0);let E=cg;const O=dg(M,Vs),R=dg(M,Ps);return k-=N,k+=b+T,S+=b+T,S-=N,k>y+L-O&&(E=$s),S<y-F+v+R&&(E=zs),E!==cg?[Math.max(H-b-ug(w,Vs,E)-O,0),H-F-T+v+ug(w,Ps,E)+R]:null}),_e(y=>y!==null),St(Hs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},kt(cn),{singleton:!0});function J2(t,r,s){if(Vo(r)){const o=$v(t,r);return[{index:Qn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const jd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const w=t[t.length-1];y=w.offset+w.size}const v=s-d,b=h+v*g+(v-1)*o,k=p,S=b-y;return{bottom:y,firstItemIndex:u,items:fg(t,c,u),offsetBottom:S,offsetTop:p,top:k,topItems:fg(r,c,u),topListHeight:r.reduce((w,C)=>C.size+w,0),totalCount:s}}function Wv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=bf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Co(p,[],h,c,s,o)}function fg(t,r,s){if(t.length===0)return[];if(!Vo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=El(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function pg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Br=nt(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:k},{recalcInProgress:S}])=>{const w=ge([]),C=ge(0),T=Qe(),N=ge(0);Te(u.topItemsIndexes,w);const M=tn(pe(Bt(k,S,De(g,Hs),De(c),De(o),De(p),y,De(w),De(r),De(s),De(N),t),_e(([E,O,,R,,,,,,,,D])=>{const I=D!==void 0&&D.length!==R;return E&&!O&&!I}),Se(([,,[E,O],R,D,I,q,X,Y,U,z,B])=>{var je,Re;const V=D,{offsetTree:W,sizeTree:de}=V,_=Et(C);if(R===0)return{...jd,totalCount:R};if(E===0&&O===0)return _===0?{...jd,totalCount:R}:Wv(_,I,D,Y,U,B||[]);if(ht(de))return _>0?null:Co(J2(bf(I,R),V,B),[],R,U,V,Y);const P=[];if(X.length>0){const Le=X[0],ae=X[X.length-1];let fe=0;for(const me of El(de,Le,ae)){const he=me.value,be=Math.max(me.start,Le),Be=Math.min(me.end,ae);for(let Oe=be;Oe<=Be;Oe++)P.push({data:B==null?void 0:B[Oe],index:Oe,offset:fe,size:he}),fe+=he}}if(!q)return Co([],P,R,U,V,Y);const ee=X.length>0?X[X.length-1]+1:0,re=$2(W,E,O,ee);if(re.length===0)return null;const xe=R-1,ce=$o([],Le=>{for(const ae of re){const fe=ae.value;let me=fe.offset,he=ae.start;const be=fe.size;if(fe.offset<E){he+=Math.floor((E-fe.offset+U)/(be+U));const Oe=he-ae.start;me+=Oe*be+Oe*U}he<ee&&(me+=(ee-he)*be,he=ee);const Be=Math.min(ae.end,xe);for(let Oe=he;Oe<=Be&&!(me>=O);Oe++)Le.push({data:B==null?void 0:B[Oe],index:Oe,offset:me,size:be}),me+=be+U}}),ye=pg(z,Vs),ue=pg(z,Ps);if(ce.length>0&&(ye>0||ue>0)){const Le=ce[0],ae=ce[ce.length-1];if(ye>0&&Le.index>ee){const fe=Math.min(ye,Le.index-ee),me=[];let he=Le.offset;for(let be=Le.index-1;be>=Le.index-fe;be--){const Be=((je=El(de,be,be)[0])==null?void 0:je.value)??Le.size;he-=Be+U,me.unshift({data:B==null?void 0:B[be],index:be,offset:he,size:Be})}ce.unshift(...me)}if(ue>0&&ae.index<xe){const fe=Math.min(ue,xe-ae.index);let me=ae.offset+ae.size+U;for(let he=ae.index+1;he<=ae.index+fe;he++){const be=((Re=El(de,he,he)[0])==null?void 0:Re.value)??ae.size;ce.push({data:B==null?void 0:B[he],index:he,offset:me,size:be}),me+=be+U}}}return Co(ce,P,R,U,V,Y)}),_e(E=>E!==null),St()),jd);Te(pe(t,_e(mf),Se(E=>E==null?void 0:E.length)),c),Te(pe(M,Se(E=>E.topListHeight)),v),Te(v,h),Te(pe(M,Se(E=>[E.top,E.bottom])),d),Te(pe(M,Se(E=>E.items)),T);const H=En(pe(M,_e(({items:E})=>E.length>0),Ge(c,t),_e(([{items:E},O])=>E[E.length-1].originalIndex===O-1),Se(([,E,O])=>[E-1,O]),St(Hs),Se(([E])=>E))),L=En(pe(M,Ra(200),_e(({items:E,topItems:O})=>E.length>0&&E[0].originalIndex===O.length),Se(({items:E})=>E[0].index),St())),F=En(pe(M,_e(({items:E})=>E.length>0),Se(({items:E})=>{let O=0,R=E.length-1;for(;E[O].type==="group"&&O<R;)O++;for(;E[R].type==="group"&&R>O;)R--;return{endIndex:E[R].index,startIndex:E[O].index}}),St(Hv)));return{endReached:H,initialItemCount:C,itemsRendered:T,listState:M,minOverscanItemCount:N,rangeChanged:F,startReached:L,topItemsIndexes:w,...b}},kt(ia,Pv,jf,qs,Ws,Ys,dr,gf),{singleton:!0}),qv=nt(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Qe(),d=tn(pe(Bt(s,t,o,r,c),Se(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Te(De(d),u),{totalListHeight:d,totalListHeightChanged:u}},kt(cn,Br),{singleton:!0}),ek=nt(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ge(!1),o=tn(pe(Bt(s,t,r),_e(([c])=>c),Se(([,c,u])=>Math.max(0,c-u)),Ra(0),St()),0);return{alignToBottom:s,paddingTopAddition:o}},kt(cn,qv),{singleton:!0}),Yv=nt(()=>({context:ge(null)})),tk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Kv=nt(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Qe();return Te(pe(y,Ge(r,g,s,u,c,o,h),Ge(t),Se(([[v,b,k,S,w,C,T,N],M])=>{const{calculateViewLocation:H=tk,done:L,...F}=v,E=Vv(v,b,S-1),O=Us(E,b.offsetTree,M)+w+C,R=O+Qn(b.sizeTree,E)[1],D=N+C,I=N+k-T,q=H({itemBottom:R,itemTop:O,locationParams:F,viewportBottom:I,viewportTop:D});return q!==null?L&&Kn(pe(d,_e(X=>!X),Dr(Et(d)?1:2)),L):L==null||L(),q}),_e(v=>v!==null)),p),{scrollIntoView:y}},kt(ia,cn,Ws,Br,ur),{singleton:!0});function mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const nk=(t,r)=>typeof t=="function"?mg(t(r)):r&&mg(t),ak=nt(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:k}])=>{const S=ge(!1),w=Qe();let C=null;function T(L){Fe(d,{align:"end",behavior:L,index:"LAST"})}lt(pe(Bt(pe(De(r),Dr(1)),g),Ge(De(S),u,h,v),Se(([[L,F],E,O,R,D])=>{let I=F&&R,q="auto";return I&&(q=nk(E,O||D),I=I&&q!==!1),{followOutputBehavior:q,shouldFollow:I,totalCount:L}}),_e(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:F})=>{C!==null&&(C(),C=null),Et(s)!==void 0?requestAnimationFrame(()=>{Et(y)("following output to ",{totalCount:F},Ut.DEBUG),T(L)}):C=Kn(t,()=>{Et(y)("following output to ",{totalCount:F},Ut.DEBUG),T(L),C=null})});function N(L){const F=Kn(c,E=>{L&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(Et(y)("scrolling to bottom due to increased size",{},Ut.DEBUG),T("auto"))});setTimeout(F,100)}lt(pe(Bt(De(S),r,p),_e(([L,,F])=>L!==!1&&F),la(({value:L},[,F])=>({refreshed:L===F,value:F}),{refreshed:!1,value:0}),_e(({refreshed:L})=>L),Ge(S,r)),([,L])=>{Et(h)&&N(L!==!1)}),lt(w,()=>{N(Et(S)!==!1)}),lt(Bt(De(S),c),([L,F])=>{L!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&T("auto")});const M=ge(null),H=Qe();return Te(qd(pe(De(o),Se(L=>(L==null?void 0:L.length)??0)),pe(De(r))),H),lt(pe(Bt(pe(H,Dr(1)),g),Ge(De(M),h,v,b),Se(([[L,F],E,O,R,D])=>F&&O&&(E==null?void 0:E({context:D,totalCount:L,scrollingInProgress:R}))),_e(L=>!!L),Ra(0)),L=>{C!==null&&(C(),C=null),Et(s)!==void 0?requestAnimationFrame(()=>{Et(y)("scrolling into view",{}),Fe(k,L)}):C=Kn(t,()=>{Et(y)("scrolling into view",{}),Fe(k,L),C=null})}),{autoscrollToBottom:w,followOutput:S,scrollIntoViewOnChange:M}},kt(ia,Ys,Ws,qs,dr,ur,cn,Yv,Kv)),rk=nt(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(pe(h,Ge(u),_e(([,g])=>g!==0),Ge(c,o,r,s,t),Se(([[,g],p,y,v,b,k=[]])=>Wv(g,p,y,v,b,k))),d),{}),kt(ia,qs,Br,dr),{singleton:!0}),lk=nt(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ge(0);return lt(pe(t,Ge(o),_e(([,c])=>c!==0),Se(([,c])=>({top:c}))),c=>{Kn(pe(s,Dr(1),_e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(r,c)})})}),{initialScrollTop:o}},kt(dr,cn,Br),{singleton:!0}),Xv=nt(([{scrollVelocity:t}])=>{const r=ge(!1),s=Qe(),o=ge(!1);return Te(pe(t,Ge(o,r,s),_e(([c,u])=>u!==!1&&u!==void 0),Se(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),St()),r),lt(pe(Bt(r,t,s),Ge(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},kt(Ys),{singleton:!0}),Sf=nt(([{scrollContainerState:t,scrollTo:r}])=>{const s=Qe(),o=Qe(),c=Qe(),u=ge(!1),d=ge(void 0);return Te(pe(Bt(s,o),Se(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Te(pe(r,Ge(o),Se(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},kt(cn)),sk=nt(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Qe(),y=ge(void 0),v=ge(null),b=ge(null);return Te(h,v),Te(g,b),lt(pe(p,Ge(r,o,d,v,b,s)),([k,S,w,C,T,N,M])=>{const H=P2(S.sizeTree);C&&T!==null&&N!==null&&(w=T.scrollTop-N.offsetTop),w-=M,k({ranges:H,scrollTop:w})}),Te(pe(y,_e(mf),Se(ik)),c),Te(pe(u,Ge(y),_e(([,k])=>k!==void 0),St(),Se(([,k])=>k.ranges)),t),{getState:p,restoreStateFrom:y}},kt(ia,cn,qs,dr,Sf));function ik(t){return{align:"start",index:0,offset:t.scrollTop}}const ok=nt(([{topItemsIndexes:t}])=>{const r=ge(0);return Te(pe(r,_e(s=>s>=0),Se(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},kt(Br));function Qv(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const ck=Qv(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),uk=nt(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:k},{recalcInProgress:S}])=>{const w=En(pe(g,Ge(d),la(([,T,N,M],[{bottom:H,items:L,offsetBottom:F,totalCount:E},O])=>{const R=H+F;let D=0;return N===E&&T.length>0&&L.length>0&&(L[0].originalIndex===0&&T[0].originalIndex===0||(D=R-M,D!==0&&(D+=O))),[D,L,E,R]},[0,[],0,0]),_e(([T])=>T!==0),Ge(o,h,s,c,k,S),_e(([,T,N,M,,,H])=>!H&&!M&&T!==0&&N===$s),Se(([[T],,,,,N])=>(N("Upward scrolling compensation",{amount:T},Ut.DEBUG),T))));function C(T){T>0?(Fe(r,{behavior:"auto",top:-T}),Fe(t,0)):(Fe(t,0),Fe(r,{behavior:"auto",top:-T}))}return lt(pe(w,Ge(t,u)),([T,N,M])=>{M&&ck()?Fe(t,N-T):C(-T)}),lt(pe(Bt(tn(u,!1),t,S),_e(([T,N,M])=>!T&&!M&&N!==0),Se(([T,N])=>N),Ra(1)),C),Te(pe(v,Se(T=>({top:-T}))),r),lt(pe(p,Ge(b,y),Se(([T,{groupIndices:N,lastSize:M,sizeTree:H},L])=>{function F(I){return I*(M+L)}if(N.length===0)return F(T);let E=0;const O=Is(H,0);let R=0,D=0;for(;R<T;){R++,E+=O;let I=N.length===D+1?1/0:N[D+1]-N[D]-1;R+I>T&&(E-=O,I=T-R+1),R+=I,E+=F(I),D++}return E})),T=>{Fe(t,T),requestAnimationFrame(()=>{Fe(r,{top:T}),requestAnimationFrame(()=>{Fe(t,0),Fe(S,!1)})})}),{deviation:t}},kt(cn,Ys,Br,ia,ur,gf)),dk=nt(([t,r,s,o,c,u,d,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...p,...y}),kt(jf,rk,dr,Xv,qv,lk,ek,Sf,Kv,ur,Yv)),Zv=nt(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:k},{initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:C},T,N,M,H,{scrollToIndex:L},F,{topItemCount:E},{groupCounts:O},R])=>{const{listState:D,minOverscanItemCount:I,topItemsIndexes:q,rangeChanged:X,...Y}=H;return Te(X,R.scrollSeekRangeChanged),Te(pe(R.windowViewportRect,Se(U=>U.visibleHeight)),T.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:C,sizeRanges:p,topItemCount:E,topItemsIndexes:q,totalCount:b,...M,groupIndices:d,itemSize:g,listState:D,minOverscanItemCount:I,scrollToIndex:L,statefulTotalCount:v,trackItemSizes:k,rangeChanged:X,...Y,...R,...T,sizes:y,...N}},kt(ia,qs,cn,sk,ak,Br,Ws,uk,ok,Pv,dk));function fk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const uo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Jv(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Ne.createContext({});function g(C,T){C.propsReady!==void 0&&Fe(C.propsReady,!1);for(const N of o){const M=C[r.required[N]];Fe(M,T[N])}for(const N of c)if(N in T){const M=C[r.optional[N]];Fe(M,T[N])}C.propsReady!==void 0&&Fe(C.propsReady,!0)}function p(C){return u.reduce((T,N)=>(T[N]=M=>{const H=C[r.methods[N]];Fe(H,M)},T),{})}function y(C){return d.reduce((T,N)=>(T[N]=T2(C[r.events[N]]),T),{})}const v=Ne.forwardRef(function(C,T){const{children:N,...M}=C,[H]=Ne.useState(()=>$o(A2(t),E=>{g(E,M)})),[L]=Ne.useState(rg(y,H));uo(()=>{for(const E of d)E in M&&lt(L[E],M[E]);return()=>{Object.values(L).map(hf)}},[M,L,H]),uo(()=>{g(H,M)}),Ne.useImperativeHandle(T,ag(p(H)));const F=s;return a.jsx(h.Provider,{value:H,children:s!==void 0?a.jsx(F,{...fk([...o,...c,...d],M),children:N}):N})}),b=C=>{const T=Ne.useContext(h);return Ne.useCallback(N=>{Fe(T[C],N)},[T,C])},k=C=>{const T=Ne.useContext(h)[C],N=Ne.useCallback(M=>lt(T,M),[T]);return Ne.useSyncExternalStore(N,()=>Et(T),()=>Et(T))},S=C=>{const T=Ne.useContext(h)[C],[N,M]=Ne.useState(rg(Et,T));return uo(()=>lt(T,H=>{H!==N&&M(ag(H))}),[T,N]),N},w=parseInt(Ne.version)>=18?k:S;return{Component:v,useEmitter:(C,T)=>{const N=Ne.useContext(h)[C];uo(()=>lt(N,T),[T,N])},useEmitterValue:w,usePublisher:b}}const ey=Ne.createContext(void 0),ty=Ne.createContext(void 0),Sd="-webkit-sticky",hg="sticky",kf=Qv(()=>{if(typeof document>"u")return hg;const t=document.createElement("div");return t.style.position=Sd,t.style.position===Sd?Sd:hg}),ny=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function kd(t){return"self"in t}function pk(t){return"body"in t}function ay(t,r,s,o=zl,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),g=Ne.useRef(null),p=Ne.useCallback(b=>{let k,S,w;const C=b.target;if(pk(C)||kd(C)){const N=kd(C)?C:C.defaultView;w=u===!0?N.scrollX:N.scrollY,k=u===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,S=u===!0?N.innerWidth:N.innerHeight}else w=u===!0?C.scrollLeft:C.scrollTop,k=u===!0?C.scrollWidth:C.scrollHeight,S=u===!0?C.offsetWidth:C.offsetHeight;const T=()=>{t({scrollHeight:k,scrollTop:Math.max(w,0),viewportHeight:S})};b.suppressFlushSync===!0?T():Bj.flushSync(T),h.current!==null&&(w===h.current||w<=0||w===k-S)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Ne.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const k=d.current;if(!k||(u===!0?"offsetWidth"in k&&k.offsetWidth===0:"offsetHeight"in k&&k.offsetHeight===0))return;const S=b.behavior==="smooth";let w,C,T;kd(k)?(C=Math.max(ir(k.document.documentElement,u===!0?"width":"height"),u===!0?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight),w=u===!0?k.innerWidth:k.innerHeight,T=u===!0?window.scrollX:window.scrollY):(C=k[u===!0?"scrollWidth":"scrollHeight"],w=ir(k,u===!0?"width":"height"),T=k[u===!0?"scrollLeft":"scrollTop"]);const N=C-w;if(b.top=Math.ceil(Math.max(Math.min(N,b.top),0)),Gv(w,C)||b.top===T){t({scrollHeight:C,scrollTop:T,viewportHeight:w}),S&&r(!0);return}S?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),k.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 wf(t){return t}const mk=nt(()=>{const t=ge(h=>`Item ${h}`),r=ge(h=>`Group ${h}`),s=ge({}),o=ge(wf),c=ge("div"),u=ge(zl),d=(h,g=null)=>tn(pe(s,Se(p=>p[h]),St()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),hk=nt(([t,r])=>({...t,...r}),kt(Zv,mk)),xk=({height:t})=>a.jsx("div",{style:{height:t}}),gk={overflowAnchor:"none",position:kf(),zIndex:1},ry={overflowAnchor:"none"},vk={...ry,display:"inline-block",height:"100%"},xg=Ne.memo(function({showTopList:t=!1}){const r=He("listState"),s=$n("sizeRanges"),o=He("useWindowScroll"),c=He("customScrollParent"),u=$n("windowScrollContainerState"),d=$n("scrollContainerState"),h=c||o?u:d,g=He("itemContent"),p=He("context"),y=He("groupContent"),v=He("trackItemSizes"),b=He("itemSize"),k=He("log"),S=$n("gap"),w=He("horizontalDirection"),{callbackRef:C}=z2(s,b,v,t?zl:h,k,S,c,w,He("skipAnimationFrameInResizeObserver")),[T,N]=Ne.useState(0);Cf("deviation",Y=>{T!==Y&&N(Y)});const M=He("EmptyPlaceholder"),H=He("ScrollSeekPlaceholder")??xk,L=He("ListComponent"),F=He("ItemComponent"),E=He("GroupComponent"),O=He("computeItemKey"),R=He("isSeeking"),D=He("groupIndices").length>0,I=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:T!==0?T:I?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:T!==0?T:I?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&M!==null&&M!==void 0?a.jsx(M,{...en(M,p)}):a.jsx(L,{...en(L,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(Y=>{const U=Y.originalIndex,z=O(U+r.firstItemIndex,Y.data,p);return R?m.createElement(H,{...en(H,p),height:Y.size,index:Y.index,key:z,type:Y.type||"item",...Y.type==="group"?{}:{groupIndex:Y.groupIndex}}):Y.type==="group"?m.createElement(E,{...en(E,p),"data-index":U,"data-item-index":Y.index,"data-known-size":Y.size,key:z,style:gk},y(Y.index,p)):m.createElement(F,{...en(F,p),...Sk(F,Y.data),"data-index":U,"data-item-group-index":Y.groupIndex,"data-item-index":Y.index,"data-known-size":Y.size,key:z,style:w?vk:ry},D?g(Y.index,Y.groupIndex,Y.data,p):g(Y.index,Y.data,p))})})}),yk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},bk={outline:"none",overflowX:"auto",position:"relative"},Po=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),jk={position:kf(),top:0,width:"100%",zIndex:1};function en(t,r){if(typeof t!="string")return{context:r}}function Sk(t,r){return{item:typeof t=="string"?void 0:r}}const kk=Ne.memo(function(){const t=He("HeaderComponent"),r=$n("headerHeight"),s=He("HeaderFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),wk=Ne.memo(function(){const t=He("FooterComponent"),r=$n("footerHeight"),s=He("HeaderFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null});function ly({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:k,scrollToCallback:S}=ay(h,p,g,y,void 0,v);return t("scrollTo",S),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:k,style:{...v?bk:yk,...c},tabIndex:0,...d,...en(g,u),children:o})})}function sy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),k=Ne.useRef(null),S=r("scrollerRef"),{scrollByCallback:w,scrollerRef:C,scrollToCallback:T}=ay(h,p,g,S,b);return ny(()=>{var N;return C.current=b||((N=k.current)==null?void 0:N.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",T),t("scrollBy",w),a.jsx(g,{ref:k,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...en(g,u),children:o})})}const Ck=({children:t})=>{const r=Ne.useContext(ey),s=$n("viewportHeight"),o=$n("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>Mv(s,g=>ir(g,u?"width":"height")),[s,u]),h=Or(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Po(c),children:t})},Ek=({children:t})=>{const r=Ne.useContext(ey),s=$n("windowViewportRect"),o=$n("fixedItemHeight"),c=He("customScrollParent"),u=zv(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Po(d),children:t})},Nk=({children:t})=>{const r=He("TopItemListComponent")??"div",s=He("headerHeight"),o={...jk,marginTop:`${s}px`},c=He("context");return a.jsx(r,{style:o,...en(r,c),children:t})},Tk=Ne.memo(function(t){const r=He("useWindowScroll"),s=He("topItemsIndexes").length>0,o=He("customScrollParent"),c=He("context");return a.jsxs(o||r?Mk:Ak,{...t,context:c,children:[s&&a.jsx(Nk,{children:a.jsx(xg,{showTopList:!0})}),a.jsxs(o||r?Ek:Ck,{children:[a.jsx(kk,{}),a.jsx(xg,{}),a.jsx(wk,{})]})]})}),{Component:Rk,useEmitter:Cf,useEmitterValue:He,usePublisher:$n}=Jv(hk,{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"}},Tk),Ak=ly({useEmitter:Cf,useEmitterValue:He,usePublisher:$n}),Mk=sy({useEmitter:Cf,useEmitterValue:He,usePublisher:$n}),Lk=Rk,zk=nt(()=>{const t=ge(p=>a.jsxs("td",{children:["Item $",p]})),r=ge(null),s=ge(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ge(null),c=ge(null),u=ge({}),d=ge(wf),h=ge(zl),g=(p,y=null)=>tn(pe(u,Se(v=>v[p]),St()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});kt(Zv,zk);kf();const gg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:vg,floor:Ao,max:Ds,min:wd,round:yg}=Math;function bg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function _k(t){return{...Dk,items:t}}function fo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function Ok(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Bk=nt(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,k,{didMount:S,propsReady:w},{customScrollParent:C,useWindowScroll:T,windowScrollContainerState:N,windowScrollTo:M,windowViewportRect:H},L])=>{const F=ge(0),E=ge(0),O=ge(gg),R=ge({height:0,width:0}),D=ge({height:0,width:0}),I=Qe(),q=Qe(),X=ge(0),Y=ge(null),U=ge({column:0,row:0}),z=Qe(),B=Qe(),V=ge(!1),W=ge(0),de=ge(!0),_=ge(!1),P=ge(!1);lt(pe(S,Ge(W),_e(([ue,je])=>je!==0)),()=>{Fe(de,!1)}),lt(pe(Bt(S,de,D,R,W,_),_e(([ue,je,Re,Le,,ae])=>ue&&!je&&Re.height!==0&&Le.height!==0&&!ae)),([,,,,ue])=>{Fe(_,!0),yf(1,()=>{Fe(I,ue)}),Kn(pe(p),()=>{Fe(r,[0,0]),Fe(de,!0)})}),Te(pe(B,_e(ue=>ue!=null&&ue.scrollTop>0),ra(0)),E),lt(pe(S,Ge(B),_e(([,ue])=>ue!=null)),([,ue])=>{ue&&(Fe(R,ue.viewport),Fe(D,ue.item),Fe(U,ue.gap),ue.scrollTop>0&&(Fe(V,!0),Kn(pe(p,Dr(1)),je=>{Fe(V,!1)}),Fe(g,{top:ue.scrollTop})))}),Te(pe(R,Se(({height:ue})=>ue)),v),Te(pe(Bt(De(R,fo),De(D,fo),De(U,(ue,je)=>ue!==void 0&&ue.column===je.column&&ue.row===je.row),De(p)),Se(([ue,je,Re,Le])=>({gap:Re,item:je,scrollTop:Le,viewport:ue}))),z),Te(pe(Bt(De(F),o,De(U,Ok),De(D,fo),De(R,fo),De(Y),De(E),De(V),De(de),De(W)),_e(([,,,,,,,ue])=>!ue),Se(([ue,[je,Re],Le,ae,fe,me,he,,be,Be])=>{const{column:Oe,row:st}=Le,{height:At,width:gt}=ae,{width:Gt}=fe;if(he===0&&(ue===0||Gt===0))return gg;if(gt===0){const Vt=bf(Be,ue),oa=Vt+Math.max(he-1,0);return _k(bg(Vt,oa,me))}const vt=iy(Gt,gt,Oe);let Ze,at;be?je===0&&Re===0&&he>0?(Ze=0,at=he-1):(Ze=vt*Ao((je+st)/(At+st)),at=vt*vg((Re+st)/(At+st))-1,at=wd(ue-1,Ds(at,vt-1)),Ze=wd(at,Ds(0,Ze))):(Ze=0,at=-1);const ve=bg(Ze,at,me),{bottom:ct,top:Nt}=jg(fe,Le,ae,ve),nn=vg(ue/vt),Rn=nn*At+(nn-1)*st-ct;return{bottom:ct,itemHeight:At,items:ve,itemWidth:gt,offsetBottom:Rn,offsetTop:Nt,top:Nt}})),O),Te(pe(Y,_e(ue=>ue!==null),Se(ue=>ue.length)),F),Te(pe(Bt(R,D,O,U),_e(([ue,je,{items:Re}])=>Re.length>0&&je.height!==0&&ue.height!==0),Se(([ue,je,{items:Re},Le])=>{const{bottom:ae,top:fe}=jg(ue,Le,je,Re);return[fe,ae]}),St(Hs)),r);const ee=ge(!1);Te(pe(p,Ge(ee),Se(([ue,je])=>je||ue!==0)),ee);const re=En(pe(Bt(O,F),_e(([{items:ue}])=>ue.length>0),Ge(ee),_e(([[ue,je],Re])=>{const Le=ue.items[ue.items.length-1].index===je-1;return(Re||ue.bottom>0&&ue.itemHeight>0&&ue.offsetBottom===0&&ue.items.length===je)&&Le}),Se(([[,ue]])=>ue-1),St())),xe=En(pe(De(O),_e(({items:ue})=>ue.length>0&&ue[0].index===0),ra(0),St())),ce=En(pe(De(O),Ge(V),_e(([{items:ue},je])=>ue.length>0&&!je),Se(([{items:ue}])=>({endIndex:ue[ue.length-1].index,startIndex:ue[0].index})),St(Hv),Ra(0)));Te(ce,k.scrollSeekRangeChanged),Te(pe(I,Ge(R,D,F,U),Se(([ue,je,Re,Le,ae])=>{const fe=Fv(ue),{align:me,behavior:he,offset:be}=fe;let Be=fe.index;Be==="LAST"&&(Be=Le-1),Be=Ds(0,Be,wd(Le-1,Be));let Oe=Zd(je,ae,Re,Be);return me==="end"?Oe=yg(Oe-je.height+Re.height):me==="center"&&(Oe=yg(Oe-je.height/2+Re.height/2)),be!==void 0&&be!==0&&(Oe+=be),{behavior:he,top:Oe}})),g);const ye=tn(pe(O,Se(ue=>ue.offsetBottom+ue.bottom)),0);return Te(pe(H,Se(ue=>({height:ue.visibleHeight,width:ue.visibleWidth}))),R),{customScrollParent:C,data:Y,deviation:X,footerHeight:c,gap:U,headerHeight:u,increaseViewportBy:t,initialItemCount:E,itemDimensions:D,overscan:s,restoreStateFrom:B,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:I,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:T,viewportDimensions:R,windowScrollContainerState:N,windowScrollTo:M,windowViewportRect:H,...k,gridState:O,horizontalDirection:P,initialTopMostItemIndex:W,totalListHeight:ye,...b,endReached:re,propsReady:w,rangeChanged:ce,startReached:xe,stateChanged:z,stateRestoreInProgress:V,...L}},kt(jf,cn,Ys,Xv,dr,Sf,ur));function iy(t,r,s){return Ds(1,Ao((t+s)/(Ao(r)+s)))}function jg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=Zd(t,r,s,o[0].index);return{bottom:Zd(t,r,s,o[o.length-1].index)+c,top:u}}function Zd(t,r,s,o){const c=iy(t.width,s.width,r.column),u=Ao(o/c),d=u*s.height+Ds(0,u-1)*r.row;return d>0?d+r.row:d}const Ik=nt(()=>{const t=ge(v=>`Item ${v}`),r=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(wf),d=ge("div"),h=ge(zl),g=(v,b=null)=>tn(pe(r,Se(k=>k[v]),St()),b),p=ge(!1),y=ge(!1);return Te(De(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Hk=nt(([t,r])=>({...t,...r}),kt(Bk,Ik)),Uk=Ne.memo(function(){const t=Ct("gridState"),r=Ct("listClassName"),s=Ct("itemClassName"),o=Ct("itemContent"),c=Ct("computeItemKey"),u=Ct("isSeeking"),d=Vn("scrollHeight"),h=Ct("ItemComponent"),g=Ct("ListComponent"),p=Ct("ScrollSeekPlaceholder"),y=Ct("context"),v=Vn("itemDimensions"),b=Vn("gap"),k=Ct("log"),S=Ct("stateRestoreInProgress"),w=Vn("reportReadyState"),C=Or(Ne.useMemo(()=>T=>{const N=T.parentElement.parentElement.scrollHeight;d(N);const M=T.firstChild;if(M!==null){const{height:H,width:L}=M.getBoundingClientRect();v({height:H,width:L})}b({column:Sg("column-gap",getComputedStyle(T).columnGap,k),row:Sg("row-gap",getComputedStyle(T).rowGap,k)})},[d,v,b,k]),!0,!1);return ny(()=>{t.itemHeight>0&&t.itemWidth>0&&w(!0)},[t]),S?null:a.jsx(g,{className:r,ref:C,...en(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(T=>{const N=c(T.index,T.data,y);return u?a.jsx(p,{...en(p,y),height:t.itemHeight,index:T.index,width:t.itemWidth},N):m.createElement(h,{...en(h,y),className:s,"data-index":T.index,key:N},o(T.index,T.data,y))})})}),$k=Ne.memo(function(){const t=Ct("HeaderComponent"),r=Vn("headerHeight"),s=Ct("headerFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=Ct("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),Vk=Ne.memo(function(){const t=Ct("FooterComponent"),r=Vn("footerHeight"),s=Ct("headerFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=Ct("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),Pk=({children:t})=>{const r=Ne.useContext(ty),s=Vn("itemDimensions"),o=Vn("viewportDimensions"),c=Or(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Po(!1),children:t})},Fk=({children:t})=>{const r=Ne.useContext(ty),s=Vn("windowViewportRect"),o=Vn("itemDimensions"),c=Ct("customScrollParent"),u=zv(s,c,!1);return Ne.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Po(!1),children:t})},Gk=Ne.memo(function({...t}){const r=Ct("useWindowScroll"),s=Ct("customScrollParent"),o=s||r?qk:Wk,c=s||r?Fk:Pk,u=Ct("context");return a.jsx(o,{...t,...en(o,u),children:a.jsxs(c,{children:[a.jsx($k,{}),a.jsx(Uk,{}),a.jsx(Vk,{})]})})}),{useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn}=Jv(Hk,{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"}},Gk),Wk=ly({useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn}),qk=sy({useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn});function Sg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Ut.WARN),r==="normal"?0:parseInt(r??"0",10)}const Yk={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},cy={source:"Own",installed:"Installed"};function Kk(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function Xk(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function kg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=Yk[t],[d,h]=m.useState(()=>Kk(u)),g=m.useCallback(()=>{h(b=>{const k=!b;return Xk(u,k),k})},[u]),p=cy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(Zk,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(Qk,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Qk({origin:t,updateCount:r}){const[s,o]=m.useState(!1),c=cy[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Zk({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Ef(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Jk({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function ew({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function tw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function nw({skillId:t,trackedForUpdates:r}){let s=null;try{s=m.useContext(Sv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Ks(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function aw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(Ks,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(ew,{target:t.symlinkTarget??null}),a.jsx(tw,{skill:t}),a.jsx(nw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Mo=m.memo(aw);function rw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Mo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function lw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function wg({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var k;const h=r??((k=t[0])==null?void 0:k.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>lw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(S=>{const w=!S;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(w))}catch{}return w})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(S=>a.jsx("div",{"data-vskill-plugin-skill":S.pluginNamespace??S.skill,children:c(S)},`${S.pluginNamespace??S.skill}`))})]})}function sw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await b.json().catch(()=>({}));if(!b.ok||!k.ok){g(k.error??`${v} failed (${b.status})`);return}on("skills"),on("plugins"),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Cd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Cd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Cd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Cd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Cg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(iw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function iw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function ow(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function cw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function uw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function dw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function Jd(t,r={}){const{enabled:s=!0,target:o}=r,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(cw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=uw(p.target);for(const v of c.current){if(!dw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const fw=200;function pw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function mw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Ef(g,r)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function hw(t,r){const s=[],o=[],c=[];for(const d of t){const h=pw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Ef(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function xw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Ef(y,r)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function gw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const k=!!g||t.some(P=>P.scope!==void 0&&P.scope!==null),S=g??"claude-cli",[w,C]=m.useState(""),T=m.useDeferredValue(w),N=m.useMemo(()=>hw(t,T),[t,T]),M=m.useMemo(()=>mw(t,T),[t,T]),H=S==="claude-code",{data:L}=Ml("plugins",()=>fetch("/api/plugins").then(P=>P.json()),{enabled:H,ttl:6e4}),F=m.useMemo(()=>{const P=new Map;for(const ee of(L==null?void 0:L.plugins)??[]){const re=P.get(ee.name);P.set(ee.name,!!re||!!ee.enabled)}return P},[L==null?void 0:L.plugins]),[E,O]=m.useState(()=>ef(`vskill-sidebar-${S}-group-available-collapsed`)),[R,D]=m.useState(()=>ef(`vskill-sidebar-${S}-group-authoring-collapsed`)),I=m.useCallback(P=>{O(P);try{window.localStorage.setItem(`vskill-sidebar-${S}-group-available-collapsed`,String(P))}catch{}},[S]),q=m.useCallback(P=>{D(P);try{window.localStorage.setItem(`vskill-sidebar-${S}-group-authoring-collapsed`,String(P))}catch{}},[S]),{own:X,installed:Y}=m.useMemo(()=>xw(t,T),[t,T]),z=N.own.filtered+N.installed.filtered+N.global.filtered>=fw,B=m.useMemo(()=>{const P=ee=>{const re=[];for(const[,xe]of ee){const ce=[...xe].sort((ye,ue)=>ye.skill.localeCompare(ue.skill));re.push(...ce)}return re};return k?[...P(N.own.byPlugin),...P(N.installed.byPlugin),...P(N.global.byPlugin)]:[...P(X.byPlugin),...P(Y.byPlugin)]},[k,N.own.byPlugin,N.installed.byPlugin,N.global.byPlugin,X.byPlugin,Y.byPlugin]),V=m.useMemo(()=>r?B.findIndex(P=>P.plugin===r.plugin&&P.skill===r.skill):-1,[B,r]),W=m.useCallback(P=>{if(B.length===0)return;const ee=V<0?P>0?0:B.length-1:Math.min(Math.max(V+P,0),B.length-1);s(B[ee])},[B,V,s]),de=m.useMemo(()=>{if(!v)return null;const[P,ee]=v.split("/");if(!P||!ee)return null;const re=t.find(ye=>ye.plugin===P&&ye.skill===ee);if(!re)return{plugin:P,skill:ee,bucket:null,pluginName:null};const xe=re.source==="plugin"?"plugin":"project",ce=xe==="plugin"?re.pluginName??P:null;return{plugin:P,skill:ee,bucket:xe,pluginName:ce}},[v,t]),_=m.useRef(null);return m.useEffect(()=>{if(!v){_.current=null;return}if(_.current===v)return;const P=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),ee=document.querySelector(`[data-skill-id="${P}"]`);ee&&(_.current=v,ee.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),Jd([{key:"j",handler:()=>W(1)},{key:"k",handler:()=>W(-1)},{key:"Enter",handler:()=>{V>=0&&s(B[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(Jk,{value:w,onChange:C}),o&&a.jsx(Sw,{}),!o&&c&&a.jsx(kw,{error:c,onRetry:u}),!o&&!c&&k&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Cg,{name:te.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:E,onToggle:I,count:M.availableProject.total+M.availablePersonal.total+M.availablePlugin.total}),!E&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:te.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${S}-available-project-collapsed`,count:M.availableProject.total,filteredCount:w?M.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:M.availableProject.filtered===0?a.jsx(Ng,{queryActive:!!w,agentId:S}):a.jsx(Ts,{items:M.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),a.jsx(Ns,{label:te.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${S}-available-personal-collapsed`,count:M.availablePersonal.total,filteredCount:w?M.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:M.availablePersonal.filtered===0?a.jsx(yw,{queryActive:!!w,agentId:S}):a.jsx(Ts,{items:M.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),H&&a.jsxs(Ns,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${S}-available-plugin-collapsed`,count:M.availablePlugin.total,filteredCount:w?M.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),M.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):M.availablePlugin.byPlugin.map(([P,ee])=>a.jsx(wg,{pluginName:P,skills:ee,persistKey:`vskill-plugin-available-${P}-collapsed`,headerActionSlot:H?a.jsx(sw,{pluginName:P,enabled:F.get(P)??!0}):void 0,renderSkill:re=>a.jsx(Mo,{skill:re,isSelected:(r==null?void 0:r.plugin)===re.plugin&&(r==null?void 0:r.skill)===re.skill,onSelect:()=>s(re),onContextMenu:d})},`available-${P}`))]})]}),a.jsx(jw,{}),a.jsx(Cg,{name:te.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:de?!1:R,onToggle:q,count:M.authoringProject.total+M.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!R||de)&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:te.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${S}-authoring-project-collapsed`,count:M.authoringProject.total,filteredCount:w?M.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(de==null?void 0:de.bucket)==="project",children:M.authoringProject.filtered===0?a.jsx(Eg,{queryActive:!!w}):a.jsx(Ts,{items:M.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),H&&a.jsx(Ns,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${S}-authoring-plugin-collapsed`,count:M.authoringPlugin.total,filteredCount:w?M.authoringPlugin.filtered:null,forceOpen:(de==null?void 0:de.bucket)==="plugin",children:M.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):M.authoringPlugin.byPlugin.map(([P,ee])=>a.jsx(wg,{pluginName:P,skills:ee,persistKey:`vskill-plugin-authoring-${P}-collapsed`,forceOpen:(de==null?void 0:de.bucket)==="plugin"&&de.pluginName===P,renderSkill:re=>a.jsx(Mo,{skill:re,isSelected:(r==null?void 0:r.plugin)===re.plugin&&(r==null?void 0:r.skill)===re.skill,onSelect:()=>s(re),onContextMenu:d})},`authoring-${P}`))})]})]}),!o&&!c&&!k&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(kg,{origin:"source",count:X.total,filteredCount:w?X.filtered:null,updateCount:h==null?void 0:h.source,children:X.filtered===0?a.jsx(Eg,{queryActive:!!w}):a.jsx(Ts,{items:X.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),a.jsx(bw,{}),a.jsx(kg,{origin:"installed",count:Y.total,filteredCount:w?Y.filtered:null,updateCount:h==null?void 0:h.installed,children:Y.filtered===0?a.jsx(Ng,{queryActive:!!w}):a.jsx(Ts,{items:Y.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})})]})]})}function ef(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ns({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>ef(r)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const k=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(k))}catch{}return k})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function vw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ts({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=vw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Lk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Mo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(rw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Eg({queryActive:t}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Nf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ng({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install <plugin>"})," to add one."]})})}function yw({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install --global <plugin>"})," to add one."]})})}function Nl({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Nf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function bw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function jw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function Sw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(ow,{},t))})}function kw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:ww(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function ww(t){const r=t.split(`
65
+ }`})]})}function Xx(){typeof window>"u"||(window.location.hash="#/")}function r2({onHome:t}){const[r,s]=m.useState(!1),[o,c]=m.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),Xx(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),Xx(),t==null||t())};return a.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:r?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),a.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const l2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",s2=m.lazy(()=>Io(()=>import("./UpdateDropdown-Bwk3qR7G.js"),__vite__mapDeps([0,1])));function i2(){const{updateCount:t,updates:r,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,updatesById:u}=Zn(),d=m.useMemo(()=>{if(!u||u.size===0)return;const S=new Map;for(const[w,C]of u)C.diffSummary&&S.set(w,C.diffSummary);return S.size>0?S:void 0},[u]),[h,g]=m.useState(!1),p=m.useRef(null),y=m.useCallback(()=>g(!1),[]),v=t>0?"var(--text-primary)":"var(--text-secondary)",b=t>9?"9+":String(t),k=t===0?"No updates available":`${t} updates available, open summary`;return a.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[a.jsxs("button",{ref:p,type:"button","data-testid":"update-bell","aria-label":k,"aria-haspopup":"dialog","aria-expanded":h,onClick:()=>g(S=>!S),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:v,cursor:"pointer"},children:[a.jsx("img",{src:l2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&a.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:b})]}),h&&a.jsx(m.Suspense,{fallback:a.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:a.jsx(s2,{updates:r,isRefreshing:s,diffSummariesById:d,onRefresh:()=>o(),onSelectSkill:S=>{const w=S.name.split("/"),C=w.length>=2?w[w.length-2]:w[0],T=w[w.length-1];c({plugin:C,skill:T,origin:"installed"}),y()},onViewAll:()=>{window.location.hash="#/updates",y()},onClose:y,anchorRef:p})})]})}function Qx(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function o2({projectName:t,selected:r,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u}){const d=r?r.origin==="installed"?"Project":"Skills":null;return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[a.jsx(r2,{onHome:o}),c?a.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&a.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),a.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:r&&d&&a.jsxs(a.Fragment,{children:[a.jsx(Zx,{segment:"origin",onClick:()=>Qx({scope:"origin",origin:r.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:r.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),a.jsx(Jx,{}),a.jsx(Zx,{segment:"plugin",onClick:()=>Qx({scope:"plugin",plugin:r.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:r.plugin}),a.jsx(Jx,{}),a.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.skill})]})}),a.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[u&&a.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),a.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:a.jsx(n2,{})}),a.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:a.jsx(i2,{})}),a.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:a.jsx("span",{children:"⌘K"})})]})]})}function Zx({segment:t,onClick:r,style:s,children:o}){return a.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:r,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function Jx(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const Ho="vskill-theme";function Nv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function c2(t,r){return t==="light"||t==="dark"?t:r?"dark":"light"}function u2(t){try{const r=t.getItem(Ho);return Nv(r)}catch{return"auto"}}function d2(t,r){try{t.setItem(Ho,r)}catch{}}function f2(t,r,s){t.dataset.theme=s,t.dataset.themeMode=r}function p2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const Tv=m.createContext(null);function m2({storage:t,matchMedia:r,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=r??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=m.useState(()=>c?u2(c):"auto"),[p,y]=m.useState(()=>p2(u)),v=m.useMemo(()=>c2(h,p),[h,p]);m.useEffect(()=>{d&&f2(d,h,v)},[d,h,v]),m.useEffect(()=>{if(!u)return;const S=u("(prefers-color-scheme: dark)"),w=T=>y(T.matches);if(typeof S.addEventListener=="function")return S.addEventListener("change",w),()=>S.removeEventListener("change",w);const C=S;return C.addListener(w),()=>C.removeListener(w)},[u]),m.useEffect(()=>{if(typeof window>"u")return;const S=w=>{w.key===Ho&&g(Nv(w.newValue))};return window.addEventListener("storage",S),()=>window.removeEventListener("storage",S)},[]),m.useEffect(()=>{if(!u||!d)return;let S;try{S=u("(prefers-contrast: more)")}catch{return}const w=N=>{N?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};w(S.matches);const C=N=>w(N.matches);if(typeof S.addEventListener=="function")return S.addEventListener("change",C),()=>S.removeEventListener("change",C);const T=S;return T.addListener(C),()=>T.removeListener(C)},[u,d]);const b=m.useCallback(S=>{g(S),c&&d2(c,S)},[c]),k=m.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return a.jsx(Tv.Provider,{value:k,children:o})}function Rv(){const t=m.useContext(Tv);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const eg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function h2(t){const r=new Map(t.map(o=>[o.id,o])),s=[];for(const o of eg){const c=r.get(o);c&&s.push(c)}for(const o of t)eg.includes(o.id)||s.push(o);return s}function x2(t){const[r,s]=m.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return m.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),r}function g2({providers:t,onOpenSettings:r,onOpenInstallHelp:s}){const o=h2(t),c=x2(640),[u,d]=m.useState(!1),h=m.useCallback(g=>{g.available||g.kind==="api-key"?r==null||r(g.id):s==null||s(g.id)},[r,s]);if(c){const g=o.filter(p=>p.available).length;return a.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[a.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":te.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:te.statusBar.providerSummary(g,o.length)}),u&&a.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(p=>a.jsx(tg,{p,onClick:h},p.id))})]})}return a.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>a.jsx(tg,{p:g,onClick:h,compact:!0},g.id))})}function tg({p:t,onClick:r,compact:s}){const o=t.available?te.statusBar.unlocked(t.label):t.kind==="cli-install"?te.statusBar.lockedCli(t.label):te.statusBar.locked(t.label);return a.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>r(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[a.jsx(Wd,{unlocked:t.available,size:10}),!s&&a.jsx("span",{children:t.label})]})}function v2(){try{return typeof localStorage>"u"?null:localStorage.getItem(Ho)}catch{return null}}function y2({projectPath:t,modelName:r,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:p}=Rv(),v=v2()==="auto",b=b2(h,g,v),k=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return a.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[a.jsx("span",{title:r??"",style:{fontFamily:"var(--font-mono)"},children:r??"—"}),a.jsx(ng,{}),a.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[a.jsx(j2,{color:k}),a.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&a.jsxs(a.Fragment,{children:[a.jsx(ng,{}),a.jsx(g2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),a.jsx("div",{style:{flex:1}}),a.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>p(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[a.jsx(S2,{mode:h}),a.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function b2(t,r,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":r==="light"?"dark":"light"}function j2({color:t}){return a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function ng(){return a.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function S2({mode:t}){return t==="dark"?a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"4"}),a.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const ko=new Map,Lr=new Map,As=new Map;function on(t){ko.delete(t),Lr.delete(t);const r=As.get(t);if(r)for(const s of r)s()}function Ml(t,r,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=m.useState(0),d=m.useRef(!0),h=m.useRef(t);h.current=t;const g=()=>on(t);m.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),m.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(k=>k+1)};return As.has(t)||As.set(t,new Set),As.get(t).add(b),()=>{var k;(k=As.get(t))==null||k.delete(b)}},[t,c]),m.useEffect(()=>{if(!c)return;const b=ko.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Lr.has(t)){const C=Lr.get(t),T=()=>{d.current&&h.current===t&&u(N=>N+1)};C.subscribers.push(T);return}const S={promise:Promise.resolve(),subscribers:[]},w=r().then(C=>{ko.set(t,{data:C,fetchedAt:Date.now()}),Lr.delete(t),d.current&&h.current===t&&u(T=>T+1);for(const T of S.subscribers)T()},C=>{Lr.delete(t),d.current&&h.current===t&&u(T=>T+1);for(const T of S.subscribers)T();throw C});S.promise=w,Lr.set(t,S)},[t,r,o,c]);const p=ko.get(t),y=c&&!p&&Lr.has(t);return{data:p==null?void 0:p.data,loading:y||c&&!p,error:void 0,revalidate:g}}const Uo=0,cr=1,Ll=2,Av=4;function ag(t){return()=>t}function k2(t){t()}function Mv(t,r){return s=>t(r(s))}function rg(t,r){return()=>t(r)}function w2(t,r){return s=>t(r,s)}function mf(t){return t!==void 0}function C2(...t){return()=>{t.map(k2)}}function zl(){}function $o(t,r){return r(t),t}function E2(t,r){return r(t)}function kt(...t){return t}function lt(t,r){return t(cr,r)}function Fe(t,r){t(Uo,r)}function hf(t){t(Ll)}function Et(t){return t(Av)}function Te(t,r){return lt(t,w2(r,Uo))}function Kn(t,r){const s=t(cr,o=>{s(),r(o)});return s}function lg(t){let r,s;return o=>c=>{r=c,s&&clearTimeout(s),s=setTimeout(()=>{o(r)},t)}}function Lv(t,r){return t===r}function St(t=Lv){let r;return s=>o=>{t(r,o)||(r=o,s(o))}}function _e(t){return r=>s=>{t(s)&&r(s)}}function Se(t){return r=>Mv(r,t)}function ra(t){return r=>()=>{r(t)}}function pe(t,...r){const s=N2(...r);return((o,c)=>{switch(o){case Ll:hf(t);return;case cr:return lt(t,s(c))}})}function la(t,r){return s=>o=>{s(r=t(r,o))}}function Dr(t){return r=>s=>{t>0?t--:r(s)}}function Ra(t){let r=null,s;return o=>c=>{r=c,!s&&(s=setTimeout(()=>{s=void 0,o(r)},t))}}function Ge(...t){const r=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;lt(u,g=>{const p=s;s|=h,r[d]=g,p!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(r))};s===c?h():o=h}}function N2(...t){return r=>t.reduceRight(E2,r)}function T2(t){let r,s;const o=()=>r==null?void 0:r();return function(c,u){switch(c){case cr:return u?s===u?void 0:(o(),s=u,r=lt(t,u),r):(o(),zl);case Ll:o(),s=null;return}}}function ge(t){let r=t;const s=Qe();return((o,c)=>{switch(o){case Uo:r=c;break;case cr:{c(r);break}case Av:return r}return s(o,c)})}function tn(t,r){return $o(ge(r),s=>Te(t,s))}function Qe(){const t=[];return((r,s)=>{switch(r){case Uo:t.slice().forEach(o=>{o(s)});return;case Ll:t.splice(0,t.length);return;case cr:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function En(t){return $o(Qe(),r=>Te(t,r))}function nt(t,r=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:r,id:R2(),singleton:s}}const R2=()=>Symbol();function A2(t){const r=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&r.has(u))return r.get(u);const h=o(c.map(g=>s(g)));return d&&r.set(u,h),h};return s(t)}function Bt(...t){const r=Qe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;lt(u,g=>{s[d]=g,o|=h,o===c&&Fe(r,s)})}),function(u,d){switch(u){case Ll:{hf(r);return}case cr:return o===c&&d(s),lt(r,d)}}}function De(t,r=Lv){return pe(t,St(r))}function qd(...t){return function(r,s){switch(r){case Ll:return;case cr:return C2(...t.map(o=>lt(o,s)))}}}const Ut={DEBUG:0,INFO:1,WARN:2,ERROR:3},M2={[Ut.DEBUG]:"debug",[Ut.ERROR]:"error",[Ut.INFO]:"log",[Ut.WARN]:"warn"},L2=()=>typeof globalThis>"u"?window:globalThis,ur=nt(()=>{const t=ge(Ut.ERROR);return{log:ge((r,s,o=Ut.INFO)=>{const c=L2().VIRTUOSO_LOG_LEVEL??Et(t);o>=c&&console[M2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",r,s)}),logLevel:t}},[],{singleton:!0});function Or(t,r,s){return xf(t,r,s).callbackRef}function xf(t,r,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&r?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function z2(t,r,s,o,c,u,d,h,g){const p=Ne.useCallback(y=>{const v=D2(y.children,r,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const k=b.lastElementChild.dataset.viewportType==="window";let S;k&&(S=b.ownerDocument.defaultView);const w=d?h?d.scrollLeft:d.scrollTop:k?h?S.scrollX||S.document.documentElement.scrollLeft:S.scrollY||S.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:k?h?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,T=d?h?d.offsetWidth:d.offsetHeight:k?h?S.innerWidth:S.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(w,0),viewportHeight:T}),u==null||u(h?sg("column-gap",getComputedStyle(y).columnGap,c):sg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,r,c,u,d,o,h]);return xf(p,s,g)}function D2(t,r,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),p=parseFloat(h.dataset.knownSize),y=r(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Ut.ERROR),y===p)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function sg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Ut.WARN),r==="normal"?0:parseInt(r??"0",10)}function zv(t,r,s){const o=Ne.useRef(null),c=Ne.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const p=g.getBoundingClientRect(),y=p.width;let v,b;if(r){const k=r.getBoundingClientRect(),S=p.top-k.top;b=k.height-Math.max(0,S),v=S+r.scrollTop}else{const k=d.current.ownerDocument.defaultView;b=k.innerHeight-Math.max(0,p.top),v=p.top+k.scrollY}o.current={listHeight:p.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,r]),{callbackRef:u,ref:d}=xf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var p;if(r){r.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(r),()=>{r.removeEventListener("scroll",h),y.unobserve(r)}}const g=(p=d.current)==null?void 0:p.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,r,d]),u}const cn=nt(()=>{const t=Qe(),r=Qe(),s=ge(0),o=Qe(),c=ge(0),u=Qe(),d=Qe(),h=ge(0),g=ge(0),p=ge(0),y=ge(0),v=Qe(),b=Qe(),k=ge(!1),S=ge(!1),w=ge(!1);return Te(pe(t,Se(({scrollTop:C})=>C)),r),Te(pe(t,Se(({scrollHeight:C})=>C)),d),Te(r,c),{deviation:s,fixedFooterHeight:p,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:S,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:k,scrollTo:v,scrollTop:r,skipAnimationFrameInResizeObserver:w,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Bs={lvl:0};function Dv(t,r){const s=t.length;if(s===0)return[];let{index:o,value:c}=r(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=r(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function ht(t){return t===Bs}function Is(t,r){if(!ht(t))return r===t.k?t.v:r<t.k?Is(t.l,r):Is(t.r,r)}function Qn(t,r,s="k"){if(ht(t))return[-1/0,void 0];if(Number(t[s])===r)return[t.k,t.v];if(Number(t[s])<r){const o=Qn(t.r,r,s);return o[0]===-1/0?[t.k,t.v]:o}return Qn(t.l,r,s)}function Cn(t,r,s){return ht(t)?Bv(r,s,1):r===t.k?Ht(t,{k:r,v:s}):r<t.k?ig(Ht(t,{l:Cn(t.l,r,s)})):ig(Ht(t,{r:Cn(t.r,r,s)}))}function Cl(){return Bs}function El(t,r,s){if(ht(t))return[];const o=Qn(t,r)[0];return _2(Kd(t,o,s))}function Yd(t,r){if(ht(t))return Bs;const{k:s,l:o,r:c}=t;if(r===s){if(ht(o))return c;if(ht(c))return o;const[u,d]=Ov(o);return wo(Ht(t,{k:u,l:_v(o),v:d}))}return r<s?wo(Ht(t,{l:Yd(o,r)})):wo(Ht(t,{r:Yd(c,r)}))}function zr(t){return ht(t)?[]:[...zr(t.l),{k:t.k,v:t.v},...zr(t.r)]}function Kd(t,r,s){if(ht(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>r&&(h=h.concat(Kd(c,r,s))),o>=r&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(Kd(u,r,s))),h}function wo(t){const{l:r,lvl:s,r:o}=t;if(o.lvl>=s-1&&r.lvl>=s-1)return t;if(s>o.lvl+1){if(bd(r))return Iv(Ht(t,{lvl:s-1}));if(!ht(r)&&!ht(r.r))return Ht(r.r,{l:Ht(r,{r:r.r.l}),lvl:s,r:Ht(t,{l:r.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(bd(t))return Xd(Ht(t,{lvl:s-1}));if(!ht(o)&&!ht(o.l)){const c=o.l,u=bd(c)?o.lvl-1:o.lvl;return Ht(c,{l:Ht(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:Xd(Ht(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Ht(t,r){return Bv(r.k!==void 0?r.k:t.k,r.v!==void 0?r.v:t.v,r.lvl!==void 0?r.lvl:t.lvl,r.l!==void 0?r.l:t.l,r.r!==void 0?r.r:t.r)}function _v(t){return ht(t.r)?t.l:wo(Ht(t,{r:_v(t.r)}))}function bd(t){return ht(t)||t.lvl>t.r.lvl}function Ov(t){return ht(t.r)?[t.k,t.v]:Ov(t.r)}function Bv(t,r,s,o=Bs,c=Bs){return{k:t,l:o,lvl:s,r:c,v:r}}function ig(t){return Xd(Iv(t))}function Iv(t){const{l:r}=t;return!ht(r)&&r.lvl===t.lvl?Ht(r,{r:Ht(t,{l:r.r})}):t}function Xd(t){const{lvl:r,r:s}=t;return!ht(s)&&!ht(s.r)&&s.lvl===r&&s.r.lvl===r?Ht(s,{l:Ht(t,{r:s.l}),lvl:r+1}):t}function _2(t){return Dv(t,({k:r,v:s})=>({index:r,value:s}))}function Hv(t,r){return!!(t&&t.startIndex===r.startIndex&&t.endIndex===r.endIndex)}function Hs(t,r){return!!(t&&t[0]===r[0]&&t[1]===r[1])}const gf=nt(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Uv(t,r,s){return t[Ro(t,r,s)]}function Ro(t,r,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,r);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${r}`)}function O2(t,r,s,o){const c=Ro(t,r,o),u=Ro(t,s,o,c);return t.slice(c,u+1)}function ir(t,r){return Math.round(t.getBoundingClientRect()[r])}function Vo(t){return!ht(t.groupOffsetTree)}function vf({index:t},r){return r===t?0:r<t?-1:1}function B2(){return{groupIndices:[],groupOffsetTree:Cl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Cl()}}function I2(t,r){let s=ht(t)?0:1/0;for(const o of r){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),ht(t)){t=Cn(t,0,u);continue}const h=El(t,d-1,c+1);if(h.some(G2(o)))continue;let g=!1,p=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=Yd(t,v)):(p=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=Cn(t,c+1,b));p&&(t=Cn(t,d,u))}return[t,s]}function H2(t){return typeof t.groupIndex<"u"}function U2({offset:t},r){return r===t?0:r<t?-1:1}function Us(t,r,s){if(r.length===0)return 0;const{index:o,offset:c,size:u}=Uv(r,t,vf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function $v(t,r){if(!Vo(r))return t;let s=0;for(;r.groupIndices[s]<=t+s;)s++;return t+s}function Vv(t,r,s){if(H2(t))return r.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=$v(o,r);return c=Math.max(0,c,Math.min(s,c)),c}function $2(t,r,s,o=0){return o>0&&(r=Math.max(r,Uv(t,o,vf).offset)),Dv(O2(t,r,s,U2),F2)}function V2(t,[r,s,o,c]){r.length>0&&o("received item sizes",r,Ut.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&ht(u)&&r.length===2){const b=r[0].size,k=r[1].size;d=s.reduce((S,w)=>Cn(Cn(S,w,b),w+1,k),d)}else[d,h]=I2(d,r);if(d===u)return t;const{lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v}=Qd(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,k)=>Cn(b,k,Us(k,v,c)),Cl()),lastIndex:g,lastOffset:p,lastSize:y,offsetTree:v,sizeTree:d}}function P2(t){return zr(t).map(({k:r,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:r}})}function og(t,r){let s=0,o=0;for(;s<t;)s+=r[o+1]-r[o]-1,o++;return o-(s===t?0:1)}function Qd(t,r,s,o){let c=t,u=0,d=0,h=0,g=0;if(r!==0){g=Ro(c,r-1,vf),h=c[g].offset;const p=Qn(s,r-1);u=p[0],d=p[1],c.length&&c[g].size===Qn(s,r)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:p,value:y}of El(s,r,1/0)){const v=p-u,b=v*d+h+v*o;c.push({index:p,offset:b,size:y}),u=p,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function F2(t){return{index:t.index,value:t}}function G2(t){const{endIndex:r,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===r||c.end===1/0)&&c.value===s}const W2={offsetHeight:"height",offsetWidth:"width"},ia=nt(([{log:t},{recalcInProgress:r}])=>{const s=Qe(),o=Qe(),c=tn(o,0),u=Qe(),d=Qe(),h=ge(0),g=ge([]),p=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),k=ge((E,O)=>ir(E,W2[O])),S=ge(void 0),w=ge(0),C=B2(),T=tn(pe(s,Ge(g,t,w),la(V2,C),St()),C),N=tn(pe(g,St(),la((E,O)=>({current:O,prev:E.current}),{current:[],prev:[]}),Se(({prev:E})=>E)),[]);Te(pe(g,_e(E=>E.length>0),Ge(T,w),Se(([E,O,R])=>{const D=E.reduce((I,q,X)=>Cn(I,q,Us(q,O.offsetTree,R)||X),Cl());return{...O,groupIndices:E,groupOffsetTree:D}})),T),Te(pe(o,Ge(T),_e(([E,{lastIndex:O}])=>E<O),Se(([E,{lastIndex:O,lastSize:R}])=>[{endIndex:O,size:R,startIndex:E}])),s),Te(p,y);const M=tn(pe(p,Se(E=>E===void 0)),!0);Te(pe(y,_e(E=>E!==void 0&&ht(Et(T).sizeTree)),Se(E=>{const O=Et(v),R=Et(g).length>0;return O!==void 0&&O!==0?R?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:E,startIndex:1}]:[]:[{endIndex:0,size:E,startIndex:0}]})),s),Te(pe(b,_e(E=>E!==void 0&&E.length>0&&ht(Et(T).sizeTree)),Se(E=>{const O=[];let R=E[0],D=0;for(let I=1;I<E.length;I++){const q=E[I];q!==R&&(O.push({endIndex:I-1,size:R,startIndex:D}),R=q,D=I)}return O.push({endIndex:E.length-1,size:R,startIndex:D}),O})),s),Te(pe(g,Ge(v,y),_e(([,E,O])=>E!==void 0&&O!==void 0),Se(([E,O,R])=>{const D=[];for(let I=0;I<E.length;I++){const q=E[I],X=E[I+1];D.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&D.push({startIndex:q+1,endIndex:X-1,size:R})}return D})),s);const H=En(pe(s,Ge(T),la(({sizes:E},[O,R])=>({changed:R!==E,sizes:R}),{changed:!1,sizes:C}),Se(E=>E.changed)));lt(pe(h,la((E,O)=>({diff:E.prev-O,prev:O}),{diff:0,prev:0}),Se(E=>E.diff)),E=>{const{groupIndices:O}=Et(T);if(E>0)Fe(r,!0),Fe(u,E+og(E,O));else if(E<0){const R=Et(N);R.length>0&&(E-=og(-E,R)),Fe(d,E)}}),lt(pe(h,Ge(t)),([E,O])=>{E<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Ut.ERROR)});const L=En(u);Te(pe(u,Ge(T),Se(([E,O])=>{const R=O.groupIndices.length>0,D=[],I=O.lastSize;if(R){const q=Is(O.sizeTree,0);let X=0,Y=0;for(;X<E;){const z=O.groupIndices[Y],B=O.groupIndices.length===Y+1?1/0:O.groupIndices[Y+1]-z-1;D.push({endIndex:z,size:q,startIndex:z}),D.push({endIndex:z+1+B-1,size:I,startIndex:z+1}),Y++,X+=B+1}const U=zr(O.sizeTree);return X!==E&&U.shift(),U.reduce((z,{k:B,v:V})=>{let W=z.ranges;return z.prevSize!==0&&(W=[...z.ranges,{endIndex:B+E-1,size:z.prevSize,startIndex:z.prevIndex}]),{prevIndex:B+E,prevSize:V,ranges:W}},{prevIndex:E,prevSize:0,ranges:D}).ranges}return zr(O.sizeTree).reduce((q,{k:X,v:Y})=>({prevIndex:X+E,prevSize:Y,ranges:[...q.ranges,{endIndex:X+E-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:I,ranges:[]}).ranges})),s);const F=En(pe(d,Ge(T,w),Se(([E,{offsetTree:O},R])=>{const D=-E;return Us(D,O,R)})));return Te(pe(d,Ge(T,w),Se(([E,O,R])=>{if(O.groupIndices.length>0){if(ht(O.sizeTree))return O;let I=Cl();const q=Et(N);let X=0,Y=0,U=0;for(;X<-E;){U=q[Y];const z=q[Y+1]-U-1;Y++,X+=z+1}if(I=zr(O.sizeTree).reduce((z,{k:B,v:V})=>Cn(z,Math.max(0,B+E),V),I),X!==-E){const z=Is(O.sizeTree,U);I=Cn(I,0,z);const B=Qn(O.sizeTree,-E+1)[1];I=Cn(I,1,B)}return{...O,sizeTree:I,...Qd(O.offsetTree,0,I,R)}}const D=zr(O.sizeTree).reduce((I,{k:q,v:X})=>Cn(I,Math.max(0,q+E),X),Cl());return{...O,sizeTree:D,...Qd(O.offsetTree,0,D,R)}})),T),{beforeUnshiftWith:L,data:S,defaultItemSize:y,firstItemIndex:h,fixedItemSize:p,fixedGroupSize:v,gap:w,groupIndices:g,heightEstimates:b,itemSize:k,listRefresh:H,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:T,statefulTotalCount:c,totalCount:o,trackItemSizes:M,unshiftWith:u}},kt(ur,gf),{singleton:!0});function q2(t){return t.reduce((r,s)=>(r.groupIndices.push(r.totalCount),r.totalCount+=s+1,r),{groupIndices:[],totalCount:0})}const Pv=nt(([{groupIndices:t,sizes:r,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Qe(),d=Qe(),h=En(pe(u,Se(q2)));return Te(pe(h,Se(g=>g.totalCount)),s),Te(pe(h,Se(g=>g.groupIndices)),t),Te(pe(Bt(c,r,o),_e(([g,p])=>Vo(p)),Se(([g,p,y])=>Qn(p.groupOffsetTree,Math.max(g-y,0),"v")[0]),St(),Se(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},kt(ia,cn)),dr=nt(([{log:t}])=>{const r=ge(!1),s=En(pe(r,_e(o=>o),St()));return lt(r,o=>{o&&Et(t)("props updated",{},Ut.DEBUG)}),{didMount:s,propsReady:r}},kt(ur),{singleton:!0}),Y2=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Fv(t){const r=typeof t=="number"?{index:t}:t;return r.align||(r.align="start"),(!r.behavior||!Y2)&&(r.behavior="auto"),r.offset===void 0&&(r.offset=0),r}const Ws=nt(([{gap:t,listRefresh:r,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:p,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const k=Qe(),S=Qe(),w=ge(0);let C=null,T=null,N=null;function M(){C!==null&&(C(),C=null),N!==null&&(N(),N=null),T&&(clearTimeout(T),T=null),Fe(g,!1)}return Te(pe(k,Ge(s,v,o,w,h,d,b),Ge(t,u,c),Se(([[H,L,F,E,O,R,D,I],q,X,Y])=>{const U=Fv(H),{align:z,behavior:B,offset:V}=U,W=E-1,de=Vv(U,L,W);let _=Us(de,L.offsetTree,q)+R;z==="end"?(_+=X+Qn(L.sizeTree,de)[1]-F+Y,de===W&&(_+=D)):z==="center"?_+=(X+Qn(L.sizeTree,de)[1]-F+Y)/2:_-=O,V!==void 0&&V!==0&&(_+=V);const P=ee=>{M(),ee?(I("retrying to scroll to",{location:H},Ut.DEBUG),Fe(k,H)):(Fe(S,!0),I("list did not change, scroll successful",{},Ut.DEBUG))};if(M(),B==="smooth"){let ee=!1;N=lt(r,re=>{ee=ee||re}),C=Kn(y,()=>{P(ee)})}else C=Kn(pe(r,K2(150)),P);return T=setTimeout(()=>{M()},1200),Fe(g,!0),I("scrolling from index to",{behavior:B,index:de,top:_},Ut.DEBUG),{behavior:B,top:_}})),p),{scrollTargetReached:S,scrollToIndex:k,topListHeight:w}},kt(ia,cn,ur),{singleton:!0});function K2(t){return r=>{const s=setTimeout(()=>{r(!1)},t);return o=>{o&&(r(!0),clearTimeout(s))}}}function yf(t,r){t===0?r():requestAnimationFrame(()=>{yf(t-1,r)})}function bf(t,r){const s=r-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const qs=nt(([{defaultItemSize:t,listRefresh:r,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),g=ge(0),p=ge(!0);return Te(pe(d,Ge(g),_e(([y,v])=>v!==0),ra(!1)),h),Te(pe(d,Ge(g),_e(([y,v])=>v!==0),ra(!1)),p),lt(pe(Bt(r,d),Ge(h,s,t,p),_e(([[,y],v,{sizeTree:b},k,S])=>y&&(!ht(b)||mf(k))&&!v&&!S),Ge(g)),([,y])=>{Kn(c,()=>{Fe(p,!0)}),yf(4,()=>{Kn(o,()=>{Fe(h,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:p,initialTopMostItemIndex:g,scrolledToInitialItem:h}},kt(ia,cn,Ws,dr),{singleton:!0});function Gv(t,r){return Math.abs(t-r)<1.01}const $s="up",zs="down",X2="none",Q2={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Z2=0,Ys=nt(([{footerHeight:t,headerHeight:r,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),g=Qe(),p=Qe(),y=ge(4),v=ge(Z2),b=tn(pe(qd(pe(De(c),Dr(1),ra(!0)),pe(De(c),Dr(1),ra(!1),lg(100))),St()),!1),k=tn(pe(qd(pe(s,ra(!0)),pe(s,ra(!1),lg(200))),St()),!1);Te(pe(Bt(De(c),De(v)),Se(([N,M])=>N<=M),St()),h),Te(pe(h,Ra(50)),p);const S=En(pe(Bt(o,De(u),De(r),De(t),De(y)),la((N,[{scrollHeight:M,scrollTop:H},L,F,E,O])=>{const R=H+L-M>-O,D={scrollHeight:M,scrollTop:H,viewportHeight:L};if(R){let q,X;return H>N.state.scrollTop?(q="SCROLLED_DOWN",X=N.state.scrollTop-H):(q="SIZE_DECREASED",X=N.state.scrollTop-H||N.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:D}}let I;return D.scrollHeight>N.state.scrollHeight?I="SIZE_INCREASED":L<N.state.viewportHeight?I="VIEWPORT_HEIGHT_DECREASING":H<N.state.scrollTop?I="SCROLLING_UPWARDS":I="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:I,state:D}},Q2),St((N,M)=>N!==void 0&&N.atBottom===M.atBottom))),w=tn(pe(o,la((N,{scrollHeight:M,scrollTop:H,viewportHeight:L})=>{if(!Gv(N.scrollHeight,M)){const F=M-(H+L)<1;return N.scrollTop!==H&&F?{changed:!0,jump:N.scrollTop-H,scrollHeight:M,scrollTop:H}:{changed:!0,jump:0,scrollHeight:M,scrollTop:H}}return{changed:!1,jump:0,scrollHeight:M,scrollTop:H}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),_e(N=>N.changed),Se(N=>N.jump)),0);Te(pe(S,Se(N=>N.atBottom)),d),Te(pe(d,Ra(50)),g);const C=ge(zs);Te(pe(o,Se(({scrollTop:N})=>N),St(),la((N,M)=>Et(k)?{direction:N.direction,prevScrollTop:M}:{direction:M<N.prevScrollTop?$s:zs,prevScrollTop:M},{direction:zs,prevScrollTop:0}),Se(N=>N.direction)),C),Te(pe(o,Ra(50),ra(X2)),C);const T=ge(0);return Te(pe(b,_e(N=>!N),ra(0)),T),Te(pe(c,Ra(100),Ge(b),_e(([N,M])=>M),la(([N,M],[H])=>[M,H],[0,0]),Se(([N,M])=>M-N)),T),{atBottomState:S,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:p,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:w,scrollDirection:C,scrollVelocity:T}},kt(cn)),Vs="top",Ps="bottom",cg="none";function ug(t,r,s){return typeof t=="number"?s===$s&&r===Vs||s===zs&&r===Ps?t:0:s===$s?r===Vs?t.main:t.reverse:r===Ps?t.main:t.reverse}function dg(t,r){return typeof t=="number"?t:t[r]??0}const jf=nt(([{deviation:t,fixedHeaderHeight:r,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Qe(),d=ge(0),h=ge(0),g=ge(0),p=tn(pe(Bt(De(o),De(c),De(s),De(u,Hs),De(g),De(d),De(r),De(t),De(h)),Se(([y,v,b,[k,S],w,C,T,N,M])=>{const H=y-N,L=C+T,F=Math.max(b-H,0);let E=cg;const O=dg(M,Vs),R=dg(M,Ps);return k-=N,k+=b+T,S+=b+T,S-=N,k>y+L-O&&(E=$s),S<y-F+v+R&&(E=zs),E!==cg?[Math.max(H-b-ug(w,Vs,E)-O,0),H-F-T+v+ug(w,Ps,E)+R]:null}),_e(y=>y!==null),St(Hs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:p}},kt(cn),{singleton:!0});function J2(t,r,s){if(Vo(r)){const o=$v(t,r);return[{index:Qn(r.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const jd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Co(t,r,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let p=0,y=0;if(t.length>0){p=t[0].offset;const w=t[t.length-1];y=w.offset+w.size}const v=s-d,b=h+v*g+(v-1)*o,k=p,S=b-y;return{bottom:y,firstItemIndex:u,items:fg(t,c,u),offsetBottom:S,offsetTop:p,top:k,topItems:fg(r,c,u),topListHeight:r.reduce((w,C)=>C.size+w,0),totalCount:s}}function Wv(t,r,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=bf(r,h),p=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Co(p,[],h,c,s,o)}function fg(t,r,s){if(t.length===0)return[];if(!Vo(r))return t.map(p=>({...p,index:p.index+s,originalIndex:p.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=El(r.groupOffsetTree,o,c);let h,g=0;for(const p of t){(!h||h.end<p.index)&&(h=d.shift(),g=r.groupIndices.indexOf(h.start));let y;p.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:p.index-(g+1)+s},u.push({...y,data:p.data,offset:p.offset,originalIndex:p.index,size:p.size})}return u}function pg(t,r){return t===void 0?0:typeof t=="number"?t:t[r]??0}const Br=nt(([{data:t,firstItemIndex:r,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:p,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:k},{recalcInProgress:S}])=>{const w=ge([]),C=ge(0),T=Qe(),N=ge(0);Te(u.topItemsIndexes,w);const M=tn(pe(Bt(k,S,De(g,Hs),De(c),De(o),De(p),y,De(w),De(r),De(s),De(N),t),_e(([E,O,,R,,,,,,,,D])=>{const I=D!==void 0&&D.length!==R;return E&&!O&&!I}),Se(([,,[E,O],R,D,I,q,X,Y,U,z,B])=>{var je,Re;const V=D,{offsetTree:W,sizeTree:de}=V,_=Et(C);if(R===0)return{...jd,totalCount:R};if(E===0&&O===0)return _===0?{...jd,totalCount:R}:Wv(_,I,D,Y,U,B||[]);if(ht(de))return _>0?null:Co(J2(bf(I,R),V,B),[],R,U,V,Y);const P=[];if(X.length>0){const Le=X[0],ae=X[X.length-1];let fe=0;for(const me of El(de,Le,ae)){const he=me.value,be=Math.max(me.start,Le),Be=Math.min(me.end,ae);for(let Oe=be;Oe<=Be;Oe++)P.push({data:B==null?void 0:B[Oe],index:Oe,offset:fe,size:he}),fe+=he}}if(!q)return Co([],P,R,U,V,Y);const ee=X.length>0?X[X.length-1]+1:0,re=$2(W,E,O,ee);if(re.length===0)return null;const xe=R-1,ce=$o([],Le=>{for(const ae of re){const fe=ae.value;let me=fe.offset,he=ae.start;const be=fe.size;if(fe.offset<E){he+=Math.floor((E-fe.offset+U)/(be+U));const Oe=he-ae.start;me+=Oe*be+Oe*U}he<ee&&(me+=(ee-he)*be,he=ee);const Be=Math.min(ae.end,xe);for(let Oe=he;Oe<=Be&&!(me>=O);Oe++)Le.push({data:B==null?void 0:B[Oe],index:Oe,offset:me,size:be}),me+=be+U}}),ye=pg(z,Vs),ue=pg(z,Ps);if(ce.length>0&&(ye>0||ue>0)){const Le=ce[0],ae=ce[ce.length-1];if(ye>0&&Le.index>ee){const fe=Math.min(ye,Le.index-ee),me=[];let he=Le.offset;for(let be=Le.index-1;be>=Le.index-fe;be--){const Be=((je=El(de,be,be)[0])==null?void 0:je.value)??Le.size;he-=Be+U,me.unshift({data:B==null?void 0:B[be],index:be,offset:he,size:Be})}ce.unshift(...me)}if(ue>0&&ae.index<xe){const fe=Math.min(ue,xe-ae.index);let me=ae.offset+ae.size+U;for(let he=ae.index+1;he<=ae.index+fe;he++){const be=((Re=El(de,he,he)[0])==null?void 0:Re.value)??ae.size;ce.push({data:B==null?void 0:B[he],index:he,offset:me,size:be}),me+=be+U}}}return Co(ce,P,R,U,V,Y)}),_e(E=>E!==null),St()),jd);Te(pe(t,_e(mf),Se(E=>E==null?void 0:E.length)),c),Te(pe(M,Se(E=>E.topListHeight)),v),Te(v,h),Te(pe(M,Se(E=>[E.top,E.bottom])),d),Te(pe(M,Se(E=>E.items)),T);const H=En(pe(M,_e(({items:E})=>E.length>0),Ge(c,t),_e(([{items:E},O])=>E[E.length-1].originalIndex===O-1),Se(([,E,O])=>[E-1,O]),St(Hs),Se(([E])=>E))),L=En(pe(M,Ra(200),_e(({items:E,topItems:O})=>E.length>0&&E[0].originalIndex===O.length),Se(({items:E})=>E[0].index),St())),F=En(pe(M,_e(({items:E})=>E.length>0),Se(({items:E})=>{let O=0,R=E.length-1;for(;E[O].type==="group"&&O<R;)O++;for(;E[R].type==="group"&&R>O;)R--;return{endIndex:E[R].index,startIndex:E[O].index}}),St(Hv)));return{endReached:H,initialItemCount:C,itemsRendered:T,listState:M,minOverscanItemCount:N,rangeChanged:F,startReached:L,topItemsIndexes:w,...b}},kt(ia,Pv,jf,qs,Ws,Ys,dr,gf),{singleton:!0}),qv=nt(([{fixedFooterHeight:t,fixedHeaderHeight:r,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Qe(),d=tn(pe(Bt(s,t,o,r,c),Se(([h,g,p,y,v])=>h+g+p+y+v.offsetBottom+v.bottom)),0);return Te(De(d),u),{totalListHeight:d,totalListHeightChanged:u}},kt(cn,Br),{singleton:!0}),ek=nt(([{viewportHeight:t},{totalListHeight:r}])=>{const s=ge(!1),o=tn(pe(Bt(s,t,r),_e(([c])=>c),Se(([,c,u])=>Math.max(0,c-u)),Ra(0),St()),0);return{alignToBottom:s,paddingTopAddition:o}},kt(cn,qv),{singleton:!0}),Yv=nt(()=>({context:ge(null)})),tk=({itemBottom:t,itemTop:r,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>r<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,Kv=nt(([{gap:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:p}])=>{const y=Qe();return Te(pe(y,Ge(r,g,s,u,c,o,h),Ge(t),Se(([[v,b,k,S,w,C,T,N],M])=>{const{calculateViewLocation:H=tk,done:L,...F}=v,E=Vv(v,b,S-1),O=Us(E,b.offsetTree,M)+w+C,R=O+Qn(b.sizeTree,E)[1],D=N+C,I=N+k-T,q=H({itemBottom:R,itemTop:O,locationParams:F,viewportBottom:I,viewportTop:D});return q!==null?L&&Kn(pe(d,_e(X=>!X),Dr(Et(d)?1:2)),L):L==null||L(),q}),_e(v=>v!==null)),p),{scrollIntoView:y}},kt(ia,cn,Ws,Br,ur),{singleton:!0});function mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const nk=(t,r)=>typeof t=="function"?mg(t(r)):r&&mg(t),ak=nt(([{listRefresh:t,totalCount:r,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:p},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:k}])=>{const S=ge(!1),w=Qe();let C=null;function T(L){Fe(d,{align:"end",behavior:L,index:"LAST"})}lt(pe(Bt(pe(De(r),Dr(1)),g),Ge(De(S),u,h,v),Se(([[L,F],E,O,R,D])=>{let I=F&&R,q="auto";return I&&(q=nk(E,O||D),I=I&&q!==!1),{followOutputBehavior:q,shouldFollow:I,totalCount:L}}),_e(({shouldFollow:L})=>L)),({followOutputBehavior:L,totalCount:F})=>{C!==null&&(C(),C=null),Et(s)!==void 0?requestAnimationFrame(()=>{Et(y)("following output to ",{totalCount:F},Ut.DEBUG),T(L)}):C=Kn(t,()=>{Et(y)("following output to ",{totalCount:F},Ut.DEBUG),T(L),C=null})});function N(L){const F=Kn(c,E=>{L&&!E.atBottom&&E.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(Et(y)("scrolling to bottom due to increased size",{},Ut.DEBUG),T("auto"))});setTimeout(F,100)}lt(pe(Bt(De(S),r,p),_e(([L,,F])=>L!==!1&&F),la(({value:L},[,F])=>({refreshed:L===F,value:F}),{refreshed:!1,value:0}),_e(({refreshed:L})=>L),Ge(S,r)),([,L])=>{Et(h)&&N(L!==!1)}),lt(w,()=>{N(Et(S)!==!1)}),lt(Bt(De(S),c),([L,F])=>{L!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&T("auto")});const M=ge(null),H=Qe();return Te(qd(pe(De(o),Se(L=>(L==null?void 0:L.length)??0)),pe(De(r))),H),lt(pe(Bt(pe(H,Dr(1)),g),Ge(De(M),h,v,b),Se(([[L,F],E,O,R,D])=>F&&O&&(E==null?void 0:E({context:D,totalCount:L,scrollingInProgress:R}))),_e(L=>!!L),Ra(0)),L=>{C!==null&&(C(),C=null),Et(s)!==void 0?requestAnimationFrame(()=>{Et(y)("scrolling into view",{}),Fe(k,L)}):C=Kn(t,()=>{Et(y)("scrolling into view",{}),Fe(k,L),C=null})}),{autoscrollToBottom:w,followOutput:S,scrollIntoViewOnChange:M}},kt(ia,Ys,Ws,qs,dr,ur,cn,Yv,Kv)),rk=nt(([{data:t,firstItemIndex:r,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(pe(h,Ge(u),_e(([,g])=>g!==0),Ge(c,o,r,s,t),Se(([[,g],p,y,v,b,k=[]])=>Wv(g,p,y,v,b,k))),d),{}),kt(ia,qs,Br,dr),{singleton:!0}),lk=nt(([{didMount:t},{scrollTo:r},{listState:s}])=>{const o=ge(0);return lt(pe(t,Ge(o),_e(([,c])=>c!==0),Se(([,c])=>({top:c}))),c=>{Kn(pe(s,Dr(1),_e(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(r,c)})})}),{initialScrollTop:o}},kt(dr,cn,Br),{singleton:!0}),Xv=nt(([{scrollVelocity:t}])=>{const r=ge(!1),s=Qe(),o=ge(!1);return Te(pe(t,Ge(o,r,s),_e(([c,u])=>u!==!1&&u!==void 0),Se(([c,u,d,h])=>{const{enter:g,exit:p}=u;if(d){if(p(c,h))return!1}else if(g(c,h))return!0;return d}),St()),r),lt(pe(Bt(r,t,s),Ge(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:r,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},kt(Ys),{singleton:!0}),Sf=nt(([{scrollContainerState:t,scrollTo:r}])=>{const s=Qe(),o=Qe(),c=Qe(),u=ge(!1),d=ge(void 0);return Te(pe(Bt(s,o),Se(([{scrollTop:h,viewportHeight:g},{offsetTop:p,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-p),viewportHeight:g}))),t),Te(pe(r,Ge(o),Se(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},kt(cn)),sk=nt(([{sizeRanges:t,sizes:r},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const p=Qe(),y=ge(void 0),v=ge(null),b=ge(null);return Te(h,v),Te(g,b),lt(pe(p,Ge(r,o,d,v,b,s)),([k,S,w,C,T,N,M])=>{const H=P2(S.sizeTree);C&&T!==null&&N!==null&&(w=T.scrollTop-N.offsetTop),w-=M,k({ranges:H,scrollTop:w})}),Te(pe(y,_e(mf),Se(ik)),c),Te(pe(u,Ge(y),_e(([,k])=>k!==void 0),St(),Se(([,k])=>k.ranges)),t),{getState:p,restoreStateFrom:y}},kt(ia,cn,qs,dr,Sf));function ik(t){return{align:"start",index:0,offset:t.scrollTop}}const ok=nt(([{topItemsIndexes:t}])=>{const r=ge(0);return Te(pe(r,_e(s=>s>=0),Se(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:r}},kt(Br));function Qv(t){let r=!1,s;return(()=>(r||(r=!0,s=t()),s))}const ck=Qv(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),uk=nt(([{deviation:t,scrollBy:r,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:p,gap:y,shiftWithOffset:v,sizes:b},{log:k},{recalcInProgress:S}])=>{const w=En(pe(g,Ge(d),la(([,T,N,M],[{bottom:H,items:L,offsetBottom:F,totalCount:E},O])=>{const R=H+F;let D=0;return N===E&&T.length>0&&L.length>0&&(L[0].originalIndex===0&&T[0].originalIndex===0||(D=R-M,D!==0&&(D+=O))),[D,L,E,R]},[0,[],0,0]),_e(([T])=>T!==0),Ge(o,h,s,c,k,S),_e(([,T,N,M,,,H])=>!H&&!M&&T!==0&&N===$s),Se(([[T],,,,,N])=>(N("Upward scrolling compensation",{amount:T},Ut.DEBUG),T))));function C(T){T>0?(Fe(r,{behavior:"auto",top:-T}),Fe(t,0)):(Fe(t,0),Fe(r,{behavior:"auto",top:-T}))}return lt(pe(w,Ge(t,u)),([T,N,M])=>{M&&ck()?Fe(t,N-T):C(-T)}),lt(pe(Bt(tn(u,!1),t,S),_e(([T,N,M])=>!T&&!M&&N!==0),Se(([T,N])=>N),Ra(1)),C),Te(pe(v,Se(T=>({top:-T}))),r),lt(pe(p,Ge(b,y),Se(([T,{groupIndices:N,lastSize:M,sizeTree:H},L])=>{function F(I){return I*(M+L)}if(N.length===0)return F(T);let E=0;const O=Is(H,0);let R=0,D=0;for(;R<T;){R++,E+=O;let I=N.length===D+1?1/0:N[D+1]-N[D]-1;R+I>T&&(E-=O,I=T-R+1),R+=I,E+=F(I),D++}return E})),T=>{Fe(t,T),requestAnimationFrame(()=>{Fe(r,{top:T}),requestAnimationFrame(()=>{Fe(t,0),Fe(S,!1)})})}),{deviation:t}},kt(cn,Ys,Br,ia,ur,gf)),dk=nt(([t,r,s,o,c,u,d,h,g,p,y])=>({...t,...r,...s,...o,...c,...u,...d,...h,...g,...p,...y}),kt(jf,rk,dr,Xv,qv,lk,ek,Sf,Kv,ur,Yv)),Zv=nt(([{data:t,defaultItemSize:r,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:p,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:k},{initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:C},T,N,M,H,{scrollToIndex:L},F,{topItemCount:E},{groupCounts:O},R])=>{const{listState:D,minOverscanItemCount:I,topItemsIndexes:q,rangeChanged:X,...Y}=H;return Te(X,R.scrollSeekRangeChanged),Te(pe(R.windowViewportRect,Se(U=>U.visibleHeight)),T.viewportHeight),{data:t,defaultItemHeight:r,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:S,initialTopMostItemIndex:w,scrolledToInitialItem:C,sizeRanges:p,topItemCount:E,topItemsIndexes:q,totalCount:b,...M,groupIndices:d,itemSize:g,listState:D,minOverscanItemCount:I,scrollToIndex:L,statefulTotalCount:v,trackItemSizes:k,rangeChanged:X,...Y,...R,...T,sizes:y,...N}},kt(ia,qs,cn,sk,ak,Br,Ws,uk,ok,Pv,dk));function fk(t,r){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in r)Object.hasOwn(o,d)||(s[d]=r[d]);return s}const uo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Jv(t,r,s){const o=Object.keys(r.required||{}),c=Object.keys(r.optional||{}),u=Object.keys(r.methods||{}),d=Object.keys(r.events||{}),h=Ne.createContext({});function g(C,T){C.propsReady!==void 0&&Fe(C.propsReady,!1);for(const N of o){const M=C[r.required[N]];Fe(M,T[N])}for(const N of c)if(N in T){const M=C[r.optional[N]];Fe(M,T[N])}C.propsReady!==void 0&&Fe(C.propsReady,!0)}function p(C){return u.reduce((T,N)=>(T[N]=M=>{const H=C[r.methods[N]];Fe(H,M)},T),{})}function y(C){return d.reduce((T,N)=>(T[N]=T2(C[r.events[N]]),T),{})}const v=Ne.forwardRef(function(C,T){const{children:N,...M}=C,[H]=Ne.useState(()=>$o(A2(t),E=>{g(E,M)})),[L]=Ne.useState(rg(y,H));uo(()=>{for(const E of d)E in M&&lt(L[E],M[E]);return()=>{Object.values(L).map(hf)}},[M,L,H]),uo(()=>{g(H,M)}),Ne.useImperativeHandle(T,ag(p(H)));const F=s;return a.jsx(h.Provider,{value:H,children:s!==void 0?a.jsx(F,{...fk([...o,...c,...d],M),children:N}):N})}),b=C=>{const T=Ne.useContext(h);return Ne.useCallback(N=>{Fe(T[C],N)},[T,C])},k=C=>{const T=Ne.useContext(h)[C],N=Ne.useCallback(M=>lt(T,M),[T]);return Ne.useSyncExternalStore(N,()=>Et(T),()=>Et(T))},S=C=>{const T=Ne.useContext(h)[C],[N,M]=Ne.useState(rg(Et,T));return uo(()=>lt(T,H=>{H!==N&&M(ag(H))}),[T,N]),N},w=parseInt(Ne.version)>=18?k:S;return{Component:v,useEmitter:(C,T)=>{const N=Ne.useContext(h)[C];uo(()=>lt(N,T),[T,N])},useEmitterValue:w,usePublisher:b}}const ey=Ne.createContext(void 0),ty=Ne.createContext(void 0),Sd="-webkit-sticky",hg="sticky",kf=Qv(()=>{if(typeof document>"u")return hg;const t=document.createElement("div");return t.style.position=Sd,t.style.position===Sd?Sd:hg}),ny=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function kd(t){return"self"in t}function pk(t){return"body"in t}function ay(t,r,s,o=zl,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),g=Ne.useRef(null),p=Ne.useCallback(b=>{let k,S,w;const C=b.target;if(pk(C)||kd(C)){const N=kd(C)?C:C.defaultView;w=u===!0?N.scrollX:N.scrollY,k=u===!0?N.document.documentElement.scrollWidth:N.document.documentElement.scrollHeight,S=u===!0?N.innerWidth:N.innerHeight}else w=u===!0?C.scrollLeft:C.scrollTop,k=u===!0?C.scrollWidth:C.scrollHeight,S=u===!0?C.offsetWidth:C.offsetHeight;const T=()=>{t({scrollHeight:k,scrollTop:Math.max(w,0),viewportHeight:S})};b.suppressFlushSync===!0?T():Bj.flushSync(T),h.current!==null&&(w===h.current||w<=0||w===k-S)&&(h.current=null,r(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,r,u]);Ne.useEffect(()=>{const b=c||d.current;return o(c||d.current),p({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",p,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",p)}},[d,p,s,o,c]);function y(b){const k=d.current;if(!k||(u===!0?"offsetWidth"in k&&k.offsetWidth===0:"offsetHeight"in k&&k.offsetHeight===0))return;const S=b.behavior==="smooth";let w,C,T;kd(k)?(C=Math.max(ir(k.document.documentElement,u===!0?"width":"height"),u===!0?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight),w=u===!0?k.innerWidth:k.innerHeight,T=u===!0?window.scrollX:window.scrollY):(C=k[u===!0?"scrollWidth":"scrollHeight"],w=ir(k,u===!0?"width":"height"),T=k[u===!0?"scrollLeft":"scrollTop"]);const N=C-w;if(b.top=Math.ceil(Math.max(Math.min(N,b.top),0)),Gv(w,C)||b.top===T){t({scrollHeight:C,scrollTop:T,viewportHeight:w}),S&&r(!0);return}S?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,r(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),k.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 wf(t){return t}const mk=nt(()=>{const t=ge(h=>`Item ${h}`),r=ge(h=>`Group ${h}`),s=ge({}),o=ge(wf),c=ge("div"),u=ge(zl),d=(h,g=null)=>tn(pe(s,Se(p=>p[h]),St()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:r,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),hk=nt(([t,r])=>({...t,...r}),kt(Zv,mk)),xk=({height:t})=>a.jsx("div",{style:{height:t}}),gk={overflowAnchor:"none",position:kf(),zIndex:1},ry={overflowAnchor:"none"},vk={...ry,display:"inline-block",height:"100%"},xg=Ne.memo(function({showTopList:t=!1}){const r=He("listState"),s=$n("sizeRanges"),o=He("useWindowScroll"),c=He("customScrollParent"),u=$n("windowScrollContainerState"),d=$n("scrollContainerState"),h=c||o?u:d,g=He("itemContent"),p=He("context"),y=He("groupContent"),v=He("trackItemSizes"),b=He("itemSize"),k=He("log"),S=$n("gap"),w=He("horizontalDirection"),{callbackRef:C}=z2(s,b,v,t?zl:h,k,S,c,w,He("skipAnimationFrameInResizeObserver")),[T,N]=Ne.useState(0);Cf("deviation",Y=>{T!==Y&&N(Y)});const M=He("EmptyPlaceholder"),H=He("ScrollSeekPlaceholder")??xk,L=He("ListComponent"),F=He("ItemComponent"),E=He("GroupComponent"),O=He("computeItemKey"),R=He("isSeeking"),D=He("groupIndices").length>0,I=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...w?{display:"inline-block",height:"100%",marginLeft:T!==0?T:I?"auto":0,paddingLeft:r.offsetTop,paddingRight:r.offsetBottom,whiteSpace:"nowrap"}:{marginTop:T!==0?T:I?"auto":0,paddingBottom:r.offsetBottom,paddingTop:r.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&r.totalCount===0&&M!==null&&M!==void 0?a.jsx(M,{...en(M,p)}):a.jsx(L,{...en(L,p),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?r.topItems:r.items).map(Y=>{const U=Y.originalIndex,z=O(U+r.firstItemIndex,Y.data,p);return R?m.createElement(H,{...en(H,p),height:Y.size,index:Y.index,key:z,type:Y.type||"item",...Y.type==="group"?{}:{groupIndex:Y.groupIndex}}):Y.type==="group"?m.createElement(E,{...en(E,p),"data-index":U,"data-item-index":Y.index,"data-known-size":Y.size,key:z,style:gk},y(Y.index,p)):m.createElement(F,{...en(F,p),...Sk(F,Y.data),"data-index":U,"data-item-group-index":Y.groupIndex,"data-item-index":Y.index,"data-known-size":Y.size,key:z,style:w?vk:ry},D?g(Y.index,Y.groupIndex,Y.data,p):g(Y.index,Y.data,p))})})}),yk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},bk={outline:"none",overflowX:"auto",position:"relative"},Po=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),jk={position:kf(),top:0,width:"100%",zIndex:1};function en(t,r){if(typeof t!="string")return{context:r}}function Sk(t,r){return{item:typeof t=="string"?void 0:r}}const kk=Ne.memo(function(){const t=He("HeaderComponent"),r=$n("headerHeight"),s=He("HeaderFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),wk=Ne.memo(function(){const t=He("FooterComponent"),r=$n("footerHeight"),s=He("HeaderFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null});function ly({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("scrollerRef"),v=r("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:k,scrollToCallback:S}=ay(h,p,g,y,void 0,v);return t("scrollTo",S),t("scrollBy",b),a.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:k,style:{...v?bk:yk,...c},tabIndex:0,...d,...en(g,u),children:o})})}function sy({useEmitter:t,useEmitterValue:r,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=r("ScrollerComponent"),p=s("smoothScrollTargetReached"),y=r("totalListHeight"),v=r("deviation"),b=r("customScrollParent"),k=Ne.useRef(null),S=r("scrollerRef"),{scrollByCallback:w,scrollerRef:C,scrollToCallback:T}=ay(h,p,g,S,b);return ny(()=>{var N;return C.current=b||((N=k.current)==null?void 0:N.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",T),t("scrollBy",w),a.jsx(g,{ref:k,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...en(g,u),children:o})})}const Ck=({children:t})=>{const r=Ne.useContext(ey),s=$n("viewportHeight"),o=$n("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>Mv(s,g=>ir(g,u?"width":"height")),[s,u]),h=Or(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{r&&(s(r.viewportHeight),o(r.itemHeight))},[r,s,o]),a.jsx("div",{"data-viewport-type":"element",ref:h,style:Po(c),children:t})},Ek=({children:t})=>{const r=Ne.useContext(ey),s=$n("windowViewportRect"),o=$n("fixedItemHeight"),c=He("customScrollParent"),u=zv(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.useEffect(()=>{r&&(o(r.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:100}))},[r,s,o]),a.jsx("div",{"data-viewport-type":"window",ref:u,style:Po(d),children:t})},Nk=({children:t})=>{const r=He("TopItemListComponent")??"div",s=He("headerHeight"),o={...jk,marginTop:`${s}px`},c=He("context");return a.jsx(r,{style:o,...en(r,c),children:t})},Tk=Ne.memo(function(t){const r=He("useWindowScroll"),s=He("topItemsIndexes").length>0,o=He("customScrollParent"),c=He("context");return a.jsxs(o||r?Mk:Ak,{...t,context:c,children:[s&&a.jsx(Nk,{children:a.jsx(xg,{showTopList:!0})}),a.jsxs(o||r?Ek:Ck,{children:[a.jsx(kk,{}),a.jsx(xg,{}),a.jsx(wk,{})]})]})}),{Component:Rk,useEmitter:Cf,useEmitterValue:He,usePublisher:$n}=Jv(hk,{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"}},Tk),Ak=ly({useEmitter:Cf,useEmitterValue:He,usePublisher:$n}),Mk=sy({useEmitter:Cf,useEmitterValue:He,usePublisher:$n}),Lk=Rk,zk=nt(()=>{const t=ge(p=>a.jsxs("td",{children:["Item $",p]})),r=ge(null),s=ge(p=>a.jsxs("td",{colSpan:1e3,children:["Group ",p]})),o=ge(null),c=ge(null),u=ge({}),d=ge(wf),h=ge(zl),g=(p,y=null)=>tn(pe(u,Se(v=>v[p]),St()),y);return{components:u,computeItemKey:d,context:r,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});kt(Zv,zk);kf();const gg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Dk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:vg,floor:Ao,max:Ds,min:wd,round:yg}=Math;function bg(t,r,s){return Array.from({length:r-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function _k(t){return{...Dk,items:t}}function fo(t,r){return t!==void 0&&t.width===r.width&&t.height===r.height}function Ok(t,r){return t!==void 0&&t.column===r.column&&t.row===r.row}const Bk=nt(([{increaseViewportBy:t,listBoundary:r,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:p,smoothScrollTargetReached:y,viewportHeight:v},b,k,{didMount:S,propsReady:w},{customScrollParent:C,useWindowScroll:T,windowScrollContainerState:N,windowScrollTo:M,windowViewportRect:H},L])=>{const F=ge(0),E=ge(0),O=ge(gg),R=ge({height:0,width:0}),D=ge({height:0,width:0}),I=Qe(),q=Qe(),X=ge(0),Y=ge(null),U=ge({column:0,row:0}),z=Qe(),B=Qe(),V=ge(!1),W=ge(0),de=ge(!0),_=ge(!1),P=ge(!1);lt(pe(S,Ge(W),_e(([ue,je])=>je!==0)),()=>{Fe(de,!1)}),lt(pe(Bt(S,de,D,R,W,_),_e(([ue,je,Re,Le,,ae])=>ue&&!je&&Re.height!==0&&Le.height!==0&&!ae)),([,,,,ue])=>{Fe(_,!0),yf(1,()=>{Fe(I,ue)}),Kn(pe(p),()=>{Fe(r,[0,0]),Fe(de,!0)})}),Te(pe(B,_e(ue=>ue!=null&&ue.scrollTop>0),ra(0)),E),lt(pe(S,Ge(B),_e(([,ue])=>ue!=null)),([,ue])=>{ue&&(Fe(R,ue.viewport),Fe(D,ue.item),Fe(U,ue.gap),ue.scrollTop>0&&(Fe(V,!0),Kn(pe(p,Dr(1)),je=>{Fe(V,!1)}),Fe(g,{top:ue.scrollTop})))}),Te(pe(R,Se(({height:ue})=>ue)),v),Te(pe(Bt(De(R,fo),De(D,fo),De(U,(ue,je)=>ue!==void 0&&ue.column===je.column&&ue.row===je.row),De(p)),Se(([ue,je,Re,Le])=>({gap:Re,item:je,scrollTop:Le,viewport:ue}))),z),Te(pe(Bt(De(F),o,De(U,Ok),De(D,fo),De(R,fo),De(Y),De(E),De(V),De(de),De(W)),_e(([,,,,,,,ue])=>!ue),Se(([ue,[je,Re],Le,ae,fe,me,he,,be,Be])=>{const{column:Oe,row:st}=Le,{height:At,width:gt}=ae,{width:Gt}=fe;if(he===0&&(ue===0||Gt===0))return gg;if(gt===0){const Vt=bf(Be,ue),oa=Vt+Math.max(he-1,0);return _k(bg(Vt,oa,me))}const vt=iy(Gt,gt,Oe);let Ze,at;be?je===0&&Re===0&&he>0?(Ze=0,at=he-1):(Ze=vt*Ao((je+st)/(At+st)),at=vt*vg((Re+st)/(At+st))-1,at=wd(ue-1,Ds(at,vt-1)),Ze=wd(at,Ds(0,Ze))):(Ze=0,at=-1);const ve=bg(Ze,at,me),{bottom:ct,top:Nt}=jg(fe,Le,ae,ve),nn=vg(ue/vt),Rn=nn*At+(nn-1)*st-ct;return{bottom:ct,itemHeight:At,items:ve,itemWidth:gt,offsetBottom:Rn,offsetTop:Nt,top:Nt}})),O),Te(pe(Y,_e(ue=>ue!==null),Se(ue=>ue.length)),F),Te(pe(Bt(R,D,O,U),_e(([ue,je,{items:Re}])=>Re.length>0&&je.height!==0&&ue.height!==0),Se(([ue,je,{items:Re},Le])=>{const{bottom:ae,top:fe}=jg(ue,Le,je,Re);return[fe,ae]}),St(Hs)),r);const ee=ge(!1);Te(pe(p,Ge(ee),Se(([ue,je])=>je||ue!==0)),ee);const re=En(pe(Bt(O,F),_e(([{items:ue}])=>ue.length>0),Ge(ee),_e(([[ue,je],Re])=>{const Le=ue.items[ue.items.length-1].index===je-1;return(Re||ue.bottom>0&&ue.itemHeight>0&&ue.offsetBottom===0&&ue.items.length===je)&&Le}),Se(([[,ue]])=>ue-1),St())),xe=En(pe(De(O),_e(({items:ue})=>ue.length>0&&ue[0].index===0),ra(0),St())),ce=En(pe(De(O),Ge(V),_e(([{items:ue},je])=>ue.length>0&&!je),Se(([{items:ue}])=>({endIndex:ue[ue.length-1].index,startIndex:ue[0].index})),St(Hv),Ra(0)));Te(ce,k.scrollSeekRangeChanged),Te(pe(I,Ge(R,D,F,U),Se(([ue,je,Re,Le,ae])=>{const fe=Fv(ue),{align:me,behavior:he,offset:be}=fe;let Be=fe.index;Be==="LAST"&&(Be=Le-1),Be=Ds(0,Be,wd(Le-1,Be));let Oe=Zd(je,ae,Re,Be);return me==="end"?Oe=yg(Oe-je.height+Re.height):me==="center"&&(Oe=yg(Oe-je.height/2+Re.height/2)),be!==void 0&&be!==0&&(Oe+=be),{behavior:he,top:Oe}})),g);const ye=tn(pe(O,Se(ue=>ue.offsetBottom+ue.bottom)),0);return Te(pe(H,Se(ue=>({height:ue.visibleHeight,width:ue.visibleWidth}))),R),{customScrollParent:C,data:Y,deviation:X,footerHeight:c,gap:U,headerHeight:u,increaseViewportBy:t,initialItemCount:E,itemDimensions:D,overscan:s,restoreStateFrom:B,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:I,scrollTop:p,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:T,viewportDimensions:R,windowScrollContainerState:N,windowScrollTo:M,windowViewportRect:H,...k,gridState:O,horizontalDirection:P,initialTopMostItemIndex:W,totalListHeight:ye,...b,endReached:re,propsReady:w,rangeChanged:ce,startReached:xe,stateChanged:z,stateRestoreInProgress:V,...L}},kt(jf,cn,Ys,Xv,dr,Sf,ur));function iy(t,r,s){return Ds(1,Ao((t+s)/(Ao(r)+s)))}function jg(t,r,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=Zd(t,r,s,o[0].index);return{bottom:Zd(t,r,s,o[o.length-1].index)+c,top:u}}function Zd(t,r,s,o){const c=iy(t.width,s.width,r.column),u=Ao(o/c),d=u*s.height+Ds(0,u-1)*r.row;return d>0?d+r.row:d}const Ik=nt(()=>{const t=ge(v=>`Item ${v}`),r=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(wf),d=ge("div"),h=ge(zl),g=(v,b=null)=>tn(pe(r,Se(k=>k[v]),St()),b),p=ge(!1),y=ge(!1);return Te(De(y),p),{components:r,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:p,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),Hk=nt(([t,r])=>({...t,...r}),kt(Bk,Ik)),Uk=Ne.memo(function(){const t=Ct("gridState"),r=Ct("listClassName"),s=Ct("itemClassName"),o=Ct("itemContent"),c=Ct("computeItemKey"),u=Ct("isSeeking"),d=Vn("scrollHeight"),h=Ct("ItemComponent"),g=Ct("ListComponent"),p=Ct("ScrollSeekPlaceholder"),y=Ct("context"),v=Vn("itemDimensions"),b=Vn("gap"),k=Ct("log"),S=Ct("stateRestoreInProgress"),w=Vn("reportReadyState"),C=Or(Ne.useMemo(()=>T=>{const N=T.parentElement.parentElement.scrollHeight;d(N);const M=T.firstChild;if(M!==null){const{height:H,width:L}=M.getBoundingClientRect();v({height:H,width:L})}b({column:Sg("column-gap",getComputedStyle(T).columnGap,k),row:Sg("row-gap",getComputedStyle(T).rowGap,k)})},[d,v,b,k]),!0,!1);return ny(()=>{t.itemHeight>0&&t.itemWidth>0&&w(!0)},[t]),S?null:a.jsx(g,{className:r,ref:C,...en(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(T=>{const N=c(T.index,T.data,y);return u?a.jsx(p,{...en(p,y),height:t.itemHeight,index:T.index,width:t.itemWidth},N):m.createElement(h,{...en(h,y),className:s,"data-index":T.index,key:N},o(T.index,T.data,y))})})}),$k=Ne.memo(function(){const t=Ct("HeaderComponent"),r=Vn("headerHeight"),s=Ct("headerFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=Ct("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),Vk=Ne.memo(function(){const t=Ct("FooterComponent"),r=Vn("footerHeight"),s=Ct("headerFooterTag"),o=Or(Ne.useMemo(()=>u=>{r(ir(u,"height"))},[r]),!0,!1),c=Ct("context");return t!=null?a.jsx(s,{ref:o,children:a.jsx(t,{...en(t,c)})}):null}),Pk=({children:t})=>{const r=Ne.useContext(ty),s=Vn("itemDimensions"),o=Vn("viewportDimensions"),c=Or(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{r&&(o({height:r.viewportHeight,width:r.viewportWidth}),s({height:r.itemHeight,width:r.itemWidth}))},[r,o,s]),a.jsx("div",{ref:c,style:Po(!1),children:t})},Fk=({children:t})=>{const r=Ne.useContext(ty),s=Vn("windowViewportRect"),o=Vn("itemDimensions"),c=Ct("customScrollParent"),u=zv(s,c,!1);return Ne.useEffect(()=>{r&&(o({height:r.itemHeight,width:r.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:r.viewportHeight,visibleWidth:r.viewportWidth}))},[r,s,o]),a.jsx("div",{ref:u,style:Po(!1),children:t})},Gk=Ne.memo(function({...t}){const r=Ct("useWindowScroll"),s=Ct("customScrollParent"),o=s||r?qk:Wk,c=s||r?Fk:Pk,u=Ct("context");return a.jsx(o,{...t,...en(o,u),children:a.jsxs(c,{children:[a.jsx($k,{}),a.jsx(Uk,{}),a.jsx(Vk,{})]})})}),{useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn}=Jv(Hk,{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"}},Gk),Wk=ly({useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn}),qk=sy({useEmitter:oy,useEmitterValue:Ct,usePublisher:Vn});function Sg(t,r,s){return r!=="normal"&&(r==null?void 0:r.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,r,Ut.WARN),r==="normal"?0:parseInt(r??"0",10)}const Yk={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},cy={source:"Own",installed:"Installed"};function Kk(t){try{const r=localStorage.getItem(t);if(r!=null)return r==="true"}catch{}try{if(typeof sessionStorage<"u"){const r=sessionStorage.getItem(t);if(r!=null)return r==="true"}}catch{}return!1}function Xk(t,r){const s=r?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function kg({origin:t,count:r,filteredCount:s,updateCount:o,children:c}){const u=Yk[t],[d,h]=m.useState(()=>Kk(u)),g=m.useCallback(()=>{h(b=>{const k=!b;return Xk(u,k),k})},[u]),p=cy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return a.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[a.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx(Zk,{collapsed:d}),a.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:p}),a.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==r?`(${s} of ${r})`:`(${r})`}),o!=null&&o>0&&a.jsx(Qk,{origin:t,updateCount:o})]}),!d&&a.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Qk({origin:t,updateCount:r}){const[s,o]=m.useState(!1),c=cy[t].toLowerCase(),u=`${r} updates available in ${c} section, view all`;return a.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[r," updates",a.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function Zk({collapsed:t}){return a.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Ef(t,r){const s=r.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function Jk({value:t,onChange:r,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=m.useRef(null),d=m.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return m.useEffect(()=>{function g(p){var b;if(p.key!=="/")return;const y=p.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(p.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),a.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[a.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"M21 21l-4.35-4.35"})]}),a.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>r(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(r(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&a.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),a.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function ew({target:t}){const r=typeof t=="string"&&t.length>0,s=r?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=r?`symlinked from ${t}`:"symlinked, target unresolved";return a.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:a.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function tw({skill:t}){if(!t.updateAvailable)return null;const r=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${r} → ${s}`.trim():"Update available";return a.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 19V5"}),a.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function nw({skillId:t,trackedForUpdates:r}){let s=null;try{s=m.useContext(Sv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return a.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return r?null:a.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function Ks(t){const{version:r,showPrefix:s=!0,size:o="md"}=t;if(!r||typeof r!="string"||r.trim()==="")return null;const c=s&&!r.startsWith("v")?`v${r}`:r,u=o==="sm"?10:12,d=o==="sm"?1:2,h=o==="sm"?5:8;return a.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":r,title:t.title,style:{display:"inline-flex",alignItems:"center",padding:`${d}px ${h}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:u,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0},children:c})}function aw({skill:t,isSelected:r,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return a.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":r?"true":void 0,"aria-selected":!!r,"data-testid":"skill-row","data-selected":r,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:r?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[a.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),a.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),t.version&&a.jsx(Ks,{version:t.version,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&a.jsx(ew,{target:t.symlinkTarget??null}),a.jsx(tw,{skill:t}),a.jsx(nw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Mo=m.memo(aw);function rw({plugin:t,skills:r,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...r].sort((d,h)=>d.skill.localeCompare(h.skill));return a.jsxs("div",{role:"group","aria-label":`${t} (${r.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",r.length,")"]})]}),a.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return a.jsx("div",{role:"listitem",children:a.jsx(Mo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function lw(t,r){if(!t||typeof window>"u")return r;try{const s=window.localStorage.getItem(t);return s===null?r:s==="true"}catch{return r}}function wg({skills:t,pluginName:r,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var k;const h=r??((k=t[0])==null?void 0:k.pluginName)??"unknown-plugin",[g,p]=m.useState(()=>lw(o,s)),y=d?!1:g,v=m.useCallback(()=>{p(S=>{const w=!S;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(w))}catch{}return w})},[o]),b=y?"▸":"▾";return a.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[a.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[a.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),a.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),a.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&a.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&a.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(S=>a.jsx("div",{"data-vskill-plugin-skill":S.pluginNamespace??S.skill,children:c(S)},`${S.pluginNamespace??S.skill}`))})]})}function sw({pluginName:t,enabled:r,onAfterAction:s}){const[o,c]=m.useState(!1),[u,d]=m.useState(null),[h,g]=m.useState(null),p=m.useRef(null);m.useEffect(()=>{if(!o)return;function v(b){p.current&&!p.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),k=await b.json().catch(()=>({}));if(!b.ok||!k.ok){g(k.error??`${v} failed (${b.status})`);return}on("skills"),on("plugins"),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return a.jsxs("div",{ref:p,style:{position:"relative",display:"inline-flex"},children:[a.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&a.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[r?a.jsx(Cd,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):a.jsx(Cd,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),a.jsx(Cd,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&a.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Cd({onClick:t,disabled:r,busy:s,label:o,hint:c,danger:u}){return a.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:r,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:r?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:r&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{r||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Cg({name:t,count:r,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",p=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:p?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=a.jsxs(a.Fragment,{children:[p&&a.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),a.jsx("span",{className:"vskill-group-header-name",children:t}),a.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",r,")"]}),d&&a.jsx("span",{style:{marginLeft:"auto"},children:a.jsx(iw,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return p?a.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):a.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function iw({label:t,title:r,icon:s,onClick:o,accent:c}){return a.jsxs("button",{type:"button","aria-label":t,title:r??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function ow(){return a.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[a.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),a.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function cw(t){const r=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(r.length>1){for(const h of r.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=r[r.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function uw(t){if(!t||!(t instanceof HTMLElement))return!1;const r=t.tagName;if(r==="INPUT"||r==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function dw(t,r){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==r.meta||o!==r.ctrl||c!==r.shift||u!==r.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===r.key}function Jd(t,r={}){const{enabled:s=!0,target:o}=r,c=m.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(cw),m.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const p=g,y=uw(p.target);for(const v of c.current){if(!dw(p,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(p);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const fw=200;function pw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function mw(t,r){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>Ef(g,r)),d={};for(const g of u){const p=g.pluginName??g.plugin;(d[p]||(d[p]=[])).push(g)}const h=Object.entries(d).sort((g,p)=>g[0].localeCompare(p[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function hw(t,r){const s=[],o=[],c=[];for(const d of t){const h=pw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Ef(v,r)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const p=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:p}}return{own:u(s),installed:u(o),global:u(c)}}function xw(t,r){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var p;const d=u.filter(y=>Ef(y,r)),h={};for(const y of d)(h[p=y.plugin]||(h[p]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function gw({skills:t,selectedKey:r,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:p,topSlot:y,revealSkillId:v,onRevealComplete:b}){const k=!!g||t.some(P=>P.scope!==void 0&&P.scope!==null),S=g??"claude-cli",[w,C]=m.useState(""),T=m.useDeferredValue(w),N=m.useMemo(()=>hw(t,T),[t,T]),M=m.useMemo(()=>mw(t,T),[t,T]),H=S==="claude-code",{data:L}=Ml("plugins",()=>fetch("/api/plugins").then(P=>P.json()),{enabled:H,ttl:6e4}),F=m.useMemo(()=>{const P=new Map;for(const ee of(L==null?void 0:L.plugins)??[]){const re=P.get(ee.name);P.set(ee.name,!!re||!!ee.enabled)}return P},[L==null?void 0:L.plugins]),[E,O]=m.useState(()=>ef(`vskill-sidebar-${S}-group-available-collapsed`)),[R,D]=m.useState(()=>ef(`vskill-sidebar-${S}-group-authoring-collapsed`)),I=m.useCallback(P=>{O(P);try{window.localStorage.setItem(`vskill-sidebar-${S}-group-available-collapsed`,String(P))}catch{}},[S]),q=m.useCallback(P=>{D(P);try{window.localStorage.setItem(`vskill-sidebar-${S}-group-authoring-collapsed`,String(P))}catch{}},[S]),{own:X,installed:Y}=m.useMemo(()=>xw(t,T),[t,T]),z=N.own.filtered+N.installed.filtered+N.global.filtered>=fw,B=m.useMemo(()=>{const P=ee=>{const re=[];for(const[,xe]of ee){const ce=[...xe].sort((ye,ue)=>ye.skill.localeCompare(ue.skill));re.push(...ce)}return re};return k?[...P(N.own.byPlugin),...P(N.installed.byPlugin),...P(N.global.byPlugin)]:[...P(X.byPlugin),...P(Y.byPlugin)]},[k,N.own.byPlugin,N.installed.byPlugin,N.global.byPlugin,X.byPlugin,Y.byPlugin]),V=m.useMemo(()=>r?B.findIndex(P=>P.plugin===r.plugin&&P.skill===r.skill):-1,[B,r]),W=m.useCallback(P=>{if(B.length===0)return;const ee=V<0?P>0?0:B.length-1:Math.min(Math.max(V+P,0),B.length-1);s(B[ee])},[B,V,s]),de=m.useMemo(()=>{if(!v)return null;const[P,ee]=v.split("/");if(!P||!ee)return null;const re=t.find(ye=>ye.plugin===P&&ye.skill===ee);if(!re)return{plugin:P,skill:ee,bucket:null,pluginName:null};const xe=re.source==="plugin"?"plugin":"project",ce=xe==="plugin"?re.pluginName??P:null;return{plugin:P,skill:ee,bucket:xe,pluginName:ce}},[v,t]),_=m.useRef(null);return m.useEffect(()=>{if(!v){_.current=null;return}if(_.current===v)return;const P=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),ee=document.querySelector(`[data-skill-id="${P}"]`);ee&&(_.current=v,ee.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),Jd([{key:"j",handler:()=>W(1)},{key:"k",handler:()=>W(-1)},{key:"Enter",handler:()=>{V>=0&&s(B[V])}}],{enabled:!o&&!c}),a.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,a.jsx(Jk,{value:w,onChange:C}),o&&a.jsx(Sw,{}),!o&&c&&a.jsx(kw,{error:c,onRetry:u}),!o&&!c&&k&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(Cg,{name:te.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:E,onToggle:I,count:M.availableProject.total+M.availablePersonal.total+M.availablePlugin.total}),!E&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:te.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${S}-available-project-collapsed`,count:M.availableProject.total,filteredCount:w?M.availableProject.filtered:null,updateCount:(p==null?void 0:p.installed)??(h==null?void 0:h.installed),children:M.availableProject.filtered===0?a.jsx(Ng,{queryActive:!!w,agentId:S}):a.jsx(Ts,{items:M.availableProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),a.jsx(Ns,{label:te.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${S}-available-personal-collapsed`,count:M.availablePersonal.total,filteredCount:w?M.availablePersonal.filtered:null,updateCount:p==null?void 0:p.global,children:M.availablePersonal.filtered===0?a.jsx(yw,{queryActive:!!w,agentId:S}):a.jsx(Ts,{items:M.availablePersonal.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),H&&a.jsxs(Ns,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${S}-available-plugin-collapsed`,count:M.availablePlugin.total,filteredCount:w?M.availablePlugin.filtered:null,children:[a.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[a.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),M.availablePlugin.filtered===0?a.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):M.availablePlugin.byPlugin.map(([P,ee])=>a.jsx(wg,{pluginName:P,skills:ee,persistKey:`vskill-plugin-available-${P}-collapsed`,headerActionSlot:H?a.jsx(sw,{pluginName:P,enabled:F.get(P)??!0}):void 0,renderSkill:re=>a.jsx(Mo,{skill:re,isSelected:(r==null?void 0:r.plugin)===re.plugin&&(r==null?void 0:r.skill)===re.skill,onSelect:()=>s(re),onContextMenu:d})},`available-${P}`))]})]}),a.jsx(jw,{}),a.jsx(Cg,{name:te.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:de?!1:R,onToggle:q,count:M.authoringProject.total+M.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!R||de)&&a.jsxs(a.Fragment,{children:[a.jsx(Ns,{label:te.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${S}-authoring-project-collapsed`,count:M.authoringProject.total,filteredCount:w?M.authoringProject.filtered:null,updateCount:(p==null?void 0:p.own)??(h==null?void 0:h.source),forceOpen:(de==null?void 0:de.bucket)==="project",children:M.authoringProject.filtered===0?a.jsx(Eg,{queryActive:!!w}):a.jsx(Ts,{items:M.authoringProject.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),H&&a.jsx(Ns,{label:te.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${S}-authoring-plugin-collapsed`,count:M.authoringPlugin.total,filteredCount:w?M.authoringPlugin.filtered:null,forceOpen:(de==null?void 0:de.bucket)==="plugin",children:M.authoringPlugin.filtered===0?a.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",a.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):M.authoringPlugin.byPlugin.map(([P,ee])=>a.jsx(wg,{pluginName:P,skills:ee,persistKey:`vskill-plugin-authoring-${P}-collapsed`,forceOpen:(de==null?void 0:de.bucket)==="plugin"&&de.pluginName===P,renderSkill:re=>a.jsx(Mo,{skill:re,isSelected:(r==null?void 0:r.plugin)===re.plugin&&(r==null?void 0:r.skill)===re.skill,onSelect:()=>s(re),onContextMenu:d})},`authoring-${P}`))})]})]}),!o&&!c&&!k&&a.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[a.jsx(kg,{origin:"source",count:X.total,filteredCount:w?X.filtered:null,updateCount:h==null?void 0:h.source,children:X.filtered===0?a.jsx(Eg,{queryActive:!!w}):a.jsx(Ts,{items:X.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})}),a.jsx(bw,{}),a.jsx(kg,{origin:"installed",count:Y.total,filteredCount:w?Y.filtered:null,updateCount:h==null?void 0:h.installed,children:Y.filtered===0?a.jsx(Ng,{queryActive:!!w}):a.jsx(Ts,{items:Y.byPlugin,selectedKey:r,onSelect:s,onContextMenu:d,useVirtual:z})})]})]})}function ef(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Ns({label:t,storageKey:r,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=m.useState(()=>ef(r)),p=d?!1:h,y=m.useCallback(()=>{g(b=>{const k=!b;if(typeof window<"u")try{window.localStorage.setItem(r,String(k))}catch{}return k})},[r]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return a.jsxs("section",{"data-vskill-named-scope":t,children:[a.jsxs("button",{type:"button",onClick:y,"aria-expanded":!p,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:p?"▸":"▾"}),a.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),a.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&a.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!p&&a.jsx("div",{style:{paddingLeft:18},children:u})]})}function vw(t){const r=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));r.push({kind:"header",plugin:s,count:c.length});for(const u of c)r.push({kind:"row",skill:u})}return r}function Ts({items:t,selectedKey:r,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=vw(t);return a.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:a.jsx(Lk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[a.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,p=!!r&&r.plugin===g.plugin&&r.skill===g.skill;return a.jsx(Mo,{skill:g,isSelected:p,onSelect:()=>s(g),onContextMenu:o})}})})}return a.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>a.jsx(rw,{plugin:u,skills:d,selectedKey:r,onSelect:s,onContextMenu:o},u))})}function Eg({queryActive:t}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:"No skills yet.",body:a.jsxs(a.Fragment,{children:["Create one with ",a.jsx(Nf,{children:"vskill new"})," or the"," ",a.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Ng({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:r?`No skills installed for ${r} in this project.`:"No installed skills.",body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install <plugin>"})," to add one."]})})}function yw({queryActive:t,agentId:r}){return t?a.jsx(Nl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):a.jsx(Nl,{headline:`No global skills for ${r}.`,body:a.jsxs(a.Fragment,{children:["Run ",a.jsx(Nf,{children:"vskill install --global <plugin>"})," to add one."]})})}function Nl({headline:t,body:r}){return a.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[a.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),a.jsx("div",{children:r})]})}function Nf({children:t}){return a.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function bw(){return a.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function jw(){return a.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function Sw(){return a.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>a.jsx(ow,{},t))})}function kw({error:t,onRetry:r}){return a.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[a.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),a.jsxs("details",{children:[a.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:ww(t)}),a.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),r&&a.jsx("button",{type:"button",onClick:r,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function ww(t){const r=t.split(`
66
66
  `)[0]??t;return r.length>80?r.slice(0,77)+"…":r}const uy=240,dy=480,fy="vskill-sidebar-width",_s=320;function Tf(t){return Number.isFinite(t)?Math.round(Math.max(uy,Math.min(dy,t))):_s}function Cw(){try{const t=localStorage.getItem(fy);if(!t)return _s;const r=Number(t);return Number.isFinite(r)?Tf(r):_s}catch{return _s}}function Ew(t){try{localStorage.setItem(fy,String(Tf(t)))}catch{}}function Nw({initialWidth:t,onChange:r}){const s=m.useRef({startX:0,startWidth:t,pointerId:null}),o=m.useRef(t);return m.useEffect(()=>{o.current=t},[t]),m.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=Tf(s.current.startWidth+h);o.current=g,r(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Ew(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[r]),a.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":uy,"aria-valuemax":dy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function Tw({connected:t,hint:r,onRetry:s}){return t?null:a.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),a.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),r&&a.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:r}),a.jsx("div",{style:{flex:1}}),s&&a.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function py(t,r){if(t!==401||typeof window>"u"||!r||typeof r!="object")return;const s=r;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function my(t){if(t!==void 0)try{return JSON.stringify(t)}catch(r){console.error("Failed to serialize request body:",r);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Ed(){const[t,r]=m.useState([]),[s,o]=m.useState(!1),[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useCallback(async(v,b)=>{r([]),o(!0),u(!1),h(null);const k=new AbortController;g.current=k;try{const S=my(b),w=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:S,signal:k.signal});if(!w.ok||!w.body){let H=`HTTP ${w.status}`,L;try{L=await w.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(H=L.error)}catch{}throw py(w.status,L),new Error(H)}const C=w.body.getReader(),T=new TextDecoder;let N="",M="";for(;;){const{done:H,value:L}=await C.read();if(H)break;N+=T.decode(L,{stream:!0});const F=N.split(`
67
67
  `);N=F.pop()||"";for(const E of F)if(E.startsWith("event: "))M=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),R={event:M,data:O};M==="done"?(u(!0),r(D=>[...D,R])):r(D=>[...D,R])}catch{}M=""}}}catch(S){S.name!=="AbortError"&&h(S.message)}finally{o(!1),g.current=null}},[]),y=m.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:p,stop:y}}function Rw(t){const r=m.useRef(t);r.current=t;const[s,o]=m.useState(new Set),c=m.useRef(new Map),u=m.useCallback(async(p,y,v)=>{var k;(k=c.current.get(p))==null||k.abort();const b=new AbortController;c.current.set(p,b),o(S=>{const w=new Set(S);return w.add(p),w});try{const S=my(v),w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:S,signal:b.signal});if(!w.ok||!w.body){let H=`HTTP ${w.status}`,L;try{L=await w.json(),L&&typeof L=="object"&&"error"in L&&typeof L.error=="string"&&(H=L.error)}catch{}throw py(w.status,L),new Error(H)}const C=w.body.getReader(),T=new TextDecoder;let N="",M="";for(;;){const{done:H,value:L}=await C.read();if(H)break;N+=T.decode(L,{stream:!0});const F=N.split(`
68
68
  `);N=F.pop()||"";for(const E of F)if(E.startsWith("event: "))M=E.slice(7).trim();else if(E.startsWith("data: ")){try{const O=JSON.parse(E.slice(6)),R={event:M,data:O};r.current.onEvent(p,R)}catch{}M=""}}r.current.onDone(p)}catch(S){S.name!=="AbortError"&&r.current.onError(p,S.message)}finally{o(S=>{const w=new Set(S);return w.delete(p),w}),c.current.delete(p)}},[]),d=m.useCallback(p=>{var y;(y=c.current.get(p))==null||y.abort()},[]),h=m.useCallback(()=>{for(const p of c.current.values())p.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Aw={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Mw(t,r){var s,o;switch(r.type){case"SET_LOADING":return{...t,loading:r.loading};case"SET_ERROR":return{...t,error:r.error};case"INIT_DATA":{const c=new Map;if(r.benchmark)for(const d of r.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=r.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:r.skillContent,savedContent:r.skillContent,isDirty:!1,evals:r.evals,evalsError:r.evalsError??null,latestBenchmark:r.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:r.panel};case"SET_CONTENT":return{...t,skillContent:r.content,isDirty:r.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:r.evals};case"SELECT_CASE":return{...t,selectedCaseId:r.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(r.caseId,{status:"running",startedAt:Date.now(),mode:r.mode}),{...t,caseRunStates:c,runMode:r.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,r.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);c.set(r.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(r.caseId,{status:"error",errorMessage:r.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(r.caseId);return c.set(r.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of r.caseIds)c.set(u,{status:"queued",mode:r.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:r.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:r.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(r.evalId,r.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:r.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,r.entry]};case"AI_EDIT_RESULT":{const c=r.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:r.improved,reasoning:r.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:r.message,aiEditClassifiedError:r.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,r.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:r.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:r.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(r.index,!c.get(r.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:r.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:r.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:r.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,r.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:r.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${r.index}/${r.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:r.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:r.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:r.runs,activationHistoryLoading:!1};default:return t}}function Lw(t){if(t==="unit"||t==="integration")return t}function zw(t,r){const s=r.data;if(r.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),r.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),r.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}r.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const hy=m.createContext(null);function Tn(){const t=m.useContext(hy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Dw({plugin:t,skill:r,origin:s,children:o}){const c=s==="installed",[u,d]=m.useReducer(Mw,{...Aw,plugin:t,skill:r}),h=m.useRef(new Set),g=m.useRef(new Set),p=m.useRef(new Map),y=m.useCallback((ae,fe)=>{let me=p.current.get(ae);me||(me={assertions:[]},p.current.set(ae,me)),zw(me,fe),d({type:"UPDATE_INLINE_RESULT",evalId:ae,result:{...me,assertions:[...me.assertions]}})},[]),v=m.useCallback(ae=>{if(g.current.has(ae))return;g.current.add(ae);const fe=p.current.get(ae)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:ae,result:{...fe,assertions:[...fe.assertions]}}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ee.getLatestBenchmark(t,r).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,r]),b=m.useCallback((ae,fe)=>{g.current.has(ae)||(g.current.add(ae),d({type:"CASE_RUN_ERROR",caseId:ae,error:fe}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ee.getLatestBenchmark(t,r).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,r]),{startCase:k,stopCase:S,stopAll:w}=Rw({onEvent:y,onDone:v,onError:b});m.useEffect(()=>()=>{w()},[w]);const C=m.useCallback(async()=>{try{const ae=await fetch(`/api/skills/${t}/${r}/activation-history`);if(!ae.ok){if(ae.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const fe=await ae.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:fe.runs||[]})}catch{}},[t,r]);m.useEffect(()=>{let ae=!1;async function fe(){try{const[me,he,be]=await Promise.allSettled([Ee.getSkillDetail(t,r),Ee.getEvals(t,r),Ee.getLatestBenchmark(t,r)]);if(ae)return;let Be=null,Oe=null;if(he.status==="fulfilled")Be=he.value;else{const st=he.reason;Oe=(st==null?void 0:st.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:me.status==="fulfilled"?me.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:be.status==="fulfilled"?be.value:null})}catch(me){ae||d({type:"SET_ERROR",error:me.message})}}return fe(),C(),()=>{ae=!0}},[t,r,C]);const T=m.useCallback(async()=>{if(!c)try{await Ee.applyImprovement(t,r,u.skillContent),d({type:"CONTENT_SAVED"})}catch(ae){d({type:"SET_ERROR",error:ae.message})}},[c,t,r,u.skillContent]),N=m.useCallback(async ae=>{if(!c)try{const fe=await Ee.saveEvals(t,r,ae);d({type:"SET_EVALS",evals:fe})}catch(fe){d({type:"SET_ERROR",error:fe.message})}},[c,t,r]),M=m.useCallback((ae,fe="benchmark")=>{if(c)return;const me=u.caseRunStates.get(ae);if((me==null?void 0:me.status)!=="running")if(p.current.delete(ae),g.current.delete(ae),d({type:"CASE_RUN_START",caseId:ae,mode:fe}),fe==="comparison"){const he=`/api/skills/${t}/${r}/compare`;k(ae,he,{eval_ids:[ae]})}else{const he=`/api/skills/${t}/${r}/benchmark/case/${ae}`;k(ae,he,fe==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.caseRunStates,k]),H=m.useCallback((ae="benchmark")=>{var he;if(c)return;const fe=((he=u.evals)==null?void 0:he.evals)??[];if(fe.length===0)return;const me=fe.map(be=>be.id);for(const be of me)p.current.delete(be),g.current.delete(be);d({type:"BULK_RUN_START",caseIds:me,mode:ae}),h.current=new Set(me);for(const be of me)if(ae==="comparison")k(be,`/api/skills/${t}/${r}/compare`,{eval_ids:[be]});else{const Be=`/api/skills/${t}/${r}/benchmark/case/${be}`;k(be,Be,ae==="baseline"?{baseline_only:!0}:void 0)}},[c,t,r,u.evals,k]),L=m.useCallback(ae=>{S(ae),d({type:"CASE_RUN_CANCEL",caseId:ae}),h.current.delete(ae),g.current.add(ae)},[S]),F=m.useCallback(()=>{w(),d({type:"CANCEL_ALL"}),h.current.clear()},[w]),E=m.useCallback(async(ae,fe)=>{d({type:"OPEN_IMPROVE",evalId:ae})},[]),O=m.useCallback(async(ae,fe)=>{try{await Ee.applyImprovement(t,r,fe),d({type:"SET_CONTENT",content:fe}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),M(ae,"benchmark")}catch(me){d({type:"SET_ERROR",error:me.message})}},[t,r,M]),R=Ed(),D=m.useRef(null),I=m.useRef(0);m.useEffect(()=>{const ae=R.events;for(let fe=I.current;fe<ae.length;fe++){const me=ae[fe],he=me.data;if(me.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:he.phase,message:he.message}}),me.event==="done"){const be=he.improved,Be=he.reasoning,Oe=he.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:be,reasoning:Be,evalChanges:Oe})}if(me.event==="error"){const be=he;d({type:"AI_EDIT_ERROR",message:be.description||"Unknown error",classified:be})}}I.current=ae.length},[R.events]),m.useEffect(()=>{R.error&&d({type:"AI_EDIT_ERROR",message:R.error})},[R.error]),m.useEffect(()=>()=>{R.stop()},[R.stop]);const q=m.useCallback(async(ae,fe,me)=>{c||(I.current=0,d({type:"AI_EDIT_LOADING"}),D.current=R.stop,R.start(`/api/skills/${t}/${r}/improve?sse`,{mode:"instruct",instruction:ae,content:u.skillContent,evals:u.evals??{skill_name:r,evals:[]},provider:fe,model:me}))},[c,t,r,u.skillContent,u.evals,R]),X=m.useCallback(()=>{R.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[R]),Y=m.useCallback(async()=>{const ae=u.aiEditResult;if(ae!=null&&ae.improved)try{if(await Ee.applyImprovement(t,r,ae.improved),d({type:"SET_CONTENT",content:ae.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:me}=await Io(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),he=u.evals??{skill_name:r,evals:[]},be=me(he,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ee.saveEvals(t,r,be);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:be}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(fe){d({type:"SET_ERROR",error:fe.message})}},[t,r,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),U=m.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),z=m.useCallback(ae=>{d({type:"TOGGLE_EVAL_CHANGE",index:ae})},[]),B=m.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),V=m.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),W=m.useCallback(async()=>{const ae=u.aiEditEvalsRetry;if(ae)try{const fe=await Ee.saveEvals(t,r,ae);d({type:"SET_EVALS",evals:fe}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(fe){d({type:"SET_ERROR",error:`Retry failed: ${fe.message}`})}},[t,r,u.aiEditEvalsRetry]),de=m.useCallback(async()=>{try{const ae=await Ee.getSkillDetail(t,r);d({type:"SET_CONTENT",content:ae.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,r]),{config:_}=_r(),P=Ed(),ee=m.useRef(0);m.useEffect(()=>{const ae=P.events;for(let fe=ee.current;fe<ae.length;fe++){const me=ae[fe],he=me.data;if(me.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:he.phase,message:he.message}}),me.event==="done"){const be=he;Ee.saveEvals(t,r,be).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}me.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:he})}ee.current=ae.length},[P.events,t,r]),m.useEffect(()=>{P.error&&d({type:"SET_ERROR",error:P.error})},[P.error]),m.useEffect(()=>()=>{P.stop()},[P.stop]);const re=m.useCallback(async ae=>{if(c)return;ee.current=0,d({type:"GENERATE_EVALS_START"});const fe={};_!=null&&_.provider&&(fe.provider=_.provider),_!=null&&_.model&&(fe.model=_.model);const me=Lw(ae==null?void 0:ae.testType);me&&(fe.testType=me),P.start(`/api/skills/${t}/${r}/generate-evals?sse`,Object.keys(fe).length>0?fe:void 0)},[c,t,r,P,_]),xe=Ed(),ce=m.useRef(0);m.useEffect(()=>()=>{xe.stop()},[xe.stop]),m.useEffect(()=>{const ae=xe.events;for(let fe=ce.current;fe<ae.length;fe++){const me=ae[fe];if(me.event==="classifying"){const he=me.data;d({type:"ACTIVATION_CLASSIFYING",index:he.index,total:he.total})}if(me.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:me.data}),me.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const he=me.data;if(he.error)d({type:"ACTIVATION_ERROR",error:he.error});else{d({type:"ACTIVATION_DONE",summary:he});const be={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(_==null?void 0:_.model)||"unknown",provider:(_==null?void 0:_.provider)||"unknown",promptCount:he.total,summary:{precision:he.precision,recall:he.recall,reliability:he.reliability,tp:he.tp,tn:he.tn,fp:he.fp,fn:he.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[be,...u.activationHistory??[]]})}}}ce.current=ae.length},[xe.events,_,u.activationHistory]),m.useEffect(()=>{xe.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:xe.error}))},[xe.error]);const ye=m.useRef(null),ue=m.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),xe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[xe]),je=m.useCallback(ae=>{const me=ae.trim().split(`
@@ -82,8 +82,8 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
82
82
  What edge cases should I test?
83
83
  +Deploy this to production
84
84
  !What's the weather like today?
85
- !Write me a poem about flowers`}),a.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:"One prompt per line"}),a.jsx(ho,{}),a.jsx("span",{children:"No prefix = auto-classify"}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),a.jsx(ho,{}),a.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[I," prompt",I!==1?"s":""]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:R,disabled:y||!M.trim(),className:"btn btn-primary",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("circle",{cx:"12",cy:"12",r:"6"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k||`${g.length} / ${I} prompts tested`,b&&a.jsx(BC,{startedAt:b})]})]})]})]}),a.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:Y?a.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:z}}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&a.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[a.jsx("div",{className:"spinner-lg mx-auto mb-4"}),a.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&a.jsxs("div",{className:"space-y-5",children:[X.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),a.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((V,W)=>a.jsx($g,{result:V},`incorrect-${W}`))})]}),q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"16 10 11 15 8 12"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((V,W)=>a.jsx($g,{result:V},`correct-${W}`))})]})]}),p&&a.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),p.autoClassifiedCount!=null&&p.autoClassifiedCount>0&&a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[p.autoClassifiedCount," of ",p.total," prompts auto-classified from skill name and tags"]}),a.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[a.jsx(Md,{label:"Precision",value:p.precision,description:"Of all activations, how many were correct?",detail:`${p.tp} true / ${p.tp+p.fp} total activations`}),a.jsx(Md,{label:"Recall",value:p.recall,description:"Of expected activations, how many fired?",detail:`${p.tp} activated / ${p.tp+p.fn} expected`}),a.jsx(Md,{label:"Reliability",value:p.reliability,description:"Overall correct classification rate",detail:`${p.tp+p.tn} correct / ${p.total} total`})]}),a.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[a.jsx(xo,{label:"True Positive",abbr:"TP",count:p.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),a.jsx(xo,{label:"False Positive",abbr:"FP",count:p.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),a.jsx(xo,{label:"False Negative",abbr:"FN",count:p.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),a.jsx(xo,{label:"True Negative",abbr:"TN",count:p.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),a.jsx(DC,{history:C,expanded:E,onToggle:()=>O(!E),skillVersion:N})]})}function DC({history:t,expanded:r,onToggle:s,skillVersion:o}){return t===null?null:a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:s,children:[a.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&a.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&a.jsx("div",{className:"px-4 py-3",children:t.length===0?a.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):a.jsx("div",{className:"space-y-2",children:t.map(c=>a.jsx(_C,{run:c,skillVersion:o},c.id))})})]})}function _C({run:t,skillVersion:r}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:OC(t.timestamp)}),a.jsx(Ks,{version:r??null,size:"sm","data-testid":"activation-row-version"}),a.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),a.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function OC(t){const r=Date.now(),s=new Date(t).getTime(),o=Math.floor((r-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function ho(){return a.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function $g({result:t}){const r=Ug[t.classification]||Ug.FN,s=t.classification==="TP"||t.classification==="TN";return a.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:r.bg,border:"1px solid transparent"},children:[a.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${r.text} 20%, transparent)`},children:s?a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),a.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[a.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:r.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),a.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&a.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&a.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Md({label:t,value:r,description:s,detail:o}){const c=Math.round(r*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),a.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),a.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),a.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function xo({abbr:t,count:r,bg:s,color:o,description:c}){return a.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[a.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:r}),a.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),a.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function BC({startedAt:t}){const[r,s]=m.useState(0);return m.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),a.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}const Ld={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Vg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},af=600,rf=180,ln=40,zd=af-ln*2,rr=rf-ln*2,IC=[25,50,75,100];function Pg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function HC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function UC({entries:t,onPointClick:r}){const[s,o]=m.useState(null),c=m.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((p,y)=>{const v=ln+y/(u-1)*zd,b=p.passRate*100,k=ln+rr-b/100*rr;return{x:v,y:k,pct:b,entry:p}}),h=d.map(p=>`${p.x},${p.y}`).join(" "),g=Array.from(new Set(c.map(p=>p.type)));return a.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[a.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),a.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(p=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Ld[p]??"var(--text-tertiary)"}}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Vg[p]??p})]},p))}),a.jsxs("svg",{width:af,height:rf,viewBox:`0 0 ${af} ${rf}`,style:{display:"block",overflow:"visible"},children:[IC.map(p=>{const y=ln+rr-p/100*rr;return a.jsxs("g",{children:[a.jsx("line",{x1:ln,y1:y,x2:ln+zd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),a.jsxs("text",{x:ln-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[p,"%"]})]},p)}),a.jsx("line",{x1:ln,y1:ln+rr,x2:ln+zd,y2:ln+rr,stroke:"var(--border-subtle)",strokeWidth:1}),a.jsx("text",{x:ln-8,y:ln+rr+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),a.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((p,y)=>a.jsx("circle",{cx:p.x,cy:p.y,r:5,fill:Ld[p.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:p.x,y:p.y,entry:p.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>r==null?void 0:r(p.entry)},y)),$C(u).map(p=>a.jsx("text",{x:d[p].x,y:ln+rr+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Pg(c[p].timestamp)},p))]}),s&&a.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Pg(s.entry.timestamp)}),a.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:Ld[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Vg[s.entry.type]??s.entry.type}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),a.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:HC(s.entry.totalDurationMs)}),a.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function $C(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const r=Math.ceil(t/10),s=[0];for(let o=r;o<t-1;o+=r)s.push(o);return s.push(t-1),s}const Ms=new Map;let sn=null,Eo=null,go=1e3,wl=0;function Ey(){if(sn)return;sn=new EventSource("/api/events");const t=r=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Ms.get(r);if(c)for(const u of c)u(o)};sn.addEventListener("benchmark:complete",t("benchmark:complete")),sn.addEventListener("history:written",t("history:written")),sn.addEventListener("leaderboard:updated",t("leaderboard:updated")),sn.onerror=()=>{sn==null||sn.close(),sn=null,wl>0&&(Eo=setTimeout(()=>{go=Math.min(go*2,3e4),Ey()},go))},sn.onopen=()=>{go=1e3}}function VC(){Eo!=null&&(clearTimeout(Eo),Eo=null),sn==null||sn.close(),sn=null}function PC(t,r){return Ms.has(t)||Ms.set(t,new Set),Ms.get(t).add(r),wl++,Ey(),()=>{var s;(s=Ms.get(t))==null||s.delete(r),wl--,wl<=0&&(wl=0,queueMicrotask(()=>{wl<=0&&VC()}))}}function Lo(t,r){const s=m.useRef(r);s.current=r,m.useEffect(()=>PC(t,c=>s.current(c)),[t])}function zo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function FC(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function GC({rate:t,label:r}){const s=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:zo(t)},children:[s,"%"]})]}),a.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:zo(t)}})})]})})}function WC({points:t}){if(t.length<2)return null;const r=200,s=48,o=4,c=t.length,u=t.map((g,p)=>{const y=o+p/(c-1)*(r-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,p)=>`${p===0?"M":"L"} ${g.x},${g.y}`).join(" ");return a.jsxs("svg",{width:r,height:s,style:{display:"block"},children:[a.jsx("path",{d,fill:"var(--accent-muted)"}),a.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),a.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function qC({plugin:t,skill:r}){const s=`stats/${t}/${r}`,o=m.useCallback(()=>Ee.getStats(t,r),[t,r]),{data:c,loading:u}=Ml(s,o),d=m.useCallback(()=>on(s),[s]);if(Lo("benchmark:complete",d),Lo("history:written",d),u)return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"skeleton h-24 rounded-xl"}),a.jsx("div",{className:"skeleton h-48 rounded-xl"}),a.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),a.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,p=h-g,y=c.assertionStats.slice(0,10);return a.jsxs("div",{className:"space-y-4 stagger-children",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:zo(h)},children:[Math.round(h*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:p>=0?"var(--green)":"var(--red)"},children:[p>=0?"+":"",Math.round(p*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Nn(c.totalCost)})]}),c.costPerRun!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Nn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),a.jsx(WC,{points:c.trendPoints})]}),c.modelStats.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),a.jsx("tbody",{children:c.modelStats.map(v=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),a.jsx("td",{style:{padding:"8px",textAlign:"center"},children:a.jsxs("span",{className:"font-semibold",style:{color:zo(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:FC(v.avgDurationMs)}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Nn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),a.jsx("div",{className:"space-y-3",children:y.map(v=>a.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),a.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),a.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),a.jsx(GC,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function YC({plugin:t,skill:r}){const[s,o]=m.useState(null),[c,u]=m.useState(null),[d,h]=m.useState({}),[g,p]=m.useState({});m.useEffect(()=>{Ee.getEvals(t,r).then(o).catch(()=>o(null))},[t,r]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){p(b=>({...b,[v]:!0}));try{const b=await Ee.getCaseHistory(t,r,v);h(k=>({...k,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{p(b=>({...b,[v]:!1}))}}}return s?a.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],k=c===v.id,S=g[v.id],w=b.length>0?b[0].pass_rate:null;return a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:k?"var(--surface-2)":"transparent"},onMouseEnter:C=>{k||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{k||(C.currentTarget.style.background="transparent")},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:k?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),a.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),a.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&a.jsx(jy,{entries:b}),w!=null&&a.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Tl(w)},children:[Math.round(w*100),"%"]}),b.length>0&&a.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),k&&a.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:S?a.jsxs("div",{className:"p-4 flex items-center gap-2",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):a.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,T)=>a.jsxs("div",{className:"p-4",style:{background:T===0?"var(--surface-2)":"transparent"},children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:yy(C.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Tl(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&a.jsx("span",{children:by(C.durationMs)}),C.tokens!=null&&a.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),a.jsx("div",{className:"space-y-1",children:C.assertions.map(N=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:N.pass?"var(--green)":"var(--red)"},children:a.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:N.pass?a.jsx("polyline",{points:"20 6 9 17 4 12"}):a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:N.text}),N.reasoning&&a.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:N.reasoning})]})]},N.id))})]},T))})})]},v.id)})}):a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function KC(){const{state:t,dispatch:r}=Tn(),{plugin:s,skill:o}=t,{state:c}=Zn(),u=c.skills.find(V=>V.plugin===s&&V.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=m.useState("timeline"),[p,y]=m.useState(""),[v,b]=m.useState(""),[k,S]=m.useState(!1),[w,C]=m.useState([]),[T,N]=m.useState(null),[M,H]=m.useState(!1),[L,F]=m.useState(null),[E,O]=m.useState(!1),R=`history/${s}/${o}?model=${p}&type=${v}`,D=m.useCallback(()=>Ee.getHistory(s,o,{model:p||void 0,type:v||void 0}),[s,o,p,v]),{data:I,loading:q}=Ml(R,D),X=I??[];m.useEffect(()=>{!I||I.length<2||Ee.compareRuns(s,o,I[0].timestamp,I[1].timestamp).then(V=>{const W=V.regressions.filter(de=>de.change==="regression");r({type:"SET_REGRESSIONS",regressions:W})}).catch(()=>{})},[I,s,o,r]);const Y=m.useCallback(()=>on(R),[R]);Lo("history:written",Y);const U=m.useCallback(async V=>{if(k){C(W=>W.includes(V)?W.filter(de=>de!==V):W.length>=2?[W[1],V]:[...W,V]);return}O(!0);try{const W=await Ee.getHistoryEntry(s,o,V);F(W)}catch{}finally{O(!1)}},[s,o,k]),z=m.useCallback(async()=>{if(w.length===2){H(!0);try{const V=await Ee.compareRuns(s,o,w[0],w[1]);N(V)}catch{}finally{H(!1)}}},[s,o,w]),B=[...new Set(X.map(V=>V.model))];return q?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"skeleton h-12 rounded-lg"}),a.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(V=>a.jsx("button",{onClick:()=>g(V),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===V?"var(--accent-muted)":"transparent",color:h===V?"var(--accent)":"var(--text-tertiary)"},children:V==="timeline"?"Timeline":V==="per-eval"?"Per Eval":"Statistics"},V))}),h==="timeline"&&a.jsxs("div",{children:[X.length>0&&a.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:a.jsx(UC,{entries:X,onPointClick:V=>U(V.timestamp)})}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("select",{value:p,onChange:V=>y(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Models"}),B.map(V=>a.jsx("option",{value:V,children:V},V))]}),a.jsxs("select",{value:v,onChange:V=>b(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Types"}),a.jsx("option",{value:"benchmark",children:"Benchmark"}),a.jsx("option",{value:"comparison",children:"Comparison"}),a.jsx("option",{value:"baseline",children:"Baseline"}),a.jsx("option",{value:"model-compare",children:"Model Compare"}),a.jsx("option",{value:"improve",children:"AI Improve"}),a.jsx("option",{value:"instruct",children:"AI Edit"}),a.jsx("option",{value:"ai-generate",children:"AI Generate"}),a.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{onClick:()=>{S(!k),C([]),N(null)},className:`btn text-[12px] ${k?"btn-primary":"btn-secondary"}`,children:k?"Exit Compare":"Compare Runs"}),k&&w.length===2&&a.jsx("button",{onClick:z,disabled:M,className:"btn btn-primary text-[12px]",children:M?"Comparing...":"Compare"})]}),a.jsx("div",{className:"space-y-2",children:X.length===0?a.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(V=>{const W=w.includes(V.timestamp);return a.jsx("button",{onClick:()=>U(V.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:W?"var(--accent-muted)":"var(--surface-1)",border:W?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:de=>{W||(de.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:de=>{W||(de.currentTarget.style.borderColor="var(--border-subtle)")},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[k&&a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:W?"var(--accent)":"var(--border-default)",background:W?"var(--accent)":"transparent"},children:W&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(V.timestamp).toLocaleString()}),a.jsx("span",{className:"pill text-[9px]",style:{background:V.type==="comparison"?"var(--purple-muted)":V.type==="baseline"?"var(--surface-3)":V.type==="model-compare"?"var(--accent-muted)":V.type==="improve"||V.type==="instruct"?"var(--purple-muted)":V.type==="ai-generate"?"var(--green-muted)":V.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:V.type==="comparison"?"var(--purple)":V.type==="baseline"?"var(--text-tertiary)":V.type==="model-compare"?"var(--accent)":V.type==="improve"||V.type==="instruct"?"var(--purple)":V.type==="ai-generate"?"var(--green)":V.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:V.type==="model-compare"?"model compare":V.type==="improve"?"ai improve":V.type==="instruct"?"ai edit":V.type==="ai-generate"?"ai generate":V.type==="eval-generate"?"eval generate":V.type})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ks,{version:d,size:"sm","data-testid":"history-row-version"}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:V.model}),V.totalCost!=null&&V.totalCost>0&&a.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Nn(V.totalCost)}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:V.passRate>=.8?"var(--green)":V.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(V.passRate*100),"%"]})]})]})},V.timestamp)})}),T&&a.jsx(XC,{result:T}),L&&!k&&a.jsx(QC,{run:L,onClose:()=>F(null)})]}),h==="per-eval"&&a.jsx(YC,{plugin:s,skill:o}),h==="statistics"&&a.jsx(qC,{plugin:s,skill:o})]})}function XC({result:t}){const r=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[a.jsxs("span",{children:["Run A cost: ",Nn(t.runA.totalCost??null)]}),a.jsxs("span",{children:["Run B cost: ",Nn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&a.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Nn(t.runB.totalCost-t.runA.totalCost)]})]}),r.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),a.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:a.jsxs("table",{className:"w-full text-[12px]",children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"var(--surface-2)"},children:[a.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),a.jsx("tbody",{children:t.caseDiffs.map(o=>a.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function QC({run:t,onClose:r}){return(t.type==="improve"||t.type==="instruct")&&t.improve?a.jsx(ZC,{run:t,onClose:r}):a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),a.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Nn(t.totalCost)}`]}),a.jsx("div",{className:"space-y-2",children:t.cases.map(s=>a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&a.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Nn(s.cost)}),a.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function ZC({run:t,onClose:r}){var u;const s=m.useMemo(()=>t.improve?Go(t.improve.original,t.improve.improved):[],[t.improve]),o=m.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=m.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return a.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),a.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),a.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&a.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:c.map((d,h)=>a.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function Ny({data:t}){if(t.length<2)return a.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=r.length,g=Math.min(...r),y=Math.max(...r)-g||1,v=r.map((S,w)=>{const C=c+w/(h-1)*u,T=c+d-(S-g)/y*d;return`${C.toFixed(1)},${T.toFixed(1)}`}),b=r[r.length-1],k=Tl(b);return a.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[a.jsx("polyline",{points:v.join(" "),fill:"none",stroke:k,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[S,w]=v[v.length-1].split(",");return a.jsx("circle",{cx:S,cy:w,r:2.5,fill:k})})()]})}function JC(){return a.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function eE({pct:t}){const r=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return a.jsxs("span",{className:"pill",style:{background:s,color:r,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function tE({score:t,rating:r}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[r]??s.minimal,c=t>=0?"+":"";return a.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),a.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function nE({warning:t}){return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function aE({active:t,onChange:r,hasBaseline:s}){return a.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[a.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),a.jsx("button",{onClick:()=>r("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function rE(t){var o,c,u;if(t.length===0)return[];const r=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;r.has(g)||r.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const p=r.get(g);p.passRates.push(h.passRate.mean),p.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,p.lastDuration=h.duration.mean,p.lastCost=((c=h.cost)==null?void 0:c.total)??null,p.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(p.lastBaselinePassRate=h.baselinePassRate.mean,p.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,p.lastAmplificationPct=h.amplificationPct,p.hasBaseline=!0)}const s=[];for(const[d,h]of r){const[g,...p]=d.split("/");s.push({rank:0,model:p.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Ty=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function lE({entries:t}){return a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>a.jsx("th",{style:Ty(r==="#"?"center":"left"),children:r},r))})}),a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&a.jsx(JC,{})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ny,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function sE({entries:t}){const r=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return r.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",a.jsx("code",{children:"--baseline"})," flag."]})})}):a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>a.jsx("th",{style:Ty(s==="#"?"center":"left"),children:s},s))})}),a.jsx("tbody",{children:r.map((s,o)=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?a.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?a.jsx(eE,{pct:s.amplificationPct}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ny,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function iE(){const{state:t}=Tn(),{plugin:r,skill:s}=t,[o,c]=m.useState("rankings"),u=`leaderboard/${r}/${s}`,d=m.useCallback(()=>Ee.getLeaderboard(r,s),[r,s]),{data:h,loading:g}=Ml(u,d),p=(h==null?void 0:h.entries)??[];m.useEffect(()=>{c("rankings")},[r,s]);const y=m.useCallback(()=>on(u),[u]);Lo("leaderboard:updated",y);const v=m.useMemo(()=>rE(p),[p]),b=v.some(w=>w.hasBaseline),k=p[0],S=k==null?void 0:k.judgeBiasWarning;return g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),a.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),a.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),a.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",a.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),a.jsx(aE,{active:o,onChange:c,hasBaseline:b})]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),S&&a.jsx(nE,{warning:S}),o==="rankings"?a.jsx(lE,{entries:v}):a.jsx(sE,{entries:v}),o==="amplification"&&(k==null?void 0:k.skillQualityScore)!=null&&(k==null?void 0:k.skillQualityRating)&&a.jsx(tE,{score:k.skillQualityScore,rating:k.skillQualityRating})]})}function oE({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState([]),[d,h]=m.useState(!0),[g,p]=m.useState(null);m.useEffect(()=>{Ee.getDependencies(t,r).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,r]);async function y(v,b){try{await navigator.clipboard.writeText(b),p(v),setTimeout(()=>p(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?a.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),a.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>a.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),a.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),a.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>a.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),a.jsx("div",{className:"space-y-1.5",children:c.map(v=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Fg({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState(!0),[d,h]=m.useState(null),[g,p]=m.useState(""),[y,v]=m.useState(!1),[b,k]=m.useState(null),[S,w]=m.useState(""),[C,T]=m.useState(""),[N,M]=m.useState(!1),[H,L]=m.useState(new Set),F=m.useCallback(async()=>{u(!0);try{const[D,I]=await Promise.all([Ee.getCredentials(t,r).catch(()=>({credentials:[]})),Ee.getParams(t,r).catch(()=>({params:[]}))]),q=new Map(I.params.map(U=>[U.name,U])),X=new Set,Y=[];for(const U of D.credentials){X.add(U.name);const z=q.get(U.name);Y.push({name:U.name,status:U.status==="ready"||U.status==="resolved"?"ready":"missing",source:U.source,maskedValue:z==null?void 0:z.maskedValue})}for(const U of I.params)X.has(U.name)||Y.push({name:U.name,status:U.status,maskedValue:U.maskedValue});o(Y)}finally{u(!1)}},[t,r]);m.useEffect(()=>{F()},[F]);const E=m.useCallback(async D=>{if(H.has(D)){L(I=>{const q=new Set(I);return q.delete(D),q}),o(I=>I.map(q=>q.name===D?{...q,revealedValue:void 0}:q));return}try{const q=(await Ee.getParamsRevealed(t,r,D)).params.find(X=>X.name===D);q&&(o(X=>X.map(Y=>Y.name===D?{...Y,revealedValue:q.value}:Y)),L(X=>new Set(X).add(D)))}catch{}},[t,r,H]),O=async(D,I)=>{if(!(!D.trim()||!I.trim())){v(!0),k(null);try{await Ee.setCredential(t,r,D,I),h(null),p(""),L(new Set),F()}catch(q){k(q.message)}finally{v(!1)}}},R=async()=>{if(!(!S.trim()||!C.trim())){v(!0),k(null);try{await Ee.setCredential(t,r,S.trim().toUpperCase(),C),w(""),T(""),M(!1),F()}catch(D){k(D.message)}finally{v(!1)}}};return c?a.jsxs("div",{className:"mt-6",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):a.jsxs("div",{className:"mt-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("button",{onClick:()=>M(!N),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&a.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!N?a.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):a.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(D=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:D.name}),D.maskedValue&&a.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:H.has(D.name)&&D.revealedValue!=null?D.revealedValue:D.maskedValue}),D.maskedValue&&a.jsx("button",{onClick:()=>E(D.name),className:"btn btn-ghost px-1",title:H.has(D.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:H.has(D.name)?a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),a.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:D.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:D.status==="ready"?"var(--green)":"var(--orange)"},children:D.status==="ready"?"ready":"missing"}),D.source&&a.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:D.source}),d===D.name?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("input",{value:g,onChange:I=>p(I.target.value),onKeyDown:I=>{I.key==="Enter"&&O(D.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),a.jsx("button",{onClick:()=>O(D.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),a.jsx("button",{onClick:()=>{h(null),p("")},className:"btn btn-ghost text-[10px] px-1",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):a.jsx("button",{onClick:()=>{h(D.name),p("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},D.name))}),N&&a.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:S,onChange:D=>w(D.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),a.jsx("input",{value:C,onChange:D=>T(D.target.value),onKeyDown:D=>{D.key==="Enter"&&R()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx("button",{onClick:()=>{M(!1),w(""),T("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),a.jsx("button",{onClick:R,disabled:y||!S.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function cE(){const{state:t}=Tn(),{plugin:r,skill:s}=t,[o,c]=m.useState(null),[u,d]=m.useState(!0);return m.useEffect(()=>{Ee.getDependencies(r,s).then(c).catch(()=>{}).finally(()=>d(!1))},[r,s]),u?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx(oE,{plugin:r,skill:s}),a.jsx(Fg,{plugin:r,skill:s})]}):a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),a.jsx(Fg,{plugin:r,skill:s})]})}function uE(t){const r={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(r.targetAgents=t.targetAgents),r}function dE(t){var o;const r=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0;return{applyName:r?null:t.aiName??null,applySuggestedPlugin:!s&&!!((o=t.aiSuggestedPlugin)!=null&&o.plugin),suggestedPluginValue:s?null:t.aiSuggestedPlugin??null}}function lf(t,r=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(s=s.replace(/^-+|-+$/g,"")),s}function fE(t,r,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function pE({onCreated:t,resolveAiConfigOverride:r,forceLayout:s}){const[o,c]=m.useState("ai"),[u,d]=m.useState(null),[h,g]=m.useState(!0),{config:p}=_r(),[y,v]=m.useState(""),[b,k]=m.useState(s??3),[S,w]=m.useState(""),[C,T]=m.useState(""),[N,M]=m.useState(""),[H,L]=m.useState(""),[F,E]=m.useState(""),[O,R]=m.useState(""),[D,I]=m.useState("write"),[q,X]=m.useState([]),[Y,U]=m.useState(!1),[z,B]=m.useState(null),[V,W]=m.useState(""),[de,_]=m.useState(!1),[P,ee]=m.useState(!1),[re,xe]=m.useState(null),[ce,ye]=m.useState(null),[ue,je]=m.useState([]),Re=m.useRef(null),Le=m.useRef(null),ae=m.useRef(null),fe=m.useRef(null),me=m.useRef(null),[he,be]=m.useState(!1),[Be,Oe]=m.useState(!1),st=m.useRef(y),At=m.useRef(S),gt=m.useRef(C);m.useEffect(()=>{st.current=y},[y]),m.useEffect(()=>{At.current=S},[S]),m.useEffect(()=>{gt.current=C},[C]),m.useEffect(()=>{Ee.getProjectLayout().then($e=>{if(d($e),s)return;k($e.suggestedLayout);const Je=$e.detectedLayouts.find(yt=>yt.layout===$e.suggestedLayout);Je!=null&&Je.existingPlugins.length&&w(Je.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),m.useEffect(()=>{var $e;o==="ai"&&(($e=Re.current)==null||$e.focus())},[o]),m.useEffect(()=>()=>{var $e;($e=Le.current)==null||$e.abort()},[]);const Gt=m.useMemo(()=>{var $e;return u?(($e=u.detectedLayouts.find(Je=>Je.layout===b))==null?void 0:$e.existingPlugins)||[]:[]},[u,b]),vt=S==="__new__"?C:S,Ze=u?fE(u.root,b,vt||"{plugin}",y||"{skill}"):"",at=m.useMemo(()=>u?u.detectedLayouts.filter($e=>$e.layout!==4):[],[u]),ve=m.useMemo(()=>{if(!u)return null;const $e=u.detectedLayouts.find(ut=>ut.layout===2&&ut.existingPlugins.length>0),Je=u.detectedLayouts.find(ut=>ut.layout===1&&ut.existingPlugins.length>0),yt=$e||Je;return yt?{layout:yt.layout,plugins:yt.existingPlugins}:null},[u]),ct=m.useCallback(()=>{if(r)return r();if(!p)return{provider:"claude-cli",model:"sonnet"};const $e=p.provider||"claude-cli",Je=p.model||"sonnet";return{provider:$e,model:Je}},[p,r]),Nt=m.useCallback(()=>{var $e;($e=Le.current)==null||$e.abort(),_(!1)},[]),nn=m.useCallback(()=>{xe(null),ye(null)},[]),Rn=m.useCallback(async()=>{var ut,Fn;if(xe(null),ye(null),je([]),ae.current=null,fe.current=null,!V.trim()){xe("Describe what your skill should do");return}_(!0);const $e=new AbortController;Le.current=$e;const{provider:Je,model:yt}=ct();try{const Qt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(uE({prompt:V.trim(),provider:Je,model:yt,targetAgents:q})),signal:$e.signal});if(!Qt.ok||!Qt.body){let un=`HTTP ${Qt.status}`;try{const ca=await Qt.json();ca.error&&(un=ca.error)}catch{}throw new Error(un)}const Gn=Qt.body.getReader(),se=new TextDecoder;let we="",ze="";for(;;){const{done:un,value:ca}=await Gn.read();if(un)break;we+=se.decode(ca,{stream:!0});const La=we.split(`
86
- `);we=La.pop()||"";for(const Ir of La)if(Ir.startsWith("event: "))ze=Ir.slice(7).trim();else if(Ir.startsWith("data: ")){try{const dt=JSON.parse(Ir.slice(6));if(ze==="progress")je(za=>[...za,{phase:dt.phase,message:dt.message,timestamp:Date.now()}]);else if(ze==="provenance")fe.current={resolvedModelId:typeof dt.resolvedModelId=="string"?dt.resolvedModelId:null,snapshotDate:typeof dt.snapshotDate=="string"?dt.snapshotDate:null};else if(ze==="done"||ze==="complete"){const za={prompt:V.trim(),provider:ct().provider,model:ct().model,resolvedModelId:((ut=fe.current)==null?void 0:ut.resolvedModelId)??null,snapshotDate:((Fn=fe.current)==null?void 0:Fn.snapshotDate)??null,reasoning:dt.reasoning||""},An=dE({userName:st.current,userPlugin:At.current,userNewPlugin:gt.current,aiName:dt.name,aiSuggestedPlugin:dt.suggestedPlugin&&dt.suggestedPlugin.plugin?{plugin:dt.suggestedPlugin.plugin,layout:dt.suggestedPlugin.layout}:null});if(An.applyName!==null&&v(An.applyName),M(dt.description),L(dt.model||""),E(dt.allowedTools||""),R(dt.body),ee(!0),ae.current=za,c("manual"),s===3)k(3),w(""),T("");else if(An.applySuggestedPlugin&&An.suggestedPluginValue){const Zt=An.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(ua=>ua.existingPlugins))??[]).includes(Zt.plugin))if(w(Zt.plugin),Zt.layout&&(Zt.layout===1||Zt.layout===2))k(Zt.layout);else{const ua=u==null?void 0:u.detectedLayouts.find(Dl=>Dl.existingPlugins.includes(Zt.plugin));ua&&(ua.layout===1||ua.layout===2)&&k(ua.layout)}else w("__new__"),T(Zt.plugin)}else!An.applySuggestedPlugin&&At.current.trim().length===0&&gt.current.trim().length===0&&b===3&&ve&&Oe(!0);const Yo={name:dt.name,plugin:vt||"",layout:b,description:dt.description,model:dt.model||void 0,allowedTools:dt.allowedTools||void 0,body:dt.body,aiMeta:za};Ee.saveDraft(Yo).then(Zt=>{be(!0),Zt!=null&&Zt.dir&&(me.current=Zt.dir)}).catch(()=>{})}else ze==="error"&&(xe(dt.message||dt.description||"Unknown error"),dt.category&&ye(dt))}catch{}ze=""}}}catch(Qt){Qt.name!=="AbortError"&&xe(Qt.message)}finally{_(!1),Le.current=null}},[V,ct,b,ve,vt,u,q,s]),Vt=m.useCallback(async()=>{if(B(null),!y.trim()){B("Skill name is required");return}if(!N.trim()){B("Description is required");return}if(b!==3&&!vt.trim()){B("Plugin name is required");return}U(!0);try{const $e=await Ee.createSkill({name:lf(y),plugin:vt||"",layout:b,description:N,model:H||void 0,allowedTools:F||void 0,body:O,aiMeta:ae.current||void 0,draftDir:me.current||void 0});me.current=null,t($e.plugin,$e.skill)}catch($e){B($e.message)}finally{U(!1)}},[y,N,b,vt,H,F,O,t]),oa=m.useCallback(()=>{ve&&(k(ve.layout),w(ve.plugins[0]),Oe(!1))},[ve]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:k,creatableLayouts:at,availablePlugins:Gt,pathPreview:Ze,plugin:S,setPlugin:w,newPlugin:C,setNewPlugin:T,effectivePlugin:vt,name:y,setName:v,description:N,setDescription:M,model:H,setModel:L,allowedTools:F,setAllowedTools:E,body:O,setBody:R,bodyViewMode:D,setBodyViewMode:I,aiPrompt:V,setAiPrompt:W,generating:de,aiGenerated:P,aiError:re,aiClassifiedError:ce,aiProgress:ue,promptRef:Re,handleGenerate:Rn,handleCancelGenerate:Nt,clearAiError:nn,targetAgents:q,setTargetAgents:X,draftSaved:he,showPluginRecommendation:Be,setShowPluginRecommendation:Oe,pluginLayoutInfo:ve,applyPluginRecommendation:oa,creating:Y,error:z,handleCreate:Vt}}function Ry(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function mE(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Ay({node:t,depth:r=0}){var s;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?a.jsx(Ry,{}):a.jsx(mE,{}),a.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>a.jsx(Ay,{node:o,depth:r+1},o.name))]})}function hE(t,r,s){const o=[];r&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function xE({skillName:t,hasEvals:r,isDraft:s}){const o=hE(t,r,s);return a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsx(Ry,{})}),"Skill Structure"]}),a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:a.jsx(Ay,{node:o})})]})}const lr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Dd({size:t=14,color:r="currentColor"}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function gE({onCreated:t,onCancel:r}){const s=pE({onCreated:t});return a.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[a.jsxs("div",{className:"mb-5",children:[a.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),a.jsx("div",{className:"flex items-center justify-between mt-2",children:a.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Dd,{size:12}),"AI-Assisted"]})}),a.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsx(Dd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),a.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
85
+ !Write me a poem about flowers`}),a.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:"One prompt per line"}),a.jsx(ho,{}),a.jsx("span",{children:"No prefix = auto-classify"}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),a.jsx(ho,{}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),a.jsx(ho,{}),a.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[I," prompt",I!==1?"s":""]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:R,disabled:y||!M.trim(),className:"btn btn-primary",children:y?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("circle",{cx:"12",cy:"12",r:"6"}),a.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k||`${g.length} / ${I} prompts tested`,b&&a.jsx(BC,{startedAt:b})]})]})]})]}),a.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[a.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),a.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:Y?a.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:z}}):a.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&a.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[a.jsx("div",{className:"spinner-lg mx-auto mb-4"}),a.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&a.jsxs("div",{className:"space-y-5",children:[X.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),a.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((V,W)=>a.jsx($g,{result:V},`incorrect-${W}`))})]}),q.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("polyline",{points:"16 10 11 15 8 12"})]}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),a.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((V,W)=>a.jsx($g,{result:V},`correct-${W}`))})]})]}),p&&a.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),p.autoClassifiedCount!=null&&p.autoClassifiedCount>0&&a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[p.autoClassifiedCount," of ",p.total," prompts auto-classified from skill name and tags"]}),a.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[a.jsx(Md,{label:"Precision",value:p.precision,description:"Of all activations, how many were correct?",detail:`${p.tp} true / ${p.tp+p.fp} total activations`}),a.jsx(Md,{label:"Recall",value:p.recall,description:"Of expected activations, how many fired?",detail:`${p.tp} activated / ${p.tp+p.fn} expected`}),a.jsx(Md,{label:"Reliability",value:p.reliability,description:"Overall correct classification rate",detail:`${p.tp+p.tn} correct / ${p.total} total`})]}),a.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[a.jsx(xo,{label:"True Positive",abbr:"TP",count:p.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),a.jsx(xo,{label:"False Positive",abbr:"FP",count:p.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),a.jsx(xo,{label:"False Negative",abbr:"FN",count:p.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),a.jsx(xo,{label:"True Negative",abbr:"TN",count:p.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),a.jsx(DC,{history:C,expanded:E,onToggle:()=>O(!E),skillVersion:N})]})}function DC({history:t,expanded:r,onToggle:s,skillVersion:o}){return t===null?null:a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:r?"1px solid var(--border-subtle)":"none"},onClick:s,children:[a.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&a.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:r?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),r&&a.jsx("div",{className:"px-4 py-3",children:t.length===0?a.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):a.jsx("div",{className:"space-y-2",children:t.map(c=>a.jsx(_C,{run:c,skillVersion:o},c.id))})})]})}function _C({run:t,skillVersion:r}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[a.jsx("div",{className:"flex-1 min-w-0",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:OC(t.timestamp)}),a.jsx(Ks,{version:r??null,size:"sm","data-testid":"activation-row-version"}),a.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),a.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),a.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),a.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function OC(t){const r=Date.now(),s=new Date(t).getTime(),o=Math.floor((r-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function ho(){return a.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function $g({result:t}){const r=Ug[t.classification]||Ug.FN,s=t.classification==="TP"||t.classification==="TN";return a.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:r.bg,border:"1px solid transparent"},children:[a.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${r.text} 20%, transparent)`},children:s?a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})}):a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:r.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"flex items-center gap-2 mb-1",children:a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),a.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[a.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:r.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),a.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),a.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&a.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&a.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Md({label:t,value:r,description:s,detail:o}){const c=Math.round(r*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return a.jsxs("div",{className:"text-center",children:[a.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),a.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),a.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),a.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function xo({abbr:t,count:r,bg:s,color:o,description:c}){return a.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[a.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:r}),a.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),a.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function BC({startedAt:t}){const[r,s]=m.useState(0);return m.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),a.jsxs("span",{className:"ml-2",children:["(",r,"s)"]})}const Ld={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Vg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},af=600,rf=180,ln=40,zd=af-ln*2,rr=rf-ln*2,IC=[25,50,75,100];function Pg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function HC(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function UC({entries:t,onPointClick:r}){const[s,o]=m.useState(null),c=m.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((p,y)=>{const v=ln+y/(u-1)*zd,b=p.passRate*100,k=ln+rr-b/100*rr;return{x:v,y:k,pct:b,entry:p}}),h=d.map(p=>`${p.x},${p.y}`).join(" "),g=Array.from(new Set(c.map(p=>p.type)));return a.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[a.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),a.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(p=>a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Ld[p]??"var(--text-tertiary)"}}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Vg[p]??p})]},p))}),a.jsxs("svg",{width:af,height:rf,viewBox:`0 0 ${af} ${rf}`,style:{display:"block",overflow:"visible"},children:[IC.map(p=>{const y=ln+rr-p/100*rr;return a.jsxs("g",{children:[a.jsx("line",{x1:ln,y1:y,x2:ln+zd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),a.jsxs("text",{x:ln-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[p,"%"]})]},p)}),a.jsx("line",{x1:ln,y1:ln+rr,x2:ln+zd,y2:ln+rr,stroke:"var(--border-subtle)",strokeWidth:1}),a.jsx("text",{x:ln-8,y:ln+rr+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),a.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((p,y)=>a.jsx("circle",{cx:p.x,cy:p.y,r:5,fill:Ld[p.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:p.x,y:p.y,entry:p.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>r==null?void 0:r(p.entry)},y)),$C(u).map(p=>a.jsx("text",{x:d[p].x,y:ln+rr+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Pg(c[p].timestamp)},p))]}),s&&a.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[a.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Pg(s.entry.timestamp)}),a.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),a.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[a.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:Ld[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Vg[s.entry.type]??s.entry.type}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),a.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[a.jsx("span",{children:HC(s.entry.totalDurationMs)}),a.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function $C(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const r=Math.ceil(t/10),s=[0];for(let o=r;o<t-1;o+=r)s.push(o);return s.push(t-1),s}const Ms=new Map;let sn=null,Eo=null,go=1e3,wl=0;function Ey(){if(sn)return;sn=new EventSource("/api/events");const t=r=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Ms.get(r);if(c)for(const u of c)u(o)};sn.addEventListener("benchmark:complete",t("benchmark:complete")),sn.addEventListener("history:written",t("history:written")),sn.addEventListener("leaderboard:updated",t("leaderboard:updated")),sn.onerror=()=>{sn==null||sn.close(),sn=null,wl>0&&(Eo=setTimeout(()=>{go=Math.min(go*2,3e4),Ey()},go))},sn.onopen=()=>{go=1e3}}function VC(){Eo!=null&&(clearTimeout(Eo),Eo=null),sn==null||sn.close(),sn=null}function PC(t,r){return Ms.has(t)||Ms.set(t,new Set),Ms.get(t).add(r),wl++,Ey(),()=>{var s;(s=Ms.get(t))==null||s.delete(r),wl--,wl<=0&&(wl=0,queueMicrotask(()=>{wl<=0&&VC()}))}}function Lo(t,r){const s=m.useRef(r);s.current=r,m.useEffect(()=>PC(t,c=>s.current(c)),[t])}function zo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function FC(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function GC({rate:t,label:r}){const s=Math.round(t*100);return a.jsx("div",{className:"flex items-center gap-3",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:r}),a.jsxs("span",{className:"text-[11px] font-semibold",style:{color:zo(t)},children:[s,"%"]})]}),a.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:a.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:zo(t)}})})]})})}function WC({points:t}){if(t.length<2)return null;const r=200,s=48,o=4,c=t.length,u=t.map((g,p)=>{const y=o+p/(c-1)*(r-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,p)=>`${p===0?"M":"L"} ${g.x},${g.y}`).join(" ");return a.jsxs("svg",{width:r,height:s,style:{display:"block"},children:[a.jsx("path",{d,fill:"var(--accent-muted)"}),a.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),a.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function qC({plugin:t,skill:r}){const s=`stats/${t}/${r}`,o=m.useCallback(()=>Ee.getStats(t,r),[t,r]),{data:c,loading:u}=Ml(s,o),d=m.useCallback(()=>on(s),[s]);if(Lo("benchmark:complete",d),Lo("history:written",d),u)return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"skeleton h-24 rounded-xl"}),a.jsx("div",{className:"skeleton h-48 rounded-xl"}),a.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return a.jsxs("div",{className:"text-center py-12",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),a.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,p=h-g,y=c.assertionStats.slice(0,10);return a.jsxs("div",{className:"space-y-4 stagger-children",children:[a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:zo(h)},children:[Math.round(h*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),a.jsxs("div",{className:"text-[24px] font-bold",style:{color:p>=0?"var(--green)":"var(--red)"},children:[p>=0?"+":"",Math.round(p*100),"%"]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),a.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Nn(c.totalCost)})]}),c.costPerRun!=null&&a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),a.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Nn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),a.jsx(WC,{points:c.trendPoints})]}),c.modelStats.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),a.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),a.jsx("tbody",{children:c.modelStats.map(v=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),a.jsx("td",{style:{padding:"8px",textAlign:"center"},children:a.jsxs("span",{className:"font-semibold",style:{color:zo(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:FC(v.avgDurationMs)}),a.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Nn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&a.jsxs("div",{className:"glass-card p-5",children:[a.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),a.jsx("div",{className:"space-y-3",children:y.map(v=>a.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[a.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[a.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),a.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),a.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),a.jsx(GC,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function YC({plugin:t,skill:r}){const[s,o]=m.useState(null),[c,u]=m.useState(null),[d,h]=m.useState({}),[g,p]=m.useState({});m.useEffect(()=>{Ee.getEvals(t,r).then(o).catch(()=>o(null))},[t,r]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){p(b=>({...b,[v]:!0}));try{const b=await Ee.getCaseHistory(t,r,v);h(k=>({...k,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{p(b=>({...b,[v]:!1}))}}}return s?a.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],k=c===v.id,S=g[v.id],w=b.length>0?b[0].pass_rate:null;return a.jsxs("div",{className:"glass-card overflow-hidden",children:[a.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:k?"var(--surface-2)":"transparent"},onMouseEnter:C=>{k||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{k||(C.currentTarget.style.background="transparent")},children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:k?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:a.jsx("polyline",{points:"9 18 15 12 9 6"})}),a.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),a.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&a.jsx(jy,{entries:b}),w!=null&&a.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Tl(w)},children:[Math.round(w*100),"%"]}),b.length>0&&a.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),k&&a.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:S?a.jsxs("div",{className:"p-4 flex items-center gap-2",children:[a.jsx("div",{className:"spinner",style:{width:14,height:14}}),a.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?a.jsx("div",{className:"p-4",children:a.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):a.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,T)=>a.jsxs("div",{className:"p-4",style:{background:T===0?"var(--surface-2)":"transparent"},children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:yy(C.timestamp)}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),a.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),a.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Tl(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&a.jsx("span",{children:by(C.durationMs)}),C.tokens!=null&&a.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),a.jsx("div",{className:"space-y-1",children:C.assertions.map(N=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[a.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:N.pass?"var(--green)":"var(--red)"},children:a.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:N.pass?a.jsx("polyline",{points:"20 6 9 17 4 12"}):a.jsxs(a.Fragment,{children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:N.text}),N.reasoning&&a.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:N.reasoning})]})]},N.id))})]},T))})})]},v.id)})}):a.jsx("div",{className:"text-center py-12",children:a.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function KC(){const{state:t,dispatch:r}=Tn(),{plugin:s,skill:o}=t,{state:c}=Zn(),u=c.skills.find(V=>V.plugin===s&&V.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=m.useState("timeline"),[p,y]=m.useState(""),[v,b]=m.useState(""),[k,S]=m.useState(!1),[w,C]=m.useState([]),[T,N]=m.useState(null),[M,H]=m.useState(!1),[L,F]=m.useState(null),[E,O]=m.useState(!1),R=`history/${s}/${o}?model=${p}&type=${v}`,D=m.useCallback(()=>Ee.getHistory(s,o,{model:p||void 0,type:v||void 0}),[s,o,p,v]),{data:I,loading:q}=Ml(R,D),X=I??[];m.useEffect(()=>{!I||I.length<2||Ee.compareRuns(s,o,I[0].timestamp,I[1].timestamp).then(V=>{const W=V.regressions.filter(de=>de.change==="regression");r({type:"SET_REGRESSIONS",regressions:W})}).catch(()=>{})},[I,s,o,r]);const Y=m.useCallback(()=>on(R),[R]);Lo("history:written",Y);const U=m.useCallback(async V=>{if(k){C(W=>W.includes(V)?W.filter(de=>de!==V):W.length>=2?[W[1],V]:[...W,V]);return}O(!0);try{const W=await Ee.getHistoryEntry(s,o,V);F(W)}catch{}finally{O(!1)}},[s,o,k]),z=m.useCallback(async()=>{if(w.length===2){H(!0);try{const V=await Ee.compareRuns(s,o,w[0],w[1]);N(V)}catch{}finally{H(!1)}}},[s,o,w]),B=[...new Set(X.map(V=>V.model))];return q?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("div",{className:"skeleton h-12 rounded-lg"}),a.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(V=>a.jsx("button",{onClick:()=>g(V),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===V?"var(--accent-muted)":"transparent",color:h===V?"var(--accent)":"var(--text-tertiary)"},children:V==="timeline"?"Timeline":V==="per-eval"?"Per Eval":"Statistics"},V))}),h==="timeline"&&a.jsxs("div",{children:[X.length>0&&a.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:a.jsx(UC,{entries:X,onPointClick:V=>U(V.timestamp)})}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsxs("select",{value:p,onChange:V=>y(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Models"}),B.map(V=>a.jsx("option",{value:V,children:V},V))]}),a.jsxs("select",{value:v,onChange:V=>b(V.target.value),className:"input-field text-[12px]",style:{width:150},children:[a.jsx("option",{value:"",children:"All Types"}),a.jsx("option",{value:"benchmark",children:"Benchmark"}),a.jsx("option",{value:"comparison",children:"Comparison"}),a.jsx("option",{value:"baseline",children:"Baseline"}),a.jsx("option",{value:"model-compare",children:"Model Compare"}),a.jsx("option",{value:"improve",children:"AI Improve"}),a.jsx("option",{value:"instruct",children:"AI Edit"}),a.jsx("option",{value:"ai-generate",children:"AI Generate"}),a.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),a.jsx("div",{className:"flex-1"}),a.jsx("button",{onClick:()=>{S(!k),C([]),N(null)},className:`btn text-[12px] ${k?"btn-primary":"btn-secondary"}`,children:k?"Exit Compare":"Compare Runs"}),k&&w.length===2&&a.jsx("button",{onClick:z,disabled:M,className:"btn btn-primary text-[12px]",children:M?"Comparing...":"Compare"})]}),a.jsx("div",{className:"space-y-2",children:X.length===0?a.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(V=>{const W=w.includes(V.timestamp);return a.jsx("button",{onClick:()=>U(V.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:W?"var(--accent-muted)":"var(--surface-1)",border:W?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:de=>{W||(de.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:de=>{W||(de.currentTarget.style.borderColor="var(--border-subtle)")},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[k&&a.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:W?"var(--accent)":"var(--border-default)",background:W?"var(--accent)":"transparent"},children:W&&a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(V.timestamp).toLocaleString()}),a.jsx("span",{className:"pill text-[9px]",style:{background:V.type==="comparison"?"var(--purple-muted)":V.type==="baseline"?"var(--surface-3)":V.type==="model-compare"?"var(--accent-muted)":V.type==="improve"||V.type==="instruct"?"var(--purple-muted)":V.type==="ai-generate"?"var(--green-muted)":V.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:V.type==="comparison"?"var(--purple)":V.type==="baseline"?"var(--text-tertiary)":V.type==="model-compare"?"var(--accent)":V.type==="improve"||V.type==="instruct"?"var(--purple)":V.type==="ai-generate"?"var(--green)":V.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:V.type==="model-compare"?"model compare":V.type==="improve"?"ai improve":V.type==="instruct"?"ai edit":V.type==="ai-generate"?"ai generate":V.type==="eval-generate"?"eval generate":V.type})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ks,{version:d,size:"sm","data-testid":"history-row-version"}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:V.model}),V.totalCost!=null&&V.totalCost>0&&a.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Nn(V.totalCost)}),a.jsxs("span",{className:"text-[12px] font-semibold",style:{color:V.passRate>=.8?"var(--green)":V.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(V.passRate*100),"%"]})]})]})},V.timestamp)})}),T&&a.jsx(XC,{result:T}),L&&!k&&a.jsx(QC,{run:L,onClose:()=>F(null)})]}),h==="per-eval"&&a.jsx(YC,{plugin:s,skill:o}),h==="statistics"&&a.jsx(qC,{plugin:s,skill:o})]})}function XC({result:t}){const r=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&a.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[a.jsxs("span",{children:["Run A cost: ",Nn(t.runA.totalCost??null)]}),a.jsxs("span",{children:["Run B cost: ",Nn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&a.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Nn(t.runB.totalCost-t.runA.totalCost)]})]}),r.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",r.length,")"]}),r.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>a.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",a.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),a.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:a.jsxs("table",{className:"w-full text-[12px]",children:[a.jsx("thead",{children:a.jsxs("tr",{style:{background:"var(--surface-2)"},children:[a.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),a.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),a.jsx("tbody",{children:t.caseDiffs.map(o=>a.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[a.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),a.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function QC({run:t,onClose:r}){return(t.type==="improve"||t.type==="instruct")&&t.improve?a.jsx(ZC,{run:t,onClose:r}):a.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),a.jsx("button",{onClick:r,className:"btn btn-ghost text-[11px]",children:"Close"})]}),a.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Nn(t.totalCost)}`]}),a.jsx("div",{className:"space-y-2",children:t.cases.map(s=>a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),a.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&a.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Nn(s.cost)}),a.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function ZC({run:t,onClose:r}){var u;const s=m.useMemo(()=>t.improve?Go(t.improve.original,t.improve.improved):[],[t.improve]),o=m.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=m.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return a.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),a.jsx("path",{d:"M2 17l10 5 10-5"}),a.jsx("path",{d:"M2 12l10 5 10-5"})]})}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),a.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[a.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),a.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),a.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&a.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[a.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),a.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:a.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:a.jsx("tbody",{children:c.map((d,h)=>a.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),a.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),a.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),a.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function Ny({data:t}){if(t.length<2)return a.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const r=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=r.length,g=Math.min(...r),y=Math.max(...r)-g||1,v=r.map((S,w)=>{const C=c+w/(h-1)*u,T=c+d-(S-g)/y*d;return`${C.toFixed(1)},${T.toFixed(1)}`}),b=r[r.length-1],k=Tl(b);return a.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[a.jsx("polyline",{points:v.join(" "),fill:"none",stroke:k,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[S,w]=v[v.length-1].split(",");return a.jsx("circle",{cx:S,cy:w,r:2.5,fill:k})})()]})}function JC(){return a.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:a.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function eE({pct:t}){const r=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return a.jsxs("span",{className:"pill",style:{background:s,color:r,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function tE({score:t,rating:r}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[r]??s.minimal,c=t>=0?"+":"";return a.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[a.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),a.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",r.toUpperCase(),")"]})]})}function nE({warning:t}){return a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),a.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),a.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),a.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function aE({active:t,onChange:r,hasBaseline:s}){return a.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[a.jsx("button",{onClick:()=>r("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),a.jsx("button",{onClick:()=>r("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function rE(t){var o,c,u;if(t.length===0)return[];const r=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;r.has(g)||r.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const p=r.get(g);p.passRates.push(h.passRate.mean),p.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,p.lastDuration=h.duration.mean,p.lastCost=((c=h.cost)==null?void 0:c.total)??null,p.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(p.lastBaselinePassRate=h.baselinePassRate.mean,p.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,p.lastAmplificationPct=h.amplificationPct,p.hasBaseline=!0)}const s=[];for(const[d,h]of r){const[g,...p]=d.split("/");s.push({rank:0,model:p.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Ty=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function lE({entries:t}){return a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(r=>a.jsx("th",{style:Ty(r==="#"?"center":"left"),children:r},r))})}),a.jsx("tbody",{children:t.map(r=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:r.rank}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:r.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:r.provider}),r.isBest&&a.jsx(JC,{})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:r.passRate>=.7?"var(--green-muted)":r.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(r.passRate),fontSize:11,fontWeight:600},children:[Math.round(r.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.rubricScore!=null?r.rubricScore.toFixed(1):"--"}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.duration<1e3?`${Math.round(r.duration)}ms`:`${(r.duration/1e3).toFixed(1)}s`}),a.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:r.cost!=null?`$${r.cost.toFixed(4)}`:"N/A"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ny,{data:r.sparklineData})})]},`${r.provider}/${r.model}`))})]})})}function sE({entries:t}){const r=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return r.length===0?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx("div",{className:"text-center",children:a.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",a.jsx("code",{children:"--baseline"})," flag."]})})}):a.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[a.jsx("thead",{children:a.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>a.jsx("th",{style:Ty(s==="#"?"center":"left"),children:s},s))})}),a.jsx("tbody",{children:r.map((s,o)=>a.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[a.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),a.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Tl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),a.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?a.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?a.jsx(eE,{pct:s.amplificationPct}):"--"}),a.jsx("td",{style:{padding:"10px 12px"},children:a.jsx(Ny,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function iE(){const{state:t}=Tn(),{plugin:r,skill:s}=t,[o,c]=m.useState("rankings"),u=`leaderboard/${r}/${s}`,d=m.useCallback(()=>Ee.getLeaderboard(r,s),[r,s]),{data:h,loading:g}=Ml(u,d),p=(h==null?void 0:h.entries)??[];m.useEffect(()=>{c("rankings")},[r,s]);const y=m.useCallback(()=>on(u),[u]);Lo("leaderboard:updated",y);const v=m.useMemo(()=>rE(p),[p]),b=v.some(w=>w.hasBaseline),k=p[0],S=k==null?void 0:k.judgeBiasWarning;return g?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M18 20V10"}),a.jsx("path",{d:"M12 20V4"}),a.jsx("path",{d:"M6 20v-6"})]})}),a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),a.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),a.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),a.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",a.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):a.jsxs("div",{className:"p-5 animate-fade-in",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),a.jsx(aE,{active:o,onChange:c,hasBaseline:b})]}),a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[p.length," sweep",p.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),S&&a.jsx(nE,{warning:S}),o==="rankings"?a.jsx(lE,{entries:v}):a.jsx(sE,{entries:v}),o==="amplification"&&(k==null?void 0:k.skillQualityScore)!=null&&(k==null?void 0:k.skillQualityRating)&&a.jsx(tE,{score:k.skillQualityScore,rating:k.skillQualityRating})]})}function oE({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState([]),[d,h]=m.useState(!0),[g,p]=m.useState(null);m.useEffect(()=>{Ee.getDependencies(t,r).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,r]);async function y(v,b){try{await navigator.clipboard.writeText(b),p(v),setTimeout(()=>p(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?a.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):a.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),a.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),a.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),a.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>a.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),a.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),a.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),a.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>a.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),a.jsx("div",{className:"space-y-1.5",children:c.map(v=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),a.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Fg({plugin:t,skill:r}){const[s,o]=m.useState([]),[c,u]=m.useState(!0),[d,h]=m.useState(null),[g,p]=m.useState(""),[y,v]=m.useState(!1),[b,k]=m.useState(null),[S,w]=m.useState(""),[C,T]=m.useState(""),[N,M]=m.useState(!1),[H,L]=m.useState(new Set),F=m.useCallback(async()=>{u(!0);try{const[D,I]=await Promise.all([Ee.getCredentials(t,r).catch(()=>({credentials:[]})),Ee.getParams(t,r).catch(()=>({params:[]}))]),q=new Map(I.params.map(U=>[U.name,U])),X=new Set,Y=[];for(const U of D.credentials){X.add(U.name);const z=q.get(U.name);Y.push({name:U.name,status:U.status==="ready"||U.status==="resolved"?"ready":"missing",source:U.source,maskedValue:z==null?void 0:z.maskedValue})}for(const U of I.params)X.has(U.name)||Y.push({name:U.name,status:U.status,maskedValue:U.maskedValue});o(Y)}finally{u(!1)}},[t,r]);m.useEffect(()=>{F()},[F]);const E=m.useCallback(async D=>{if(H.has(D)){L(I=>{const q=new Set(I);return q.delete(D),q}),o(I=>I.map(q=>q.name===D?{...q,revealedValue:void 0}:q));return}try{const q=(await Ee.getParamsRevealed(t,r,D)).params.find(X=>X.name===D);q&&(o(X=>X.map(Y=>Y.name===D?{...Y,revealedValue:q.value}:Y)),L(X=>new Set(X).add(D)))}catch{}},[t,r,H]),O=async(D,I)=>{if(!(!D.trim()||!I.trim())){v(!0),k(null);try{await Ee.setCredential(t,r,D,I),h(null),p(""),L(new Set),F()}catch(q){k(q.message)}finally{v(!1)}}},R=async()=>{if(!(!S.trim()||!C.trim())){v(!0),k(null);try{await Ee.setCredential(t,r,S.trim().toUpperCase(),C),w(""),T(""),M(!1),F()}catch(D){k(D.message)}finally{v(!1)}}};return c?a.jsxs("div",{className:"mt-6",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):a.jsxs("div",{className:"mt-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),a.jsx("button",{onClick:()=>M(!N),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&a.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!N?a.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):a.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(D=>a.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[a.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:D.name}),D.maskedValue&&a.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:H.has(D.name)&&D.revealedValue!=null?D.revealedValue:D.maskedValue}),D.maskedValue&&a.jsx("button",{onClick:()=>E(D.name),className:"btn btn-ghost px-1",title:H.has(D.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:H.has(D.name)?a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),a.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),a.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),a.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:D.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:D.status==="ready"?"var(--green)":"var(--orange)"},children:D.status==="ready"?"ready":"missing"}),D.source&&a.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:D.source}),d===D.name?a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("input",{value:g,onChange:I=>p(I.target.value),onKeyDown:I=>{I.key==="Enter"&&O(D.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),a.jsx("button",{onClick:()=>O(D.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),a.jsx("button",{onClick:()=>{h(null),p("")},className:"btn btn-ghost text-[10px] px-1",children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):a.jsx("button",{onClick:()=>{h(D.name),p("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},D.name))}),N&&a.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsx("input",{value:S,onChange:D=>w(D.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),a.jsx("input",{value:C,onChange:D=>T(D.target.value),onKeyDown:D=>{D.key==="Enter"&&R()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),a.jsxs("div",{className:"flex justify-end gap-1.5",children:[a.jsx("button",{onClick:()=>{M(!1),w(""),T("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),a.jsx("button",{onClick:R,disabled:y||!S.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function cE(){const{state:t}=Tn(),{plugin:r,skill:s}=t,[o,c]=m.useState(null),[u,d]=m.useState(!0);return m.useEffect(()=>{Ee.getDependencies(r,s).then(c).catch(()=>{}).finally(()=>d(!1))},[r,s]),u?a.jsxs("div",{className:"p-5",children:[a.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),a.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx(oE,{plugin:r,skill:s}),a.jsx(Fg,{plugin:r,skill:s})]}):a.jsxs("div",{className:"p-5 max-w-3xl",children:[a.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),a.jsx(Fg,{plugin:r,skill:s})]})}function uE(t){const r={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(r.targetAgents=t.targetAgents),r}function dE(t){var c;const r=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:r?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function lf(t,r=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return r&&(s=s.replace(/^-+|-+$/g,"")),s}function fE(t,r,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(r){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function pE({onCreated:t,resolveAiConfigOverride:r,forceLayout:s}){const[o,c]=m.useState("ai"),[u,d]=m.useState(null),[h,g]=m.useState(!0),{config:p}=_r(),[y,v]=m.useState(""),[b,k]=m.useState(s??3),[S,w]=m.useState(""),[C,T]=m.useState(""),[N,M]=m.useState(""),[H,L]=m.useState(""),[F,E]=m.useState(""),[O,R]=m.useState(""),[D,I]=m.useState("write"),[q,X]=m.useState([]),[Y,U]=m.useState(!1),[z,B]=m.useState(null),[V,W]=m.useState(""),[de,_]=m.useState(!1),[P,ee]=m.useState(!1),[re,xe]=m.useState(null),[ce,ye]=m.useState(null),[ue,je]=m.useState([]),Re=m.useRef(null),Le=m.useRef(null),ae=m.useRef(null),fe=m.useRef(null),me=m.useRef(null),[he,be]=m.useState(!1),[Be,Oe]=m.useState(!1),st=m.useRef(y),At=m.useRef(S),gt=m.useRef(C);m.useEffect(()=>{st.current=y},[y]),m.useEffect(()=>{At.current=S},[S]),m.useEffect(()=>{gt.current=C},[C]),m.useEffect(()=>{Ee.getProjectLayout().then($e=>{if(d($e),s)return;k($e.suggestedLayout);const Je=$e.detectedLayouts.find(yt=>yt.layout===$e.suggestedLayout);Je!=null&&Je.existingPlugins.length&&w(Je.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),m.useEffect(()=>{var $e;o==="ai"&&(($e=Re.current)==null||$e.focus())},[o]),m.useEffect(()=>()=>{var $e;($e=Le.current)==null||$e.abort()},[]);const Gt=m.useMemo(()=>{var $e;return u?(($e=u.detectedLayouts.find(Je=>Je.layout===b))==null?void 0:$e.existingPlugins)||[]:[]},[u,b]),vt=S==="__new__"?C:S,Ze=u?fE(u.root,b,vt||"{plugin}",y||"{skill}"):"",at=m.useMemo(()=>u?u.detectedLayouts.filter($e=>$e.layout!==4):[],[u]),ve=m.useMemo(()=>{if(!u)return null;const $e=u.detectedLayouts.find(ut=>ut.layout===2&&ut.existingPlugins.length>0),Je=u.detectedLayouts.find(ut=>ut.layout===1&&ut.existingPlugins.length>0),yt=$e||Je;return yt?{layout:yt.layout,plugins:yt.existingPlugins}:null},[u]),ct=m.useCallback(()=>{if(r)return r();if(!p)return{provider:"claude-cli",model:"sonnet"};const $e=p.provider||"claude-cli",Je=p.model||"sonnet";return{provider:$e,model:Je}},[p,r]),Nt=m.useCallback(()=>{var $e;($e=Le.current)==null||$e.abort(),_(!1)},[]),nn=m.useCallback(()=>{xe(null),ye(null)},[]),Rn=m.useCallback(async()=>{var ut,Fn;if(xe(null),ye(null),je([]),ae.current=null,fe.current=null,!V.trim()){xe("Describe what your skill should do");return}_(!0);const $e=new AbortController;Le.current=$e;const{provider:Je,model:yt}=ct();try{const Qt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(uE({prompt:V.trim(),provider:Je,model:yt,targetAgents:q})),signal:$e.signal});if(!Qt.ok||!Qt.body){let un=`HTTP ${Qt.status}`;try{const ca=await Qt.json();ca.error&&(un=ca.error)}catch{}throw new Error(un)}const Gn=Qt.body.getReader(),se=new TextDecoder;let we="",ze="";for(;;){const{done:un,value:ca}=await Gn.read();if(un)break;we+=se.decode(ca,{stream:!0});const La=we.split(`
86
+ `);we=La.pop()||"";for(const Ir of La)if(Ir.startsWith("event: "))ze=Ir.slice(7).trim();else if(Ir.startsWith("data: ")){try{const dt=JSON.parse(Ir.slice(6));if(ze==="progress")je(za=>[...za,{phase:dt.phase,message:dt.message,timestamp:Date.now()}]);else if(ze==="provenance")fe.current={resolvedModelId:typeof dt.resolvedModelId=="string"?dt.resolvedModelId:null,snapshotDate:typeof dt.snapshotDate=="string"?dt.snapshotDate:null};else if(ze==="done"||ze==="complete"){const za={prompt:V.trim(),provider:ct().provider,model:ct().model,resolvedModelId:((ut=fe.current)==null?void 0:ut.resolvedModelId)??null,snapshotDate:((Fn=fe.current)==null?void 0:Fn.snapshotDate)??null,reasoning:dt.reasoning||""},An=dE({userName:st.current,userPlugin:At.current,userNewPlugin:gt.current,aiName:dt.name,aiSuggestedPlugin:dt.suggestedPlugin&&dt.suggestedPlugin.plugin?{plugin:dt.suggestedPlugin.plugin,layout:dt.suggestedPlugin.layout}:null,forceLayout:s});if(An.applyName!==null&&v(An.applyName),M(dt.description),L(dt.model||""),E(dt.allowedTools||""),R(dt.body),ee(!0),ae.current=za,c("manual"),s===3)k(3),w(""),T("");else if(An.applySuggestedPlugin&&An.suggestedPluginValue){const Zt=An.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(ua=>ua.existingPlugins))??[]).includes(Zt.plugin))if(w(Zt.plugin),Zt.layout&&(Zt.layout===1||Zt.layout===2))k(Zt.layout);else{const ua=u==null?void 0:u.detectedLayouts.find(Dl=>Dl.existingPlugins.includes(Zt.plugin));ua&&(ua.layout===1||ua.layout===2)&&k(ua.layout)}else w("__new__"),T(Zt.plugin)}else!An.applySuggestedPlugin&&At.current.trim().length===0&&gt.current.trim().length===0&&b===3&&ve&&Oe(!0);const Yo={name:dt.name,plugin:vt||"",layout:b,description:dt.description,model:dt.model||void 0,allowedTools:dt.allowedTools||void 0,body:dt.body,aiMeta:za};Ee.saveDraft(Yo).then(Zt=>{be(!0),Zt!=null&&Zt.dir&&(me.current=Zt.dir)}).catch(()=>{})}else ze==="error"&&(xe(dt.message||dt.description||"Unknown error"),dt.category&&ye(dt))}catch{}ze=""}}}catch(Qt){Qt.name!=="AbortError"&&xe(Qt.message)}finally{_(!1),Le.current=null}},[V,ct,b,ve,vt,u,q,s]),Vt=m.useCallback(async()=>{if(B(null),!y.trim()){B("Skill name is required");return}if(!N.trim()){B("Description is required");return}if(b!==3&&!vt.trim()){B("Plugin name is required");return}U(!0);try{const $e=await Ee.createSkill({name:lf(y),plugin:vt||"",layout:b,description:N,model:H||void 0,allowedTools:F||void 0,body:O,aiMeta:ae.current||void 0,draftDir:me.current||void 0});me.current=null,t($e.plugin,$e.skill)}catch($e){B($e.message)}finally{U(!1)}},[y,N,b,vt,H,F,O,t]),oa=m.useCallback(()=>{ve&&(k(ve.layout),w(ve.plugins[0]),Oe(!1))},[ve]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:k,creatableLayouts:at,availablePlugins:Gt,pathPreview:Ze,plugin:S,setPlugin:w,newPlugin:C,setNewPlugin:T,effectivePlugin:vt,name:y,setName:v,description:N,setDescription:M,model:H,setModel:L,allowedTools:F,setAllowedTools:E,body:O,setBody:R,bodyViewMode:D,setBodyViewMode:I,aiPrompt:V,setAiPrompt:W,generating:de,aiGenerated:P,aiError:re,aiClassifiedError:ce,aiProgress:ue,promptRef:Re,handleGenerate:Rn,handleCancelGenerate:Nt,clearAiError:nn,targetAgents:q,setTargetAgents:X,draftSaved:he,showPluginRecommendation:Be,setShowPluginRecommendation:Oe,pluginLayoutInfo:ve,applyPluginRecommendation:oa,creating:Y,error:z,handleCreate:Vt,standaloneLocked:s===3}}function Ry(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function mE(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Ay({node:t,depth:r=0}){var s;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${r*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?a.jsx(Ry,{}):a.jsx(mE,{}),a.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>a.jsx(Ay,{node:o,depth:r+1},o.name))]})}function hE(t,r,s){const o=[];r&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function xE({skillName:t,hasEvals:r,isDraft:s}){const o=hE(t,r,s);return a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsx(Ry,{})}),"Skill Structure"]}),a.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:a.jsx(Ay,{node:o})})]})}const lr={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Dd({size:t=14,color:r="currentColor"}){return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function gE({onCreated:t,onCancel:r}){const s=pE({onCreated:t});return a.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[a.jsxs("div",{className:"mb-5",children:[a.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),a.jsx("div",{className:"flex items-center justify-between mt-2",children:a.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[a.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(Dd,{size:12}),"AI-Assisted"]})}),a.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),a.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[a.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:a.jsx(Dd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),a.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
87
87
 
88
88
  Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...lr,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),a.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&a.jsx(Xs,{entries:s.aiProgress,isRunning:!0}),s.aiError&&a.jsx("div",{children:s.aiClassifiedError?a.jsx(Wo,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):a.jsxs("div",{children:[a.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),a.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),a.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?a.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):a.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[a.jsx(Dd,{size:14}),"Generate"]}),a.jsx("button",{onClick:r,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&a.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",a.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&a.jsxs("div",{className:"space-y-4 animate-fade-in",children:[a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),a.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>a.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),a.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr,children:[s.availablePlugins.map(o=>a.jsx("option",{value:o,children:o},o)),a.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&a.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(lf(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:lr})]}),a.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&a.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),a.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),a.jsxs("span",{children:["Plugins detected (",a.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),a.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:a.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(lf(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr})]}),a.jsxs("div",{className:"mb-3",children:[a.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",a.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),a.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...lr,minHeight:"72px"}})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),a.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr,children:[a.jsx("option",{value:"",children:"Any"}),a.jsx("option",{value:"opus",children:"Opus"}),a.jsx("option",{value:"sonnet",children:"Sonnet"}),a.jsx("option",{value:"haiku",children:"Haiku"})]})]}),a.jsxs("div",{className:"flex-1",children:[a.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),a.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:lr})]})]})]}),a.jsxs("div",{className:"glass-card p-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),a.jsxs("div",{children:[a.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),a.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),a.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>a.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("polyline",{points:"16 18 22 12 16 6"}),a.jsx("polyline",{points:"8 6 2 12 8 18"})]}):a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),a.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),a.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?a.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
89
89
 
@@ -99,4 +99,4 @@ You are an expert at...
99
99
  from { opacity: 0; transform: translateX(-50%) translateY(2px); }
100
100
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
101
101
  }`})]}),document.body)}function kN({agent:t,focused:r,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return a.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:r?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),a.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function wN({row:t,onFocus:r}){return a.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:r,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),a.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),a.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function CN({agent:t}){const r=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return a.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:r,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),a.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&a.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function EN({agent:t,activeAgentId:r,onSwitch:s}){const o=t.id===r,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":te.scopePicker.switchCta;return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":TN(t.health)})]}),a.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[a.jsx(Id,{label:te.scopePicker.statsInstalled,value:String(t.installedCount)}),a.jsx(Id,{label:te.scopePicker.statsGlobal,value:String(t.globalCount)}),a.jsx(Id,{label:te.scopePicker.statsLastSync,value:t.lastSync?NN(t.lastSync):"—"})]}),a.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function Id({label:t,value:r}){return a.jsxs(a.Fragment,{children:[a.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),a.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:r})]})}function Xg(){return a.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function NN(t){try{const r=new Date(t).getTime(),s=Date.now()-r;if(Number.isNaN(r))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function TN(t){switch(t){case"ok":return te.scopePicker.statsHealthOk;case"stale":return te.scopePicker.statsHealthStale;case"missing":return te.scopePicker.statsHealthMissing}}function RN(t){const r=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)r.set(o,s);return t.agents.map(s=>{const o=r.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function AN({agents:t,activeAgentId:r,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=m.useState(!1),[d,h]=m.useState(null),g=m.useRef(null),p=m.useMemo(()=>t.find(k=>k.id===r)??t[0]??null,[t,r]),y=m.useMemo(()=>p?p.health==="ok"?"var(--color-ok, #22c55e)":p.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[p]),v=m.useCallback(()=>{var k;u(!1),(k=g.current)==null||k.focus()},[]),b=m.useCallback(k=>{s(k),u(!1)},[s]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(k=>!k),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),a.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(p==null?void 0:p.displayName)??"Select agent"}),a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(p==null?void 0:p.installedCount)??0," · ",(p==null?void 0:p.globalCount)??0,")"]}),a.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&a.jsx(SN,{agents:t,activeAgentId:r,focusedAgentId:d??r,onFocusAgent:h,onSwitch:b,onOpenSetup:k=>{o(k),v()},onClose:v})]})}const By="vskill-ccode-banner-dismissed",MN=new Set(["claude-cli","claude-code"]);function LN(){try{return sessionStorage.getItem(By)==="true"}catch{return!1}}function zN(){try{sessionStorage.setItem(By,"true")}catch{}}function DN({activeAgentId:t}){const[r,s]=m.useState(()=>LN()),o=m.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=m.useCallback(()=>{zN(),s(!0)},[]);return!t||!MN.has(t)||r?null:a.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[a.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{children:[te.claudeCodeLabel.firstUseBanner," "]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:te.claudeCodeLabel.learnMore})]}),a.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function _N(){const[t,r]=m.useState(null),[s,o]=m.useState("loading"),[c,u]=m.useState(null),d=m.useCallback(async()=>{try{const h=await Ee.getAgents();r(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return m.useEffect(()=>{d()},[d]),m.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const vo="workspace",ON=["skills","agents"];async function BN(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function IN(t){const r=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${r.status}`)}return await r.json()}async function HN(t){const r=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${r.status}`)}return await r.json()}async function UN(t){const r=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok){const s=await r.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${r.status}`)}return await r.json()}function Hd(){for(const t of ON)on(t)}function $N(){const{data:t,loading:r,error:s,revalidate:o}=Ml(vo,BN),c=t,u=c==null?void 0:c.projects.find(p=>p.id===c.activeProjectId),d=m.useCallback(async p=>{await IN(p),on(vo),Hd()},[]),h=m.useCallback(async p=>{await HN(p),on(vo),Hd()},[]),g=m.useCallback(async p=>{await UN(p),on(vo),Hd()},[]);return{workspace:c,activeProject:u,loading:r,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function VN({workspace:t,onSwitch:r,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=m.useState(!1),[h,g]=m.useState(!1),[p,y]=m.useState(""),[v,b]=m.useState(null),[k,S]=m.useState(null),[w,C]=m.useState(null),[T,N]=m.useState(!1),M=m.useRef(null),H=(t==null?void 0:t.projects)??[],L=H.find(R=>R.id===(t==null?void 0:t.activeProjectId));m.useEffect(()=>{if(!u)return;function R(D){M.current&&!M.current.contains(D.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[u]);async function F(){b(null);const R=p.trim();if(!R){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!R.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(R)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:R}),y(""),g(!1)}catch(D){const I=D instanceof Error?D.message:String(D);/does not exist/i.test(I)?b(`Path not found on disk: ${R}`):/Duplicate/i.test(I)?b("That project is already registered."):b(I)}}async function E(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const R=await window.showDirectoryPicker();y(R.name),g(!0)}catch{}else g(!0)}function O(R){if(R.length<=50)return R;const D=R.split("/");return D.length<=4?R:`${D.slice(0,3).join("/")}/…/${D.slice(-2).join("/")}`}return a.jsxs("div",{ref:M,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[a.jsxs("button",{type:"button",onClick:()=>d(R=>!R),"aria-expanded":u,"aria-haspopup":"menu",title:(L==null?void 0:L.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(L==null?void 0:L.colorDot)??"var(--text-tertiary, #999)"}}),a.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L?L.name:"No project"}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&a.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[H.length===0&&a.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),H.length>0&&a.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:H.map(R=>{const D=c?c(R.path):!1,I=R.id===(t==null?void 0:t.activeProjectId),q=k===R.id;return a.jsxs("li",{role:"menuitem","data-stale":D?"true":"false",onMouseEnter:()=>S(R.id),onMouseLeave:()=>S(X=>X===R.id?null:X),onClick:()=>{if(!D){if(I){d(!1);return}C(R)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:D?"not-allowed":"pointer",background:q&&!D?"var(--surface-2, rgba(0,0,0,0.04))":I?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:D?.5:1,transition:"background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:R.colorDot,boxShadow:I?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:I?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[a.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),I&&a.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),a.jsx("div",{title:R.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(R.path)}),D&&a.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),a.jsx("button",{type:"button","aria-label":`Remove ${R.name}`,onClick:X=>{X.stopPropagation(),o(R.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("polyline",{points:"3 6 5 6 21 6"}),a.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),a.jsx("path",{d:"M10 11v6"}),a.jsx("path",{d:"M14 11v6"}),a.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},R.id)})}),a.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&a.jsxs("button",{type:"button",onClick:()=>void E(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:R=>{R.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:R=>{R.currentTarget.style.backgroundColor="transparent"},children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),a.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("input",{type:"text",value:p,onChange:R=>y(R.target.value),onKeyDown:R=>{R.key==="Enter"&&F(),R.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),a.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),w&&a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[a.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),a.jsxs("div",{onClick:R=>R.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[a.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",w.name]}),a.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),a.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${w.path}" && npx vskill@latest studio`}),a.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[a.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${w.path}" && npx vskill@latest studio`),N(!0),setTimeout(()=>N(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:T?"Copied!":"Copy command"}),a.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function PN(t,r){const s=r.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function FN({open:t,projects:r,onSwitch:s,onClose:o}){const[c,u]=m.useState(""),[d,h]=m.useState(0),g=m.useMemo(()=>PN(r,c),[r,c]);m.useEffect(()=>{t||(u(""),h(0))},[t]),m.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const p=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?a.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[a.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),a.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[a.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:p,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),a.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&a.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>a.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[a.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),a.jsxs("span",{className:"flex-1",children:[a.jsx("span",{className:"vskill-palette-name",children:y.name}),a.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const Qg=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function GN({open:t,onClose:r,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=m.useState("destination"),[g,p]=m.useState(s),[y,v]=m.useState(""),[b,k]=m.useState(""),[S,w]=m.useState(""),[C,T]=m.useState([]),[N,M]=m.useState(!1),[H,L]=m.useState(null);if(m.useEffect(()=>{t&&(h("destination"),p(s),v(""),k(""),w(""),L(null))},[t,s]),m.useEffect(()=>{if(!t)return;let U=!0;return fetch("/api/authoring/plugins").then(z=>z.json()).then(z=>{U&&T(z.plugins??[])}).catch(()=>{}),()=>{U=!1}},[t]),m.useEffect(()=>{if(!t)return;function U(z){z.key==="Escape"&&(z.preventDefault(),r())}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[t,r]),!t)return null;const F=C.length>0,E=o&&F,O=o,R=Qg.test(y),D=g==="existing-plugin"?b.length>0:Qg.test(b),I=!N&&R&&(g==="standalone"||D),q=WN(c,g,b,y);async function X(){L(null),M(!0);try{const B=new URLSearchParams;B.set("mode",g),B.set("skillName",y),b&&B.set("pluginName",b);const V=await fetch(`/api/authoring/skill-exists?${B.toString()}`),W=await V.json();if(!V.ok){L(W.error??`Check failed: ${V.status}`);return}if(W.exists){L(`Skill '${y}' already exists${W.path?` at ${W.path}`:""}`);return}}catch(B){L(B instanceof Error?B.message:String(B));return}finally{M(!1)}const U=new URLSearchParams;U.set("mode",g),U.set("skillName",y),S.trim()&&U.set("description",S.trim()),b&&U.set("pluginName",b);const z=`#/create?${U.toString()}`;typeof window<"u"&&(window.location.hash=z),r()}async function Y(){L(null),M(!0);try{const U=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:S.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),z=await U.json();if(!U.ok||!z.ok){L(z.error??`Create failed: ${U.status}`);return}on("skills"),u==null||u({mode:g,skillName:y,pluginName:z.pluginName??null,skillMdPath:z.skillMdPath}),r()}catch(U){L(U instanceof Error?U.message:String(U))}finally{M(!1)}}return a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),a.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[a.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),a.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&a.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[a.jsx(Ud,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>p("standalone")}),a.jsx(Ud,{title:"Add to existing plugin",subtitle:E?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!E,selected:g==="existing-plugin",onClick:()=>E&&p("existing-plugin")}),a.jsx(Ud,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&p("new-plugin")})]}),d==="details"&&a.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&a.jsx(yo,{label:"Plugin name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:b,onChange:U=>k(U.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:bo(!b||D)})}),g==="existing-plugin"&&a.jsx(yo,{label:"Plugin",children:a.jsxs("select",{value:b,onChange:U=>k(U.target.value),style:{...bo(!0),fontFamily:"var(--font-mono)"},children:[a.jsx("option",{value:"",children:"Select a plugin…"}),C.map(U=>a.jsx("option",{value:U.name,children:U.name},U.path))]})}),a.jsx(yo,{label:"Skill name",hint:"kebab-case",children:a.jsx("input",{type:"text",value:y,onChange:U=>v(U.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:bo(!y||R)})}),a.jsx(yo,{label:"Description",hint:"One short sentence — shown in frontmatter",children:a.jsx("textarea",{value:S,onChange:U=>w(U.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...bo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&a.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[a.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map((U,z)=>a.jsx("div",{children:U},z))]}),H&&a.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:H})]}),a.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[a.jsx("button",{type:"button",onClick:r,style:$d,children:"Cancel"}),d==="destination"&&a.jsx("button",{type:"button",onClick:()=>h("details"),style:Zg,children:"Continue →"}),d==="details"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>h("destination"),style:$d,children:"← Back"}),a.jsx("button",{type:"button",onClick:()=>void X(),disabled:!I,style:{...$d,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),a.jsx("button",{type:"button",onClick:()=>void Y(),disabled:!I,style:{...Zg,opacity:I?1:.5,cursor:I?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:N?"Creating…":"Create empty scaffold"})]})]})]})]})}function Ud({title:t,subtitle:r,description:s,icon:o,selected:c,disabled:u,onClick:d}){return a.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:r}),a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function yo({label:t,hint:r,children:s}){return a.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[a.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[a.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),r&&a.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:r})]}),s]})}function bo(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const Zg={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},$d={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function WN(t,r,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return r==="standalone"?[`${d}/skills/${c}/SKILL.md`]:r==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:r==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function qN({open:t,onClose:r,onInstall:s,installedNames:o}){const[c,u]=m.useState([]),[d,h]=m.useState(null),[g,p]=m.useState(null),[y,v]=m.useState(!1),[b,k]=m.useState(null);return m.useEffect(()=>{t&&(v(!0),k(null),fetch("/api/plugins/marketplaces").then(S=>S.json()).then(S=>{if(S.error)throw new Error(S.error);u(S.marketplaces??[])}).catch(S=>k(S instanceof Error?S.message:String(S))).finally(()=>v(!1)))},[t]),m.useEffect(()=>{if(!d){p(null);return}v(!0),k(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(d)}`).then(S=>S.json()).then(S=>{if(S.error)throw new Error(S.error);p(S)}).catch(S=>k(S instanceof Error?S.message:String(S))).finally(()=>v(!1))},[d]),m.useEffect(()=>{if(!t)return;function S(w){w.key==="Escape"&&r()}return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,r]),t?a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[a.jsx("div",{onClick:r,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),a.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[d&&a.jsx("button",{type:"button",onClick:()=>h(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),a.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:d?(g==null?void 0:g.name)??d:"Browse plugins"}),a.jsx("button",{type:"button",onClick:r,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),a.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[y&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),b&&a.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:b}),!d&&!y&&c.length===0&&!b&&a.jsx(YN,{}),!d&&c.map(S=>a.jsxs("button",{type:"button",onClick:()=>h(S.name),style:XN,onMouseEnter:w=>{w.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},children:[a.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:S.name}),a.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.source})]},S.name)),d&&g&&a.jsxs(a.Fragment,{children:[g.description&&a.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:g.description}),g.plugins.length===0&&a.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),g.plugins.map(S=>{const w=o.has(S.name);return a.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:a.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[a.jsxs("div",{style:{flex:1,minWidth:0},children:[a.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[S.name,S.version&&a.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:S.version}),S.category&&a.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:S.category})]}),S.description&&a.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:S.description})]}),a.jsx("button",{type:"button",disabled:w,onClick:()=>s(S.name,d),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:w?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:w?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:w?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:w?"default":"pointer",fontFamily:"inherit",boxShadow:w?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:w?"Installed":"Install"})]})},S.name)})]})]}),!d&&a.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:a.jsx(KN,{onAdded:()=>{on("marketplaces"),fetch("/api/plugins/marketplaces").then(S=>S.json()).then(S=>u(S.marketplaces??[]))}})})]})]}):null}function YN(){return a.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",a.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[a.jsx("li",{children:a.jsx("code",{children:"anthropics/claude-plugins-official"})}),a.jsx("li",{children:a.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function KN({onAdded:t}){const[r,s]=m.useState(""),[o,c]=m.useState(!1),[u,d]=m.useState(null);async function h(){const g=r.trim();if(g){c(!0),d(null);try{const p=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await p.json().catch(()=>({}));if(!p.ok||!y.ok){d(y.error??`Add failed (${p.status})`);return}s(""),t()}catch(p){d(p instanceof Error?p.message:String(p))}finally{c(!1)}}}return a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[a.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),a.jsxs("div",{style:{display:"flex",gap:6},children:[a.jsx("input",{type:"text",value:r,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),a.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!r.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!r.trim()?"not-allowed":"pointer",opacity:o||!r.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&a.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const XN={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Vd=12;function QN({job:t,onDone:r}){const[s,o]=m.useState([]),[c,u]=m.useState("running"),[d,h]=m.useState(!1);if(m.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],k="running";return(async()=>{try{const S=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(!S.ok||!S.body){u("failed"),r({ok:!1,code:S.status,lines:[`HTTP ${S.status}`]});return}const w=S.body.getReader(),C=new TextDecoder;let T="";for(;;){const{value:N,done:M}=await w.read();if(M)break;T+=C.decode(N,{stream:!0});const H=T.split(/\n\n/);T=H.pop()??"";for(const L of H){const F=L.match(/^data:\s*(.*)$/m);if(F)try{const E=JSON.parse(F[1]);E.type==="stdout"&&E.line?(b=[...b,E.line].slice(-Vd),o(b)):E.type==="stderr"&&E.line?(b=[...b,`⚠ ${E.line}`].slice(-Vd),o(b)):E.type==="done"?(k=E.ok?"ok":"failed",u(k),on("plugins"),on("skills"),r({ok:E.ok??!1,code:E.code??null,lines:b})):E.type==="error"&&E.error&&(b=[...b,`✘ ${E.error}`].slice(-Vd),o(b))}catch{}}}k==="running"&&r({ok:!0,code:0,lines:b})}catch(S){if(S.name==="AbortError")return;u("failed"),r({ok:!1,code:null,lines:[...b,S instanceof Error?S.message:String(S)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",p=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return a.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[a.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[a.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?a.jsx(ZN,{}):p}),a.jsxs("span",{style:{flex:1,minWidth:0},children:[a.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,a.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&a.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),a.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&a.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
- `)})]})}function ZN(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const JN=3e3,eT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Jg(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function tT(){const{toast:t}=qo(),r=m.useRef(new Map),s=m.useCallback(o=>{if(!Jg(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<JN)return;r.current.set(o.provider,c);const d=eT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!Jg(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Iy="vskill.studio.prefs";function Hy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Uy(){const t=Hy();if(!t)return{};try{const r=t.getItem(Iy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function nT(t,r){const s=Hy();if(s)try{const c={...Uy(),[t]:r};s.setItem(Iy,JSON.stringify(c))}catch{}}function aT(t,r){const o=Uy()[t];return o===void 0?r:o}const ev={open:!1,x:0,y:0,skill:null};function rT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function Ar(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function lT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function sT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{Ar(te.toasts.permissionDenied,"error");return}Ar(te.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ar(te.actions.editPlaceholder,"info");return;case"run-benchmark":Ar(te.toasts.benchmarkQueued,"info");return;case"duplicate":Ar(te.toasts.skillDuplicated,"info");return;case"update":Ar(te.toasts.skillUpdated,"info");return;case"uninstall":Ar(te.actions.editPlaceholder,"info");return;case"delete":lT(r);return;default:return}}const iT=m.lazy(()=>Io(()=>import("./CommandPalette-mzfSdGtx.js"),__vite__mapDeps([2,1]))),oT=m.lazy(()=>Io(()=>import("./CreateSkillPage-CjeJOSY4.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage})));function cT(){const[t,r]=m.useState(()=>typeof window<"u"&&window.location.hash.startsWith("#/create"));return m.useEffect(()=>{function s(){r(window.location.hash.startsWith("#/create"))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),t}function uT(){return a.jsx(cS,{children:a.jsx(sS,{children:a.jsxs(VE,{children:[a.jsx(dT,{}),a.jsx(rN,{})]})})})}function dT(){var Qt,Gn;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=Zn(),{config:h}=_r(),{mode:g,resolvedTheme:p,setTheme:y}=Rv(),{toast:v}=qo(),[b,k]=m.useState(()=>Cw()),[S]=m.useState(!0),[w,C]=m.useState(!1),[T,N]=m.useState(!1),[M,H]=m.useState(!1),[L,F]=m.useState("overview"),[E,O]=m.useState(ev),R=m.useCallback((se,we)=>{O(rT(se,we))},[]),D=_N(),[I,q]=m.useState(()=>aT("activeAgent",null));m.useEffect(()=>{var se;!I&&((se=D.response)!=null&&se.suggested)&&q(D.response.suggested)},[I,(Qt=D.response)==null?void 0:Qt.suggested]);const X=m.useCallback(se=>{q(se),nT("activeAgent",se),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:se}}))},[]),Y=m.useMemo(()=>D.response?RN(D.response):[],[D.response]),{workspace:U,switchProject:z,addProject:B,removeProject:V,activeProject:W}=$N(),[de,_]=m.useState(!1),[P,ee]=m.useState(!1),[re,xe]=m.useState("standalone"),ce=m.useCallback((se="standalone")=>{xe(se),ee(!0)},[]);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ce((ze==null?void 0:ze.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",se),()=>window.removeEventListener("studio:request-create-skill",se)},[ce]);const[ye,ue]=m.useState(!1),[je,Re]=m.useState(null);m.useEffect(()=>{function se(){ue(!0)}return window.addEventListener("studio:open-marketplace",se),()=>window.removeEventListener("studio:open-marketplace",se)},[]);const Le=m.useMemo(()=>{const se=new Set;for(const we of t.skills)we.source==="plugin"&&we.pluginName&&se.add(we.pluginName);return se},[t.skills]);Jd([{key:"p",meta:!0,handler:se=>{var ze;const we=typeof document<"u"?document.activeElement:null;we&&we.tagName==="INPUT"||((ze=se==null?void 0:se.preventDefault)==null||ze.call(se),_(un=>!un))}}],{enabled:!0});const ae=bN(),fe=ae.open;m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.provider&&fe(ze.provider)}return window.addEventListener("studio:open-setup-drawer",se),()=>window.removeEventListener("studio:open-setup-drawer",se)},[fe]);const me=m.useCallback(()=>{O(ev)},[]);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.message&&v({message:ze.message,severity:ze.severity??"info"})}return window.addEventListener("studio:toast",se),()=>window.removeEventListener("studio:toast",se)},[v]),tT();const[he,be]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;Oe(ze==null?void 0:ze.provider),be(!0)}return window.addEventListener("studio:open-settings",se),()=>window.removeEventListener("studio:open-settings",se)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[st,At]=m.useState(null),[gt,Gt]=m.useState(()=>new Set),vt=m.useRef(!1),Ze=m.useMemo(()=>uN(),[]),at=m.useCallback(se=>`${se.plugin}/${se.skill}`,[]),ve=m.useCallback(se=>{Gt(we=>{const ze=new Set(we);return ze.add(at(se)),ze})},[at]),ct=m.useCallback(se=>{Gt(we=>{const ze=new Set(we);return ze.delete(at(se)),ze})},[at]),Nt=dN({delayMs:1e4,onCommit:se=>{o(),ct(se)},onFailure:(se,we)=>{ct(se),v({message:`Couldn't delete ${se.skill}: ${we.message}`,severity:"error",durationMs:0,action:{label:te.actions.retry,onInvoke:()=>{ve(se),Nt.enqueueDelete(se)}}})}});m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.skill&&At(ze.skill)}return window.addEventListener("studio:request-delete",se),()=>window.removeEventListener("studio:request-delete",se)},[]);const nn=m.useCallback(()=>{const se=st;if(At(null),!se)return;const we={plugin:se.plugin,skill:se.skill};ve(we),Nt.enqueueDelete(we);const ze=vt.current?"":`Sent to your ${Ze}. Open Trash to restore. `;vt.current=!0,v({message:`${ze}Deleted ${se.skill}`,severity:"info",durationMs:1e4,action:{label:te.actions.undo,onInvoke:()=>{Nt.cancelDelete(at(we)),ct(we)}}})},[st,ve,ct,Nt,v,Ze,at]),Rn=m.useCallback(()=>{At(null)},[]),Vt=m.useMemo(()=>t.skills.filter(se=>!gt.has(at(se))),[t.skills,gt,at]),oa=m.useMemo(()=>t.selectedSkill?t.skills.find(se=>se.plugin===t.selectedSkill.plugin&&se.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),$e=m.useCallback(se=>{r({plugin:se.plugin,skill:se.skill,origin:se.origin})},[r]),Je=m.useMemo(()=>{if(!t.selectedSkill)return"";const se=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${se})`},[t.selectedSkill]),yt=m.useMemo(()=>[{id:"switch-theme",label:te.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>H(se=>!se)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>N(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);Jd([{key:"cmd+k",handler:()=>C(se=>!se)},{key:"ctrl+k",handler:()=>C(se=>!se)},{key:"?",handler:()=>N(se=>!se)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>H(se=>!se)},{key:"ctrl+b",handler:()=>H(se=>!se)},{key:"e",handler:()=>v({message:te.actions.editPlaceholder,severity:"info"})}]);const Fn=cT()?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(oT,{})}):a.jsx(XE,{selectedSkillInfo:oa,activeDetailTab:L,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:$e});return a.jsxs(a.Fragment,{children:[a.jsx(uS,{sidebarWidth:b,sidebarHidden:M||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Tw,{connected:S}),liveMessage:Je,topRail:a.jsx(o2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ce("standalone"),projectPickerSlot:U&&U.projects.length>0?a.jsx(VN,{workspace:U,onSwitch:z,onAdd:B,onRemove:V}):void 0}),sidebar:a.jsx(gw,{skills:Vt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:$e,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:R,outdatedByOrigin:c,activeAgentId:I,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:D.status==="ready"&&Y.length>0?a.jsxs(a.Fragment,{children:[a.jsx(AN,{agents:Y,activeAgentId:I,onActiveAgentChange:X,onOpenSetup:se=>ae.open(se)}),a.jsx(DN,{activeAgentId:I})]}):null}),resizeHandle:a.jsx(Nw,{initialWidth:b??_s,onChange:k}),main:Fn,statusBar:a.jsx(y2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Gn=h==null?void 0:h.providers)==null?void 0:Gn.map(se=>{const we=se.id;return{id:we,label:se.label,available:se.available,kind:we==="ollama"||we==="lm-studio"?"start-service":we==="anthropic"||we==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(sN,{open:T,onClose:()=>N(!1)}),a.jsx(mN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),a.jsx(oN,{state:E,onClose:me,onAction:(se,we)=>sT(se,we)}),w&&a.jsx(m.Suspense,{fallback:null,children:a.jsx(iT,{open:w,onClose:()=>C(!1),commands:yt})}),a.jsx(FN,{open:de,projects:(U==null?void 0:U.projects)??[],onSwitch:se=>{z(se)},onClose:()=>_(!1)}),a.jsx(GN,{open:P,onClose:()=>ee(!1),initialMode:re,isClaudeCode:I==="claude-code",projectRoot:(W==null?void 0:W.path)??(h==null?void 0:h.projectName)??"",onCreated:se=>{o(),setTimeout(()=>{u(se.pluginName??"",se.skillName)},500)}}),a.jsx(qN,{open:ye,onClose:()=>ue(!1),installedNames:Le,onInstall:(se,we)=>{Re({plugin:se,marketplace:we,ref:`${se}@${we}`}),ue(!1)}}),a.jsx(Ev,{open:he,onClose:()=>be(!1),initialProvider:Be,onToast:se=>v({message:se,severity:"info"})}),a.jsx(QN,{job:je,onDone:se=>{se.ok&&setTimeout(()=>Re(null),3e3)}}),a.jsx(cN,{open:st!==null,title:st?`Delete "${st.skill}"?`:"",body:`It will be sent to your ${Ze}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:nn,onCancel:Rn})]})}const tv="vskill.migrations.scope-rename.v1",fT={own:"authoring-project",installed:"available-project",global:"available-personal"},pT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function mT(t){if(t.getItem(tv)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(pT);if(!c)continue;const[,u,d]=c,h=fT[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(tv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{mT(window.localStorage)}catch{}s0.createRoot(document.getElementById("root")).render(a.jsx(m.StrictMode,{children:a.jsx(Nj,{children:a.jsx(m2,{children:a.jsx(uT,{})})})}));export{Wo as E,bv as L,Xs as P,Ne as R,xE as S,_r as a,Uy as b,pE as c,Fo as d,aT as g,a as j,m as r,te as s,lf as t,V0 as u,nT as w};
102
+ `)})]})}function ZN(){return a.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:a.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const JN=3e3,eT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function Jg(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function tT(){const{toast:t}=qo(),r=m.useRef(new Map),s=m.useCallback(o=>{if(!Jg(o.provider))return;const c=Date.now(),u=r.current.get(o.provider)??0;if(c-u<JN)return;r.current.set(o.provider,c);const d=eT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return m.useEffect(()=>{function o(c){const u=c.detail;!u||!Jg(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const Iy="vskill.studio.prefs";function Hy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Uy(){const t=Hy();if(!t)return{};try{const r=t.getItem(Iy);if(!r)return{};const s=JSON.parse(r);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function nT(t,r){const s=Hy();if(s)try{const c={...Uy(),[t]:r};s.setItem(Iy,JSON.stringify(c))}catch{}}function aT(t,r){const o=Uy()[t];return o===void 0?r:o}const ev={open:!1,x:0,y:0,skill:null};function rT(t,r){return{open:!0,x:t.clientX,y:t.clientY,skill:r}}function Ar(t,r="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:r}}))}function lT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function sT(t,r){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(r.dir)}catch{Ar(te.toasts.permissionDenied,"error");return}Ar(te.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ar(te.actions.editPlaceholder,"info");return;case"run-benchmark":Ar(te.toasts.benchmarkQueued,"info");return;case"duplicate":Ar(te.toasts.skillDuplicated,"info");return;case"update":Ar(te.toasts.skillUpdated,"info");return;case"uninstall":Ar(te.actions.editPlaceholder,"info");return;case"delete":lT(r);return;default:return}}const iT=m.lazy(()=>Io(()=>import("./CommandPalette-3xE9OCOe.js"),__vite__mapDeps([2,1]))),oT=m.lazy(()=>Io(()=>import("./CreateSkillPage-BEdLsGoc.js"),__vite__mapDeps([3,1])).then(t=>({default:t.CreateSkillPage})));function cT(){const[t,r]=m.useState(()=>typeof window<"u"&&window.location.hash.startsWith("#/create"));return m.useEffect(()=>{function s(){r(window.location.hash.startsWith("#/create"))}return window.addEventListener("hashchange",s),s(),()=>window.removeEventListener("hashchange",s)},[]),t}function uT(){return a.jsx(cS,{children:a.jsx(sS,{children:a.jsxs(VE,{children:[a.jsx(dT,{}),a.jsx(rN,{})]})})})}function dT(){var Qt,Gn;const{state:t,selectSkill:r,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=Zn(),{config:h}=_r(),{mode:g,resolvedTheme:p,setTheme:y}=Rv(),{toast:v}=qo(),[b,k]=m.useState(()=>Cw()),[S]=m.useState(!0),[w,C]=m.useState(!1),[T,N]=m.useState(!1),[M,H]=m.useState(!1),[L,F]=m.useState("overview"),[E,O]=m.useState(ev),R=m.useCallback((se,we)=>{O(rT(se,we))},[]),D=_N(),[I,q]=m.useState(()=>aT("activeAgent",null));m.useEffect(()=>{var se;!I&&((se=D.response)!=null&&se.suggested)&&q(D.response.suggested)},[I,(Qt=D.response)==null?void 0:Qt.suggested]);const X=m.useCallback(se=>{q(se),nT("activeAgent",se),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:se}}))},[]),Y=m.useMemo(()=>D.response?RN(D.response):[],[D.response]),{workspace:U,switchProject:z,addProject:B,removeProject:V,activeProject:W}=$N(),[de,_]=m.useState(!1),[P,ee]=m.useState(!1),[re,xe]=m.useState("standalone"),ce=m.useCallback((se="standalone")=>{xe(se),ee(!0)},[]);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ce((ze==null?void 0:ze.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",se),()=>window.removeEventListener("studio:request-create-skill",se)},[ce]);const[ye,ue]=m.useState(!1),[je,Re]=m.useState(null);m.useEffect(()=>{function se(){ue(!0)}return window.addEventListener("studio:open-marketplace",se),()=>window.removeEventListener("studio:open-marketplace",se)},[]);const Le=m.useMemo(()=>{const se=new Set;for(const we of t.skills)we.source==="plugin"&&we.pluginName&&se.add(we.pluginName);return se},[t.skills]);Jd([{key:"p",meta:!0,handler:se=>{var ze;const we=typeof document<"u"?document.activeElement:null;we&&we.tagName==="INPUT"||((ze=se==null?void 0:se.preventDefault)==null||ze.call(se),_(un=>!un))}}],{enabled:!0});const ae=bN(),fe=ae.open;m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.provider&&fe(ze.provider)}return window.addEventListener("studio:open-setup-drawer",se),()=>window.removeEventListener("studio:open-setup-drawer",se)},[fe]);const me=m.useCallback(()=>{O(ev)},[]);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.message&&v({message:ze.message,severity:ze.severity??"info"})}return window.addEventListener("studio:toast",se),()=>window.removeEventListener("studio:toast",se)},[v]),tT();const[he,be]=m.useState(!1),[Be,Oe]=m.useState(void 0);m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;Oe(ze==null?void 0:ze.provider),be(!0)}return window.addEventListener("studio:open-settings",se),()=>window.removeEventListener("studio:open-settings",se)},[]),m.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[st,At]=m.useState(null),[gt,Gt]=m.useState(()=>new Set),vt=m.useRef(!1),Ze=m.useMemo(()=>uN(),[]),at=m.useCallback(se=>`${se.plugin}/${se.skill}`,[]),ve=m.useCallback(se=>{Gt(we=>{const ze=new Set(we);return ze.add(at(se)),ze})},[at]),ct=m.useCallback(se=>{Gt(we=>{const ze=new Set(we);return ze.delete(at(se)),ze})},[at]),Nt=dN({delayMs:1e4,onCommit:se=>{o(),ct(se)},onFailure:(se,we)=>{ct(se),v({message:`Couldn't delete ${se.skill}: ${we.message}`,severity:"error",durationMs:0,action:{label:te.actions.retry,onInvoke:()=>{ve(se),Nt.enqueueDelete(se)}}})}});m.useEffect(()=>{function se(we){if(!(we instanceof CustomEvent))return;const ze=we.detail;ze!=null&&ze.skill&&At(ze.skill)}return window.addEventListener("studio:request-delete",se),()=>window.removeEventListener("studio:request-delete",se)},[]);const nn=m.useCallback(()=>{const se=st;if(At(null),!se)return;const we={plugin:se.plugin,skill:se.skill};ve(we),Nt.enqueueDelete(we);const ze=vt.current?"":`Sent to your ${Ze}. Open Trash to restore. `;vt.current=!0,v({message:`${ze}Deleted ${se.skill}`,severity:"info",durationMs:1e4,action:{label:te.actions.undo,onInvoke:()=>{Nt.cancelDelete(at(we)),ct(we)}}})},[st,ve,ct,Nt,v,Ze,at]),Rn=m.useCallback(()=>{At(null)},[]),Vt=m.useMemo(()=>t.skills.filter(se=>!gt.has(at(se))),[t.skills,gt,at]),oa=m.useMemo(()=>t.selectedSkill?t.skills.find(se=>se.plugin===t.selectedSkill.plugin&&se.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),$e=m.useCallback(se=>{r({plugin:se.plugin,skill:se.skill,origin:se.origin})},[r]),Je=m.useMemo(()=>{if(!t.selectedSkill)return"";const se=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${se})`},[t.selectedSkill]),yt=m.useMemo(()=>[{id:"switch-theme",label:te.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>H(se=>!se)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>N(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]);Jd([{key:"cmd+k",handler:()=>C(se=>!se)},{key:"ctrl+k",handler:()=>C(se=>!se)},{key:"?",handler:()=>N(se=>!se)},{key:"cmd+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(p==="light"?"dark":"light")},{key:"cmd+b",handler:()=>H(se=>!se)},{key:"ctrl+b",handler:()=>H(se=>!se)},{key:"e",handler:()=>v({message:te.actions.editPlaceholder,severity:"info"})}]);const Fn=cT()?a.jsx(m.Suspense,{fallback:a.jsx("div",{style:{padding:40},children:"Loading…"}),children:a.jsx(oT,{})}):a.jsx(XE,{selectedSkillInfo:oa,activeDetailTab:L,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:$e});return a.jsxs(a.Fragment,{children:[a.jsx(uS,{sidebarWidth:b,sidebarHidden:M||t.isMobile&&t.mobileView==="detail",banner:a.jsx(Tw,{connected:S}),liveMessage:Je,topRail:a.jsx(o2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>ce("standalone"),projectPickerSlot:U&&U.projects.length>0?a.jsx(VN,{workspace:U,onSwitch:z,onAdd:B,onRemove:V}):void 0}),sidebar:a.jsx(gw,{skills:Vt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:$e,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:R,outdatedByOrigin:c,activeAgentId:I,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:D.status==="ready"&&Y.length>0?a.jsxs(a.Fragment,{children:[a.jsx(AN,{agents:Y,activeAgentId:I,onActiveAgentChange:X,onOpenSetup:se=>ae.open(se)}),a.jsx(DN,{activeAgentId:I})]}):null}),resizeHandle:a.jsx(Nw,{initialWidth:b??_s,onChange:k}),main:Fn,statusBar:a.jsx(y2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Gn=h==null?void 0:h.providers)==null?void 0:Gn.map(se=>{const we=se.id;return{id:we,label:se.label,available:se.available,kind:we==="ollama"||we==="lm-studio"?"start-service":we==="anthropic"||we==="openrouter"?"api-key":"cli-install"}})})}),a.jsx(sN,{open:T,onClose:()=>N(!1)}),a.jsx(mN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),a.jsx(oN,{state:E,onClose:me,onAction:(se,we)=>sT(se,we)}),w&&a.jsx(m.Suspense,{fallback:null,children:a.jsx(iT,{open:w,onClose:()=>C(!1),commands:yt})}),a.jsx(FN,{open:de,projects:(U==null?void 0:U.projects)??[],onSwitch:se=>{z(se)},onClose:()=>_(!1)}),a.jsx(GN,{open:P,onClose:()=>ee(!1),initialMode:re,isClaudeCode:I==="claude-code",projectRoot:(W==null?void 0:W.path)??(h==null?void 0:h.projectName)??"",onCreated:se=>{o(),setTimeout(()=>{u(se.pluginName??"",se.skillName)},500)}}),a.jsx(qN,{open:ye,onClose:()=>ue(!1),installedNames:Le,onInstall:(se,we)=>{Re({plugin:se,marketplace:we,ref:`${se}@${we}`}),ue(!1)}}),a.jsx(Ev,{open:he,onClose:()=>be(!1),initialProvider:Be,onToast:se=>v({message:se,severity:"info"})}),a.jsx(QN,{job:je,onDone:se=>{se.ok&&setTimeout(()=>Re(null),3e3)}}),a.jsx(cN,{open:st!==null,title:st?`Delete "${st.skill}"?`:"",body:`It will be sent to your ${Ze}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:nn,onCancel:Rn})]})}const tv="vskill.migrations.scope-rename.v1",fT={own:"authoring-project",installed:"available-project",global:"available-personal"},pT=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function mT(t){if(t.getItem(tv)==="done")return;const r=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match(pT);if(!c)continue;const[,u,d]=c,h=fT[d];if(!h)continue;const g=t.getItem(o);g!==null&&r.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of r)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(tv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(r=>{for(const s of r.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{mT(window.localStorage)}catch{}s0.createRoot(document.getElementById("root")).render(a.jsx(m.StrictMode,{children:a.jsx(Nj,{children:a.jsx(m2,{children:a.jsx(uT,{})})})}));export{Wo as E,bv as L,Xs as P,Ne as R,xE as S,_r as a,Uy as b,pE as c,Fo as d,aT as g,a as j,m as r,te as s,lf as t,V0 as u,nT as w};