@tickernelz/paperclip-pro-ui 2026.1011.0 → 2026.1011.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-Dp_Bz_iN.js → AgentAvatar-BlBIRCn-.js} +1 -1
- package/dist/assets/{AgentIdentity-Cm7Ujbf8.js → AgentIdentity-DGZ1IWcm.js} +1 -1
- package/dist/assets/{Agents.production-BnelNlT5.js → Agents.production-BLkE-0NE.js} +2 -2
- package/dist/assets/CompanyActivity.production-CTian23Q.js +1 -0
- package/dist/assets/{CompanyExport-DRIJiXEe.js → CompanyExport-C2LARvhE.js} +3 -3
- package/dist/assets/{CompanySkills.production-c52i25KS.js → CompanySkills.production-o0Fyauh-.js} +3 -3
- package/dist/assets/{Costs.production-Bde_oJtZ.js → Costs.production-BC1KZiFm.js} +1 -1
- package/dist/assets/{EmptyState-BvEr-i9V.js → EmptyState-B3GzFGA2.js} +1 -1
- package/dist/assets/{MarkdownBody-Bd9hxCfT.js → MarkdownBody-Czv0XlBT.js} +5 -5
- package/dist/assets/{MarkdownEditor-DXsEO6HV.js → MarkdownEditor-Cli5vQ9A.js} +2 -2
- package/dist/assets/{OrgChart.production-BX6M_6k3.js → OrgChart.production-32WvU7ZC.js} +1 -1
- package/dist/assets/{PageSkeleton-CMyiRvA3.js → PageSkeleton-DjZAlHdx.js} +1 -1
- package/dist/assets/{RoutineDetail.production-7iRbsdFp.js → RoutineDetail.production-DixgPerZ.js} +1 -1
- package/dist/assets/{RoutineRunVariablesDialog-CqSSDBNj.js → RoutineRunVariablesDialog-CX_crJ2M.js} +2 -2
- package/dist/assets/{Routines.production-Cs68g7nD.js → Routines.production-DqVaTpH6.js} +1 -1
- package/dist/assets/{SidebarContext-B0gN2yk0.js → SidebarContext-BafyN2te.js} +1 -1
- package/dist/assets/{StatusIcon-Cr_DvVs3.js → StatusIcon-DAfZZt5s.js} +1 -1
- package/dist/assets/{agent-avatar-url-DEapdgX0.js → agent-avatar-url-CrFre_o0.js} +10 -10
- package/dist/assets/{agents-jWr30SW1.js → agents-CXRgDTPe.js} +1 -1
- package/dist/assets/{badge-0lGEKGdq.js → badge-DgXn7-fn.js} +1 -1
- package/dist/assets/{bot-CB_07Yl8.js → bot-XZ1yN3-I.js} +1 -1
- package/dist/assets/{boxes-DTW7vs8-.js → boxes-D23QBcG5.js} +2 -2
- package/dist/assets/{button-CGzOHorw.js → button-qNr9PNnV.js} +1 -1
- package/dist/assets/{card-BZJFFCT6.js → card-C7YSXtUE.js} +1 -1
- package/dist/assets/{check-Dx-gtI1E.js → check-QbJMKH4B.js} +1 -1
- package/dist/assets/{checkbox-DvxFR--v.js → checkbox-DgUtspFU.js} +1 -1
- package/dist/assets/{chevron-down-EwSb0M2p.js → chevron-down-WiCDFzOc.js} +1 -1
- package/dist/assets/{chevron-right-CK-MTGab.js → chevron-right-CrTYgpoD.js} +1 -1
- package/dist/assets/{clipboard-D7Po3iHX.js → clipboard-CCSd74n9.js} +1 -1
- package/dist/assets/{company-members-D19iQoSi.js → company-members-DQZcrryX.js} +1 -1
- package/dist/assets/{definition-CZHmW18n.js → definition-6w9rBPo4.js} +1 -1
- package/dist/assets/{dist-D4m6GMlG.js → dist-CxnAC5ut.js} +1 -1
- package/dist/assets/{dist-DFelLOra.js → dist-DwdZYoi9.js} +1 -1
- package/dist/assets/{environments-CBw_34UZ.js → environments-BMUrSRs5.js} +1 -1
- package/dist/assets/{external-link-ClLhvZg8.js → external-link-CXBsDJFH.js} +1 -1
- package/dist/assets/{file-text-DFAhf3Yt.js → file-text-enWNyTOr.js} +1 -1
- package/dist/assets/health-DBBZn_mP.js +1 -0
- package/dist/assets/{heartbeats-BloBN5DU.js → heartbeats-C7hzaXUK.js} +1 -1
- package/dist/assets/index-Bf6jMBkl.css +1 -0
- package/dist/assets/{index-du-gijCO.js → index-DRvRAzwu.js} +179 -178
- package/dist/assets/{input-BHz3zHCk.js → input-CaBijGbz.js} +1 -1
- package/dist/assets/{label-KM16bZPN.js → label-BOZRq-vu.js} +2 -2
- package/dist/assets/{loader-circle-C85VO-_N.js → loader-circle-BvNlkozx.js} +1 -1
- package/dist/assets/{mention-chips-C9nmTfZg.js → mention-chips-DymVknlf.js} +1 -1
- package/dist/assets/{octagon-alert-DBi8Q0dq.js → octagon-alert-BDrG2ej6.js} +1 -1
- package/dist/assets/{rotate-ccw-DW5P87E8.js → rotate-ccw-Bm2GI2Za.js} +1 -1
- package/dist/assets/{router-DE8lO3Qs.js → router-DsEp3y3a.js} +2 -2
- package/dist/assets/{save-DOeGUiMf.js → save-hiSIvhFZ.js} +1 -1
- package/dist/assets/{select-DnXFgZEc.js → select-BGs-t22m.js} +1 -1
- package/dist/assets/{sheet-Bv7Wb_q8.js → sheet-o78ZsqWt.js} +1 -1
- package/dist/assets/{skeleton-BVstbaRJ.js → skeleton-wNNcfiP_.js} +1 -1
- package/dist/assets/{tabs-Da--SIl7.js → tabs-CcJa_lIi.js} +1 -1
- package/dist/assets/{triangle-alert-mwG72aw8.js → triangle-alert-CvrMHubr.js} +1 -1
- package/dist/assets/{use-adapter-capabilities-b_EYr-Px.js → use-adapter-capabilities-Dgs0vc7z.js} +1 -1
- package/dist/assets/{useHiddenSettings-DLhdM44E.js → useHiddenSettings-BjfNzv3C.js} +1 -1
- package/dist/index.html +46 -46
- package/dist/sw.js +1 -1
- package/package.json +1 -1
- package/dist/assets/CompanyActivity.production-CuirQ3KC.js +0 -1
- package/dist/assets/health-DvN50_K4.js +0 -1
- package/dist/assets/index-B_sGrEo-.css +0 -1
package/dist/assets/{CompanySkills.production-c52i25KS.js → CompanySkills.production-o0Fyauh-.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var gr=Object.defineProperty;var n=(t,l)=>gr(t,"name",{value:l,configurable:!0});import{i as yn}from"./rolldown-runtime-ZpX3ckPj.js";import{B as fr,Bi as br,
|
|
1
|
+
var gr=Object.defineProperty;var n=(t,l)=>gr(t,"name",{value:l,configurable:!0});import{i as yn}from"./rolldown-runtime-ZpX3ckPj.js";import{B as fr,Bi as br,Hi as jr,S as K,W as vr,Z as f,ai as Y,oi as xe,zi as yr}from"./agent-avatar-url-CrFre_o0.js";import{Ht as kr,L as Nr,M as wr,Ut as Sr,o as Cr,t as pe,w as kn}from"./router-DsEp3y3a.js";import{Z as Fr}from"./mention-chips-DymVknlf.js";import{t as ge}from"./boxes-D23QBcG5.js";import{c as _,f as Ir,t as Dr}from"./MarkdownEditor-Cli5vQ9A.js";import{b as Lr,v as Ws,y as Nn}from"./sheet-o78ZsqWt.js";import{t as rn}from"./AgentAvatar-BlBIRCn-.js";import{A as Br,C as Pr,O as Bs,S as Ls,a as bs,c as js,f as Re,g as Ps,h as $e,j as Er,k as Tr,n as jt,o as As,p as ze,r as vs,s as vt,t as Ar,u as ys,v as Es,x as xt,y as Ze}from"./checkbox-DgUtspFU.js";import{i as Ts,r as wn,t as Sn}from"./tabs-CcJa_lIi.js";import{i as Mr,s as Ft,t as Hs}from"./agents-CXRgDTPe.js";import{m as It}from"./StatusIcon-DAfZZt5s.js";import{t as Kr}from"./use-adapter-capabilities-Dgs0vc7z.js";import{r as qr,t as es}from"./EmptyState-B3GzFGA2.js";import{t as Cn}from"./check-QbJMKH4B.js";import{t as gs}from"./chevron-down-WiCDFzOc.js";import{t as Fn}from"./chevron-right-CrTYgpoD.js";import{n as Rr,t as ht}from"./save-hiSIvhFZ.js";import{k as yt,t as y}from"./button-qNr9PNnV.js";import{i as In,r as Dt}from"./clipboard-CCSd74n9.js";import{t as fs}from"./external-link-CXBsDJFH.js";import{t as kt,w as $r}from"./MarkdownBody-Czv0XlBT.js";import{t as Lt}from"./file-text-enWNyTOr.js";import{t as Dn}from"./triangle-alert-CvrMHubr.js";import{t as le}from"./badge-DgXn7-fn.js";import{t as qe}from"./input-CaBijGbz.js";import"./AgentIdentity-DGZ1IWcm.js";import{t as Be}from"./PageSkeleton-DjZAlHdx.js";import{$ as zr,$t as Ln,At as pt,Bt as _r,Dn as Or,En as Nt,Fn as Bn,Ft as Pn,Hn as an,Ht as Ur,In as wt,It as En,Jt as Vr,Mn as Qr,Mt as Gs,Nn as ks,Nt as gt,On as Hr,Ot as Bt,Pn as Tn,Pt as Gr,Q as Wr,Sn as An,Vn as St,X as Yr,Z as Xr,_ as Zr,_t as he,at as Jr,bn as ea,c as sa,ct as ta,d as na,dt as ra,et as aa,f as Ms,ft as Mn,g as la,gn as ia,h as oa,it as da,jn as ca,jt as ua,kt as ma,l as xa,lt as ha,m as Kn,mn as pa,mt as Je,nt as ga,o as fa,ot as ba,p as ft,pt as ln,rt as ja,s as va,u as ya,ut as ka,v as Na,vn as wa,wn as Sa,y as Ca,zn as Fa}from"./index-DRvRAzwu.js";var c=yn(jr(),1),e=yn(br(),1),on=16,dn=24,cn="min-h-9";function un(t){return(0,e.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...t,children:(0,e.jsx)("path",{d:"M12 4 21 19H3z"})})}n(un,"VercelMark");function qn(t){const l=t.replace(/\r\n/g,`
|
|
2
2
|
`);if(!l.startsWith(`---
|
|
3
3
|
`))return l.trim();const a=l.indexOf(`
|
|
4
4
|
---
|
|
5
|
-
`,4);return a<0?l.trim():l.slice(a+5).trim()}n(
|
|
5
|
+
`,4);return a<0?l.trim():l.slice(a+5).trim()}n(qn,"stripFrontmatter");function Ct(t){const l=t.replace(/\r\n/g,`
|
|
6
6
|
`);if(!l.startsWith(`---
|
|
7
7
|
`))return{frontmatter:null,body:l};const a=l.indexOf(`
|
|
8
8
|
---
|
|
9
9
|
`,4);return a<0?{frontmatter:null,body:l}:{frontmatter:l.slice(4,a).trim(),body:l.slice(a+5).trimStart()}}n(Ct,"splitFrontmatter");function Ia(t,l){const a=Ct(t);return a.frontmatter?["---",a.frontmatter,"---","",l].join(`
|
|
10
|
-
`):l}n(Ia,"mergeFrontmatter");function qn(t){const l={name:"",path:null,kind:"dir",children:[]};for(const u of t){const m=u.path.split("/").filter(Boolean);let r=l,g="";for(const[o,x]of m.entries()){g=g?`${g}/${x}`:x;const N=o===m.length-1;let v=r.children.find(I=>I.name===x);v||(v={name:x,path:N?u.path:g,kind:N?"file":"dir",fileKind:N?u.kind:void 0,children:[]},r.children.push(v)),r=v}}function a(u){u.children.sort((m,r)=>m.kind!==r.kind?m.kind==="dir"?-1:1:m.name==="SKILL.md"?-1:r.name==="SKILL.md"?1:m.name.localeCompare(r.name)),u.children.forEach(a)}return n(a,"sortNode"),a(l),l.children}n(qn,"buildTree");function Ys(t,l){const a=l?.toLowerCase()??"",u=a.includes("skills.sh")||a.includes("vercel-labs/skills");switch(t){case"skills_sh":return{icon:un,label:l??"skills.sh",managedLabel:"skills.sh managed"};case"github":return u?{icon:un,label:l??"skills.sh",managedLabel:"skills.sh managed"}:{icon:It,label:l??"GitHub",managedLabel:"GitHub managed"};case"url":return{icon:ma,label:l??"URL",managedLabel:"URL managed"};case"local":return{icon:Ft,label:l??"Folder",managedLabel:"Folder managed"};case"paperclip":return{icon:Or,label:l??"Paperclip",managedLabel:"Paperclip managed"};default:return{icon:ge,label:l??"Catalog",managedLabel:"Catalog managed"}}}n(Ys,"sourceMeta");function Xs(t){return t?t.slice(0,7):null}n(Xs,"shortRef");function Da(t){const l=[`${t.discovered} found`,`${t.imported.length} imported`,`${t.updated.length} updated`];return t.conflicts.length>0&&l.push(`${t.conflicts.length} conflicts`),t.skipped.length>0&&l.push(`${t.skipped.length} skipped`),`${l.join(", ")} across ${t.scannedWorkspaces} workspace${t.scannedWorkspaces===1?"":"s"}.`}n(Da,"formatProjectScanSummary");function La(t){return t==="script"||t==="reference"?$r:Lt}n(La,"fileIcon");function mn(t){const l=t.split("/").filter(Boolean),a=[];for(let u=0;u<l.length-1;u+=1)a.push(l.slice(0,u+1).join("/"));return a}n(mn,"parentDirectoryPaths");function xn(t,l){if(!t||typeof t!="object")return null;const a=t[l];if(typeof a!="string")return null;const u=a.trim();return u.length>0?u:null}n(xn,"readonlyMetadataValue");function Ba(t){const l=xn(t,"sourceKind")??xn(t,"catalogKind");return l==="bundled"?"bundled":l==="optional"?"optional":null}n(Ba,"readonlyMetadataKind");function Pa(t){if(t.sourceBadge==="paperclip"||t.sourceType==="local_path"&&!t.sourceBadge.toString().includes("github"))return"company";if(t.sourceType==="catalog"||t.sourceBadge==="catalog"){const l=t.catalogKind??Ba(t.metadata);return l==="bundled"?"bundled":l==="optional"?"optional":"company"}return t.sourceBadge==="github"||t.sourceBadge==="skills_sh"||t.sourceBadge==="url"||t.sourceBadge==="local"?"external":"company"}n(Pa,"classifySource");function $n({level:t}){const l={markdown_only:{icon:wa,label:"Markdown only",tooltip:"Text only — no scripts, no binaries, no assets.",className:"border-border bg-muted/40 text-muted-foreground"},assets:{icon:Ft,label:"Includes assets",tooltip:"Ships images, fonts, or other non-script files.",className:"border-cyan-500/30 bg-cyan-500/10 text-cyan-800 dark:text-cyan-200"},scripts_executables:{icon:Dn,label:"Includes scripts",tooltip:"Ships executable scripts. Review before installing.",className:"border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200"}},a=l[t]??l.markdown_only,u=a.icon;return(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:K("text-(length:--text-micro)",a.className),children:[(0,e.jsx)(u,{className:"h-3 w-3","aria-hidden":"true"}),a.label]})}),(0,e.jsx)(ze,{children:a.tooltip})]})}n($n,"TrustChip");function zn({compatibility:t}){if(t==="compatible")return null;const l={unknown:{icon:qr,label:"Unknown format",tooltip:"Paperclip could not validate this skill as Agent Skills markdown. Install at your own risk.",className:"border-yellow-500/40 bg-yellow-500/10 text-yellow-800 dark:text-yellow-200"},invalid:{icon:Wr,label:"Invalid",tooltip:"This skill cannot be installed — content is not valid Agent Skills markdown.",className:"border-destructive/40 bg-destructive/10 text-destructive"}}[t],a=l.icon;return(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:K("text-(length:--text-micro)",l.className),children:[(0,e.jsx)(a,{className:"h-3 w-3","aria-hidden":"true"}),l.label]})}),(0,e.jsx)(ze,{children:l.tooltip})]})}n(zn,"CompatChip");function Ea({packageName:t,packageVersion:l}){return t?(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted/30 px-1.5 py-0.5 font-mono text-(length:--text-nano) text-muted-foreground",children:[(0,e.jsx)(ge,{className:"h-3 w-3","aria-hidden":"true"}),(0,e.jsxs)("span",{children:[t,l?` v${l}`:""]})]})}),(0,e.jsx)(ze,{children:"Installed from the app-shipped skills catalog. Provenance is signed by package version and content hash."})]}):null}n(Ea,"ProvenanceBadge");function Ta(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}n(Ta,"formatBytes");var Aa=["all","installed","catalog","bundled"];function Ma(t){return Aa.includes(t)?t:"installed"}n(Ma,"resolveDiscoveryTab");function Ka(t,l){const a=new URLSearchParams(t);return l==="installed"?a.delete("tab"):a.set("tab",l),a.delete("category"),l!=="installed"&&a.delete("folder"),a}n(Ka,"withDiscoveryTab");function Ra(t,l){return[{label:"Skills",href:"/skills"},...(t.folderId?ra(Je(l),t.folderId):[]).map((a,u)=>({label:u===0?ka(a):a.name,href:`/skills?folder=${encodeURIComponent(a.id)}`})),{label:t.name}]}n(Ra,"skillDetailBreadcrumbs");var hn={agents:"Most agents",stars:"Most stars",forks:"Most forks",recent:"Recently updated",alphabetical:"Alphabetical"},qa=["agents","stars","forks","recent","alphabetical"];function pn(t,l){return t.packageVersion?`v${t.packageVersion}`:l?"core":t.sourceRef?Xs(t.sourceRef):null}n(pn,"discoveryVersionLabel");function gn(t){const l=[],a=new Set;for(const u of t){const m=u?.trim();!m||a.has(m)||(a.add(m),l.push(m))}return l}n(gn,"uniqueCategories");function fn(t){return[...t].sort().join(",")}n(fn,"categorySetKey");function $a(t){return`${t.sharingScope==="private"?"Sharing: private":"Sharing: company"} | ${t.categories.length?`Categories: ${t.categories.join(", ")}`:"Categories: none"}`}n($a,"skillSettingsToastBody");function za(t,l){const a=new Map(l.map(r=>[r.key,r])),u=[],m=new Set;for(const r of t){m.add(r.key);const g=a.get(r.key)??null,o=r.catalogKind==="bundled"||g?.kind==="bundled";u.push({key:r.key,skillId:r.id,folderId:r.folderId??null,catalogRef:g?g.id:null,name:r.name,slug:r.slug,author:r.authorName??r.sourceLabel??"you",version:pn(r,o),tagline:r.tagline??null,description:r.description??null,categories:gn([...r.categories??[],g?.category]),iconUrl:r.iconUrl,color:r.color,starCount:r.starCount??0,agentCount:r.attachedAgentCount??0,forkCount:r.forkCount??0,installed:!0,required:o,forkedFrom:!!r.forkedFromSkillId,updatedAt:new Date(r.updatedAt).getTime()||0,sourceBadge:r.sourceBadge,sourceLabel:r.sourceLabel})}for(const r of l){if(m.has(r.key))continue;const g=r.kind==="bundled";u.push({key:r.key,skillId:null,folderId:null,catalogRef:r.id,name:r.name,slug:r.slug,author:r.packageName??"Paperclip",version:pn({packageVersion:r.packageVersion??null,sourceRef:null},g),tagline:null,description:r.description,categories:gn([r.category,...r.tags??[]]),iconUrl:null,color:null,starCount:0,agentCount:0,forkCount:0,installed:!1,required:g,forkedFrom:!1,updatedAt:0,sourceBadge:"catalog",sourceLabel:r.packageName??"Catalog"})}return u}n(za,"buildDiscoveryCards");function _a(t,l){switch(l){case"installed":return t.filter(a=>a.installed);case"catalog":return t.filter(a=>a.catalogRef!=null);case"bundled":return t.filter(a=>a.required);default:return t}}n(_a,"cardsForTab");function Oa(t,l,a){const u=n((m,r)=>m.name.localeCompare(r.name),"byName");return[...t].sort((m,r)=>{if(a&&m.required!==r.required)return m.required?1:-1;switch(l){case"stars":return r.starCount-m.starCount||u(m,r);case"forks":return r.forkCount-m.forkCount||u(m,r);case"recent":return r.updatedAt-m.updatedAt||u(m,r);case"alphabetical":return u(m,r);default:return r.agentCount-m.agentCount||u(m,r)}})}n(Oa,"sortDiscoveryCards");function bn(t,l){return l?[t.name,t.slug,t.author,t.tagline??"",t.description??"",t.categories.join(" ")].join(" ").toLowerCase().includes(l.toLowerCase()):!0}n(bn,"discoveryMatchesSearch");function jn({icon:t,value:l}){return(0,e.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,e.jsx)(t,{className:"h-3 w-3","aria-hidden":"true"}),l]})}n(jn,"SkillStat");function _n({label:t}){return(0,e.jsx)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-nano) capitalize text-muted-foreground",children:t})}n(_n,"SkillCategoryChip");function Ua({card:t,folders:l,selected:a=!1,selectMode:u=!1,showFolderBadge:m=!1,onOpen:r,onSelectChange:g,onMove:o,onCreateFolderAndMove:x,onOpenMove:N}){const v=m&&t.installed?t.folderId?l?.find(p=>p.id===t.folderId)??null:null:void 0,I=t.folderId?l?.find(p=>p.id===t.folderId)??null:null,k=t.installed&&!t.required&&!(I&&ha(I));return(0,e.jsxs)("div",{onClick:n(()=>r(t),"onClick"),onKeyDown:n(p=>{p.target===p.currentTarget&&(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(t))},"onKeyDown"),role:"button",tabIndex:0,className:K("group flex h-full min-h-(--sz-11_5rem) flex-col rounded-lg border border-border bg-card p-4 text-left cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t.required&&"bg-muted/30"),children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[u&&k?(0,e.jsx)("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-border",checked:a,"aria-label":`Select ${t.name}`,onClick:n(p=>p.stopPropagation(),"onClick"),onChange:n(p=>g?.(t,p.target.checked),"onChange")}):null,(0,e.jsx)(Bt,{card:t}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"truncate font-mono text-sm font-medium text-foreground",children:t.name}),(0,e.jsxs)("div",{className:"truncate text-xs text-muted-foreground",children:["by ",t.author,t.version?` · ${t.version}`:""]}),v!==void 0?(0,e.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(ga,{color:v?.color,className:"h-2 w-2"}),(0,e.jsx)("span",{className:"truncate",children:v?v.name:"Unfiled"})]}):null]}),(()=>{const p=Ys(t.sourceBadge??"catalog",t.sourceLabel??null),T=p.icon;return(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground",title:`From ${p.label}`,"aria-label":`From ${p.label}`,children:(0,e.jsx)(T,{className:"h-3.5 w-3.5","aria-hidden":"true"})})})(),k&&l&&o&&x?(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsx)(y,{variant:"ghost",size:"icon-sm",className:"-mr-1 -mt-1 opacity-70 group-hover:opacity-100","aria-label":`More actions for ${t.name}`,onClick:n(p=>p.stopPropagation(),"onClick"),children:(0,e.jsx)(Er,{className:"h-4 w-4"})})}),(0,e.jsxs)(Es,{align:"end",onClick:n(p=>p.stopPropagation(),"onClick"),children:[N?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(Ze,{onSelect:n(()=>N(t),"onSelect"),children:[(0,e.jsx)(Tn,{className:"h-3.5 w-3.5"}),"Move to folder…"]}),(0,e.jsx)(Pr,{})]}):null,(0,e.jsx)(ua,{folders:l,currentFolderId:t.folderId,onMove:n(p=>o(t,p),"onMove"),onCreateAndMove:n(()=>x(t),"onCreateAndMove")})]})]}):null]}),t.forkedFrom?(0,e.jsxs)("div",{className:"mt-2 inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground",children:[(0,e.jsx)(ks,{className:"h-3 w-3","aria-hidden":"true"}),"Forked"]}):null,(0,e.jsx)("p",{className:"mt-2 line-clamp-2 min-h-8 text-xs text-muted-foreground",children:En({tagline:t.tagline,description:t.description,key:t.key,name:t.name})??""}),(0,e.jsxs)("div",{className:"mt-auto pt-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,e.jsxs)("span",{children:[t.agentCount," ",t.agentCount===1?"agent":"agents"]}),t.starCount>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,e.jsx)(jn,{icon:kn,value:String(t.starCount)})]}):null,t.forkCount>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,e.jsx)(jn,{icon:ks,value:String(t.forkCount)})]}):null]}),(0,e.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:[t.installed?(0,e.jsx)(le,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 text-(length:--text-nano) text-emerald-700 dark:text-emerald-300",children:"Installed"}):null,t.categories.slice(0,2).map(p=>(0,e.jsx)(_n,{label:p},p)),t.required?(0,e.jsxs)(le,{variant:"outline",className:"ml-auto border-border bg-muted/60 text-(length:--text-nano) text-muted-foreground",children:[(0,e.jsx)(wr,{className:"h-3 w-3","aria-hidden":"true"}),"Bundled"]}):null]})]})]})}n(Ua,"SkillCard");function Va({categories:t,total:l,active:a,onSelect:u}){return(0,e.jsxs)("nav",{className:"flex flex-col gap-0.5 px-2",children:[(0,e.jsxs)("button",{type:"button",onClick:n(()=>u(null),"onClick"),className:K("flex items-center justify-between rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent/40",a==null?"bg-accent/60 font-medium text-foreground":"text-muted-foreground"),children:[(0,e.jsx)("span",{children:"All"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:l})]}),t.map(m=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>u(m.slug),"onClick"),className:K("flex items-center justify-between rounded-md px-2 py-1.5 text-sm capitalize transition-colors hover:bg-accent/40",a===m.slug?"bg-accent/60 font-medium text-foreground":"text-muted-foreground"),children:[(0,e.jsx)("span",{className:"truncate",children:m.slug}),(0,e.jsx)("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:m.count})]},m.slug))]})}n(Va,"CategoryNav");function Qa({tab:t,tabCounts:l,onTabChange:a,categories:u,categoryTotal:m,activeCategory:r,onCategoryChange:g,search:o,onSearchChange:x,sort:N,onSortChange:v,cards:I,onOpenCard:k,loading:p,error:T,totalCount:$,onCreate:X,onImport:j,onImportFromProject:L,onBrowseCatalog:b,onScan:M,scanPending:Z,scanStatus:fe,folderResult:R,folderSelection:O="all",foldersLoading:be=!1,selectMode:D=!1,selectedSkillIds:W=[],onFolderSelect:de,onCreateFolder:Se,onRenameFolder:Pe,onEditFolder:_e,onMoveFolder:Ce,onDeleteFolder:ss,onToggleSelectMode:je,onSelectCard:ie,onMoveCard:ce,onCreateFolderAndMoveCard:ve,onMoveSelected:Oe,onCreateFolderAndMoveSelected:ts,onClearSelected:ns,onOpenMobileFolders:Rs,onCreateFolderIn:rs,onEnsureMyFolder:as,onOpenMoveCard:Ns,folderNudgeStorageKey:J}){const[U,Ue]=(0,c.useState)("all"),ue=(0,c.useMemo)(()=>{const w=new Set;for(const Ie of I)Ie.sourceBadge&&w.add(Ie.sourceBadge);return Array.from(w).sort()},[I]);(0,c.useEffect)(()=>{U!=="all"&&!ue.includes(U)&&Ue("all")},[ue,U]);const Fe=(0,c.useMemo)(()=>U==="all"?I:I.filter(w=>w.sourceBadge===U),[I,U]),ye=U!=="all",V=!!(rs&&Pe&&_e&&Ce&&ss),me=!!(R&&R.folders.length>0&&de&&V),ne=(0,c.useMemo)(()=>{if(!R||O==="all"||O==="unfiled")return null;const w=R.folders.find(Ie=>Ie.id===O);return w?.systemKey?.startsWith("project:")?w:null},[R,O]),ke=ne?.systemKey?.slice(8)||null;return(0,e.jsxs)("div",{className:"flex min-h-(--sz-calc-30) md:h-(--sz-calc-33) md:min-h-0 md:overflow-hidden",children:[me?(0,e.jsx)("div",{className:"hidden shrink-0 pl-4 pt-4 md:block",children:(0,e.jsx)(na,{result:R,selection:O,loading:be,tags:u,activeTag:r,onSelect:de,onSelectTag:g,onCreateFolder:rs,onRenameFolder:Pe,onEditFolder:_e,onMoveFolder:Ce,onDeleteFolder:ss,onEnsureMyFolder:as})}):null,(0,e.jsxs)("aside",{className:K("hidden w-60 shrink-0 flex-col overflow-hidden border-r border-border md:flex",me&&"md:hidden"),children:[(0,e.jsxs)("div",{className:"border-b border-border px-4 py-4",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Skills Store"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Discover, install, fork, share"})]}),(0,e.jsx)("div",{className:"px-4 pb-1 pt-3 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:(0,e.jsx)(Va,{categories:u,total:m,active:r,onSelect:g})})]}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex h-9 min-w-(--sz-12rem) flex-1 items-center gap-2 rounded-md border border-border px-2.5",children:[(0,e.jsx)(Mr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsx)("input",{value:o,onChange:n(w=>x(w.target.value),"onChange"),placeholder:"Search skills, authors, categories…",className:"h-full w-full bg-transparent text-base outline-none placeholder:text-muted-foreground sm:text-sm"})]}),(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Sort"}),(0,e.jsx)("span",{className:"ml-1.5",children:hn[N]}),(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"end",children:(0,e.jsx)(xt,{value:N,onValueChange:n(w=>v(w),"onValueChange"),children:qa.map(w=>(0,e.jsx)(Ls,{value:w,children:hn[w]},w))})})]}),ue.length>1?(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Source"}),(0,e.jsx)("span",{className:"ml-1.5 capitalize",children:U==="all"?"All":Ys(U,null).label}),(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"end",children:(0,e.jsxs)(xt,{value:U,onValueChange:Ue,children:[(0,e.jsx)(Ls,{value:"all",children:"All sources"}),ue.map(w=>(0,e.jsx)(Ls,{value:w,children:Ys(w,null).label},w))]})})]}):null,(0,e.jsx)(y,{variant:"ghost",size:"icon-sm",onClick:n(()=>M(),"onClick"),disabled:Z,"aria-label":"Scan project workspaces for skills",title:"Scan project workspaces for skills",children:(0,e.jsx)(Ws,{className:K("h-4 w-4",Z&&"animate-spin")})}),(0,e.jsx)(y,{asChild:!0,variant:"outline",size:"sm",children:(0,e.jsxs)(pe,{to:"/skills/studio",children:[(0,e.jsx)(Bn,{className:"h-3.5 w-3.5"}),"Studio"]})}),(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{size:"sm",variant:"default",children:[(0,e.jsx)(yt,{className:"mr-1 h-3.5 w-3.5"}),"New",(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsxs)(Es,{align:"end",children:[(0,e.jsxs)(Ze,{onSelect:X,children:[(0,e.jsx)(Nn,{className:"mr-2 h-4 w-4"}),"Create new skill"]}),(0,e.jsxs)(Ze,{onSelect:b,children:[(0,e.jsx)(ge,{className:"mr-2 h-4 w-4"}),"Browse catalog"]}),(0,e.jsx)(Ze,{asChild:!0,children:(0,e.jsxs)(pe,{to:"/skills/sources/new",children:[(0,e.jsx)(It,{className:"mr-2 h-4 w-4"}),"Import from GitHub"]})}),(0,e.jsx)(Ze,{asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources",children:"Manage sources"})}),(0,e.jsxs)(Ze,{onSelect:j,children:[(0,e.jsx)(Nr,{className:"mr-2 h-4 w-4"}),"Import from path or URL"]}),(0,e.jsxs)(Ze,{onSelect:L,children:[(0,e.jsx)(Lr,{className:"mr-2 h-4 w-4"}),"Import skills from project"]})]})]}),R&&de?(0,e.jsx)("div",{className:"w-full md:hidden",children:(0,e.jsx)(zr,{result:R,selection:O,allLabel:"All skills",onClick:Rs??(()=>{})})}):null,Se&&!me?(0,e.jsxs)(y,{variant:"outline",size:"sm",onClick:Se,children:[(0,e.jsx)(yt,{className:"mr-1 h-3.5 w-3.5"}),"New folder"]}):null,je?(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:je,children:D?"Done":"Select"}):null]}),u.length>0?(0,e.jsx)("div",{className:"border-b border-border px-4 py-2 md:hidden",children:(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",className:"w-full justify-between",children:[(0,e.jsx)("span",{className:"capitalize",children:r??"All categories"}),(0,e.jsx)(gs,{className:"h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"start",className:"max-h-72 overflow-auto",children:(0,e.jsxs)(xt,{value:r??"__all__",onValueChange:n(w=>g(w==="__all__"?null:w),"onValueChange"),children:[(0,e.jsxs)(Ls,{value:"__all__",children:["All (",m,")"]}),u.map(w=>(0,e.jsxs)(Ls,{value:w.slug,className:"capitalize",children:[w.slug," (",w.count,")"]},w.slug))]})})]})}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-4",children:[(0,e.jsx)(Sn,{value:t,onValueChange:n(w=>a(w),"onValueChange"),children:(0,e.jsxs)(wn,{variant:"line",className:"p-0",children:[(0,e.jsxs)(Ts,{value:"all",className:"px-3",children:[(0,e.jsx)("span",{children:"All"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.all})]}),(0,e.jsxs)(Ts,{value:"installed",className:"px-3",children:[(0,e.jsx)("span",{children:"Installed"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.installed})]}),(0,e.jsxs)(Ts,{value:"catalog",className:"px-3",children:[(0,e.jsx)("span",{children:"Catalog"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.catalog})]}),(0,e.jsxs)(Ts,{value:"bundled",className:"px-3",children:[(0,e.jsx)("span",{children:"Bundled"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.bundled})]})]})}),(0,e.jsx)(y,{variant:"ghost",size:"sm",asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources",children:"Sources"})})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:[fe?(0,e.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:fe}):null,me&&de?(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-2",children:[(0,e.jsx)(fa,{result:R,selection:O,onSelect:de}),ne&&ke?(0,e.jsxs)(y,{variant:"ghost",size:"sm",onClick:n(()=>M(ke),"onClick"),disabled:Z,"aria-label":`Refresh ${ne.name} project skills`,title:`Refresh skills from ${ne.name}`,children:[(0,e.jsx)(Ws,{className:K("h-3.5 w-3.5",Z&&"animate-spin")}),"Refresh"]}):null]}):null,J&&Se&&R&&R.folders.length===0&&!p&&I.length>0?(0,e.jsx)(Zr,{storageKey:J,itemLabelPlural:"skills",onCreateFolder:Se}):null,D&&Oe&&ts&&ns?(0,e.jsx)("div",{className:"mb-3",children:(0,e.jsx)(Jr,{selectedCount:W.length,folders:R?.folders??[],onMove:Oe,onCreateAndMove:ts,onClear:ns,onDone:je??ns})}):null,p?(0,e.jsx)(Be,{variant:"list"}):T?(0,e.jsx)("div",{className:"py-6 text-sm text-destructive",children:T}):Fe.length===0?(0,e.jsxs)("div",{className:"py-12",children:[(0,e.jsx)(es,{icon:Hr,message:$===0?"No skills yet. Create one or install from the catalog.":o||r||ye?"No skills match your filters.":"No skills in this tab yet."}),$===0?(0,e.jsxs)("div",{className:"mt-3 flex flex-col items-center gap-2",children:[(0,e.jsxs)(y,{size:"sm",onClick:b,children:[(0,e.jsx)(ge,{className:"mr-1.5 h-3.5 w-3.5"})," Browse catalog"]}),(0,e.jsx)(y,{size:"sm",variant:"outline",asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources/new",children:"Import from GitHub"})}),(0,e.jsx)(y,{size:"sm",variant:"ghost",onClick:X,children:"Create a skill"})]}):o||r||ye?(0,e.jsx)("div",{className:"mt-3 flex justify-center",children:(0,e.jsx)(y,{size:"sm",variant:"ghost",onClick:n(()=>{x(""),g(null),Ue("all")},"onClick"),children:"Clear filters"})}):null]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[Fe.length," ",Fe.length===1?"skill":"skills",r?(0,e.jsxs)("span",{className:"capitalize",children:[" · ",r]}):null]}),(0,e.jsx)("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(19rem,1fr))]",children:Fe.map(w=>(0,e.jsx)(Ua,{card:w,folders:R?.folders,selected:W.includes(w.skillId??""),selectMode:D,showFolderBadge:!!(R&&o.trim()),onOpen:k,onSelectChange:ie,onMove:ce,onCreateFolderAndMove:ve,onOpenMove:Ns},w.key))})]})]})]})]})}n(Qa,"DiscoveryGrid");function Ha({initialDraft:t,onCreate:l,isPending:a,error:u,onCancel:m}){const[r,g]=(0,c.useState)(0),[o,x]=(0,c.useState)(t),[N,v]=(0,c.useState)(t.slug.trim().length>0),I=o.categories.join(", "),k=["Basics","Design","Content","Review"];(0,c.useEffect)(()=>{g(0),x(t),v(t.slug.trim().length>0)},[t]);function p(j){x(L=>({...L,...j}))}n(p,"patchDraft");const T=o.name.trim().length>0,$=o.slug.trim()||pt(o.name);function X(){l(Ur(o))}return n(X,"submit"),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"flex items-center gap-2 border-b border-border pb-3",children:k.map((j,L)=>(0,e.jsx)("button",{type:"button",onClick:n(()=>g(L),"onClick"),className:K("rounded-md px-2 py-1 text-xs",r===L?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:j},j))}),o.forkedFromName?(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)(ks,{className:"h-3.5 w-3.5"}),"Forking ",o.forkedFromName]}):null,r===0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(Re,{value:o.name,onChange:n(j=>{const L=j.target.value;p({name:L,slug:N?o.slug:pt(L),markdown:o.markdown===Gs(o.name,o.tagline)?Gs(L,o.tagline):o.markdown})},"onChange"),placeholder:"Skill name",className:"h-9"}),(0,e.jsx)(Re,{value:o.slug,onChange:n(j=>{const L=pt(j.target.value);v(L.length>0),p({slug:L})},"onChange"),placeholder:"skill-shortname",className:"h-9 font-mono"}),(0,e.jsx)(jt,{value:o.tagline,onChange:n(j=>{const L=j.target.value;p({tagline:L,description:o.description?o.description:L,markdown:o.markdown===Gs(o.name,o.tagline)?Gs(o.name,L):o.markdown})},"onChange"),placeholder:"One-line promise for the skill",className:"min-h-20"})]}):r===1?(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(Bt,{size:48,card:{key:$||o.name||"new-skill",name:o.name||"New Skill",slug:$||"skill",iconUrl:null,color:o.color}}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium",children:o.name||"New Skill"}),(0,e.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:o.tagline||"No tagline yet."})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-2 block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Color"}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[_r.map(j=>(0,e.jsx)("button",{type:"button",onClick:n(()=>p({color:j}),"onClick"),className:K("h-7 w-7 rounded-md border",o.color===j?"border-foreground":"border-border"),style:{backgroundColor:j},"aria-label":`Use ${j}`},j)),(0,e.jsx)(Re,{value:o.color,onChange:n(j=>p({color:j.target.value}),"onChange"),className:"h-7 w-28 font-mono text-xs"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-2 block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)(Re,{value:I,onChange:n(j=>p({categories:Pn(j.target.value)}),"onChange"),placeholder:"engineering, review, memory",className:"h-9"})]})]}):r===2?(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)(jt,{value:o.markdown,onChange:n(j=>p({markdown:j.target.value}),"onChange"),className:"h-(--sz-calc-34) resize-y font-mono text-xs"})}):(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-26) gap-y-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Name"}),(0,e.jsx)("span",{children:o.name||"Untitled"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Slug"}),(0,e.jsx)("span",{className:"font-mono",children:$||"skill"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Scope"}),(0,e.jsx)("span",{children:o.sharingScope==="private"?"Private":"Company"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Categories"}),(0,e.jsx)("span",{children:o.categories.length?o.categories.join(", "):"none"})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sharing"}),(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[["company","private"].map(j=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>p({sharingScope:j}),"onClick"),className:K("rounded-md border px-3 py-2 text-left text-sm",o.sharingScope===j?"border-foreground bg-accent/50":"border-border"),children:[(0,e.jsx)("span",{className:"block font-medium",children:j==="company"?"Company":"Private"}),(0,e.jsx)("span",{className:"mt-1 block text-xs text-muted-foreground",children:j==="company"?"Visible inside this company.":"Only visible in your library."})]},j)),(0,e.jsxs)("button",{type:"button",disabled:!0,className:"rounded-md border border-dashed border-border px-3 py-2 text-left text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"block font-medium",children:"Public link"}),(0,e.jsx)("span",{className:"mt-1 block text-xs",children:"Coming later."})]})]})]})]}),u?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-border pt-3",children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:m,disabled:a,children:"Cancel"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>g(j=>Math.max(0,j-1)),"onClick"),disabled:a||r===0,children:"Back"}),r<k.length-1?(0,e.jsx)(y,{size:"sm",onClick:n(()=>g(j=>Math.min(k.length-1,j+1)),"onClick"),disabled:!T,children:"Next"}):(0,e.jsx)(y,{size:"sm",onClick:X,disabled:a||!T,children:a?"Creating...":o.forkedFromSkillId?"Create fork":"Create skill"})]})]})]})}n(Ha,"NewSkillWizard");function Ga({skill:t,packageName:l,packageVersion:a,installedSkill:u,installedSkillId:m,fileQuery:r,selectedPath:g,onInstall:o,onUpdate:x,onOpenInstalled:N,loadingPrimaryAction:v}){if(!t)return(0,e.jsx)(es,{icon:ge,message:"Select a catalog skill to inspect."});const I=u?.originHash??null,k=!!(u&&I&&I!==t.contentHash),p=!!u;let T;t.compatibility==="invalid"?T=(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsxs)(y,{disabled:!0,children:[(0,e.jsx)(wt,{className:"mr-1.5 h-3.5 w-3.5"}),"Install skill"]})})}),(0,e.jsx)(ze,{children:"This skill cannot be installed — its content is not valid Agent Skills markdown."})]}):p?k?T=(0,e.jsxs)(y,{onClick:x,disabled:v,className:"border-amber-500/40 bg-amber-500/20 text-amber-900 dark:text-amber-100 hover:bg-amber-500/30",children:[(0,e.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Update from catalog"]}):T=(0,e.jsxs)(y,{variant:"ghost",onClick:n(()=>m&&N(m),"onClick"),children:[(0,e.jsx)(Cn,{className:"mr-1.5 h-3.5 w-3.5"}),"Installed · Open in library"]}):T=(0,e.jsxs)(y,{onClick:o,disabled:v,children:[t.trustLevel==="scripts_executables"?(0,e.jsx)(Dn,{className:"mr-1.5 h-3.5 w-3.5"}):(0,e.jsx)(wt,{className:"mr-1.5 h-3.5 w-3.5"}),v?"Preparing...":"Install skill in this organization"]});const $=r.data?.markdown?Rn(r.data.content):r.data?.content??"";return(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"border-b border-border px-5 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("h1",{className:"flex items-center gap-2 truncate text-2xl font-semibold",children:[(0,e.jsx)(ge,{className:K("h-5 w-5 shrink-0 text-muted-foreground",t.kind==="optional"&&"opacity-70"),"aria-hidden":"true"}),t.name]}),(0,e.jsx)("p",{className:"mt-2 max-w-3xl text-sm text-muted-foreground",children:t.description}),(0,e.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"rounded border border-border bg-muted/40 px-1.5 py-0.5 uppercase tracking-wide",children:t.kind}),(0,e.jsx)("span",{children:"·"}),(0,e.jsx)("span",{children:t.category}),(0,e.jsx)("span",{children:"·"}),(0,e.jsx)(Ea,{packageName:l,packageVersion:a})]})]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:T})]}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-2 border-t border-border pt-4",children:[(0,e.jsx)($n,{level:t.trustLevel}),(0,e.jsx)(zn,{compatibility:t.compatibility}),k?(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-(length:--text-micro) text-amber-800 dark:text-amber-200",children:[(0,e.jsx)(St,{className:"h-3 w-3","aria-hidden":"true"}),"Update available"]})}),(0,e.jsx)(ze,{children:"Catalog content hash has changed since this skill was installed."})]}):null,t.requires.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Requires: ",t.requires.join(", ")]}):null,t.recommendedForRoles.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Roles: ",t.recommendedForRoles.join(" · ")]}):null,t.tags.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Tags: ",t.tags.join(" · ")]}):null]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"Key"}),(0,e.jsx)("span",{className:"font-mono",children:t.key}),(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"·"}),(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"Hash"}),(0,e.jsxs)("span",{className:"font-mono",children:[t.contentHash.slice(0,24),"…"]}),(0,e.jsx)(Yr,{text:t.contentHash,copiedLabel:"Copied hash",ariaLabel:"Copy content hash",title:"Copy content hash",className:"inline-flex h-6 w-6 items-center justify-center rounded-sm border border-border text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,e.jsx)(In,{className:"h-3 w-3"})})]})]}),(0,e.jsx)("div",{className:"border-b border-border px-5 py-3",children:(0,e.jsx)("div",{className:"truncate font-mono text-sm",children:g})}),(0,e.jsx)("div",{className:"min-h-(--sz-400px) px-5 py-5",children:r.isLoading?(0,e.jsx)(Be,{variant:"detail"}):r.error?(0,e.jsx)("div",{className:"text-sm text-destructive",children:r.error instanceof Error?r.error.message:"Failed to load file"}):r.data?r.data.markdown?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:$}):(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap wrap-break-word border-0 bg-transparent p-0 font-mono text-sm text-foreground",children:(0,e.jsx)("code",{children:r.data.content})}):(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a file to inspect."})})]})}n(Ga,"CatalogDetailPane");function Wa(t){return new Set(t.filter(l=>l.supportsSkills&&!l.required).map(l=>l.id))}n(Wa,"defaultInstallAgentSelection");function Ya({open:t,onOpenChange:l,skill:a,packageName:u,packageVersion:m,conflict:r,defaultSlug:g,defaultForce:o,defaultAction:x,agents:N,isPending:v,error:I,onConfirm:k}){const[p,T]=(0,c.useState)(""),[$,X]=(0,c.useState)(!1),[j,L]=(0,c.useState)(!1),[b,M]=(0,c.useState)(new Set),[Z,fe]=(0,c.useState)(!1),R=(0,c.useRef)(!1);if((0,c.useEffect)(()=>{t&&(T(g??""),X(o),L(x==="replace"||o))},[t,g,o,x]),(0,c.useEffect)(()=>{t&&!R.current&&fe(!1),R.current=t},[t]),(0,c.useEffect)(()=>{!t||Z||M(x==="install"?Wa(N):new Set)},[t,Z,x,N]),!a)return null;let O="Install skill",be="default";return x==="update"?O="Install update":x==="replace"&&(O="Replace existing skill",be="destructive"),v&&(O="Installing…"),(0,e.jsx)(vs,{open:t,onOpenChange:n(D=>v?null:l(D),"onOpenChange"),children:(0,e.jsxs)(bs,{className:"sm:max-w-2xl",showCloseButton:!v,children:[(0,e.jsxs)(js,{children:[(0,e.jsxs)(ys,{children:[x==="update"?"Update":x==="replace"?"Replace":"Install"," · ",a.name]}),(0,e.jsxs)(As,{children:[(0,e.jsx)("span",{className:"capitalize",children:a.kind})," · ",a.category,u?(0,e.jsxs)(e.Fragment,{children:[" · ",u,m?` v${m}`:""]}):null]})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsx)("div",{className:"rounded-md border border-border p-3",children:(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-26) gap-y-2 text-xs",children:[(0,e.jsx)("div",{className:"text-muted-foreground",children:"Trust"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)($n,{level:a.trustLevel}),a.trustLevel==="markdown_only"?(0,e.jsx)("span",{className:"text-muted-foreground",children:"Safe"}):a.trustLevel==="scripts_executables"?(0,e.jsx)("span",{className:"text-amber-800 dark:text-amber-200",children:"Review required"}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Non-script assets"})]}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Compatibility"}),(0,e.jsx)("div",{className:"flex items-center gap-2",children:a.compatibility==="compatible"?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[(0,e.jsx)(Cn,{className:"h-3 w-3","aria-hidden":"true"}),"Compatible"]}):(0,e.jsx)(zn,{compatibility:a.compatibility})}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Requires"}),(0,e.jsx)("div",{className:"text-foreground",children:a.requires.length===0?"none":a.requires.join(", ")}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Roles"}),(0,e.jsx)("div",{className:"text-foreground",children:a.recommendedForRoles.length===0?"any":a.recommendedForRoles.join(" · ")}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Provenance"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate",children:[u??"—",m?` v${m}`:""]}),(0,e.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:a.contentHash})]})]})}),(0,e.jsxs)("div",{className:"rounded-md border border-border",children:[(0,e.jsxs)("div",{className:"border-b border-border px-3 py-2 text-xs uppercase tracking-wide text-muted-foreground",children:["Files (",a.files.length,")"]}),(0,e.jsx)("div",{className:"max-h-48 overflow-y-auto",children:a.files.map(D=>(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-27) items-center gap-x-3 border-b border-border/50 px-3 py-1.5 text-xs last:border-b-0",children:[(0,e.jsx)("span",{className:"truncate font-mono text-muted-foreground",children:D.path}),(0,e.jsx)("span",{className:"rounded border border-border bg-muted/40 px-1 py-0.5 text-(length:--text-nano) uppercase text-muted-foreground",children:D.kind}),(0,e.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:Ta(D.sizeBytes)})]},D.path))})]}),r?(0,e.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-800 dark:text-amber-200",children:["An existing skill with key ",(0,e.jsx)("span",{className:"font-mono",children:r.key})," is installed (",r.sourceLabel??r.sourceType,"). Installing will ",x==="update"?"overwrite the catalog content":"replace the existing skill","."]}):null,x==="install"?(0,e.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,e.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-muted-foreground",children:"Enable for agents"}),(0,e.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Installing adds the skill to the company library. Agents can only use it once it is enabled for them."}),(0,e.jsx)(Ln,{agents:N,selectedAgentIds:b,onChange:n(D=>{fe(!0),M(D)},"onChange"),showSelectionPreview:!1,emptyMessage:"No agents in this company support skills yet.",isAgentDisabled:n(D=>{const W=D;return W.required||!W.supportsSkills},"isAgentDisabled"),getDescription:n(D=>{const W=D;return`${W.adapterType}${W.required?" · required":""}${W.supportsSkills?"":" · skills not supported"}`},"getDescription")})]}):null,(0,e.jsxs)("button",{type:"button",onClick:n(()=>L(D=>!D),"onClick"),className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[j?(0,e.jsx)(gs,{className:"h-3 w-3"}):(0,e.jsx)(Fn,{className:"h-3 w-3"}),"Advanced"]}),j?(0,e.jsxs)("div",{className:"space-y-3 rounded-md border border-border p-3 text-xs",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-1 block uppercase tracking-wide text-muted-foreground",children:"Slug override"}),(0,e.jsx)(Re,{value:p,onChange:n(D=>T(D.target.value),"onChange"),placeholder:g??a.slug,className:"h-8"})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ar,{checked:$,onCheckedChange:n(D=>X(!!D),"onCheckedChange")}),(0,e.jsx)("span",{children:"Force replace existing same-key skill"})]})]}):null,I?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-xs text-destructive",children:I}):null]}),(0,e.jsxs)(vt,{children:[(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>l(!1),"onClick"),disabled:v,children:"Cancel"}),(0,e.jsx)(y,{variant:be,onClick:n(()=>k({slug:p.trim().length>0?p.trim():null,force:$,agentIds:x==="install"?Array.from(b):[]}),"onClick"),disabled:v,children:O})]})]})})}n(Ya,"InstallPreviewDialog");function vn({agents:t,attachedAgentIds:l,versions:a,selectedVersionId:u,pending:m,onSubmit:r,fullWidth:g=!1}){const[o,x]=(0,c.useState)(u),N=(0,c.useMemo)(()=>new Set(l),[l]),v=t.filter(k=>k.supportsSkills),I=[...a].sort((k,p)=>p.revisionNumber-k.revisionNumber);return(0,e.jsx)(Ln,{agents:t,selectedAgentIds:N,onSave:n(k=>r(Array.from(k),o),"onSave"),pending:m,triggerLabel:"Add to agent",triggerIcon:(0,e.jsx)(yt,{className:"mr-1.5 h-3.5 w-3.5"}),triggerVariant:"default",triggerSize:"sm",triggerFullWidth:g,triggerClassName:K(g&&"w-full"),contentAlign:"end",showSelectionPreview:!1,onOpenChange:n(k=>{k&&x(u)},"onOpenChange"),headerContent:I.length>0?(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs",children:[(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"Version"}),(0,e.jsxs)("select",{value:o??"__latest__",onChange:n(k=>x(k.target.value==="__latest__"?null:k.target.value),"onChange"),className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs text-foreground",children:[(0,e.jsx)("option",{value:"__latest__",children:"Latest"}),I.map(k=>(0,e.jsxs)("option",{value:k.id,children:["v",k.revisionNumber,k.label?` · ${k.label}`:""]},k.id))]})]}):null,emptyMessage:v.length===0?"No agents in this company support skills yet.":"No agents yet.",isAgentDisabled:n(k=>{const p=k;return p.required||!p.supportsSkills},"isAgentDisabled"),getDescription:n(k=>{const p=k;return`${p.adapterType}${p.required?" · required":""}${p.supportsSkills?"":" · skills not supported"}`},"getDescription"),renderNameSuffix:n(k=>k.paused?(0,e.jsxs)(le,{variant:"outline",className:"[&>svg]:size-2.5 border-amber-500/30 bg-amber-500/10 px-1.5 text-(length:--text-nano) uppercase tracking-wide text-amber-500",children:[(0,e.jsx)(Nt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Paused"]}):null,"renderNameSuffix")})}n(vn,"AttachAgentsPopover");function Pt({nodes:t,skillId:l,selectedPath:a,expandedDirs:u,onToggleDir:m,onSelectPath:r,fileHref:g=n((x,N)=>Ms(x,N),"fileHref"),depth:o=0}){return(0,e.jsx)("div",{children:t.map(x=>{const N=x.kind==="dir"&&x.path?u.has(x.path):!1;if(x.kind==="dir")return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:K("group grid w-full grid-cols-(--gtc-3) items-center gap-x-1 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",cn),children:[(0,e.jsxs)("button",{type:"button",className:"flex min-w-0 items-center gap-2 py-1 text-left",style:{paddingLeft:`${on+o*dn}px`},onClick:n(()=>x.path&&m(x.path),"onClick"),children:[(0,e.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:N?(0,e.jsx)(Dt,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Ft,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("span",{className:"truncate",children:x.name})]}),(0,e.jsx)("button",{type:"button",className:"flex h-9 w-9 items-center justify-center self-center rounded-sm text-muted-foreground opacity-70 transition-(--tp-background-color-color-opacity) hover:bg-accent hover:text-foreground group-hover:opacity-100",onClick:n(()=>x.path&&m(x.path),"onClick"),children:N?(0,e.jsx)(gs,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Fn,{className:"h-3.5 w-3.5"})})]}),N&&(0,e.jsx)(Pt,{nodes:x.children,skillId:l,selectedPath:a,expandedDirs:u,onToggleDir:m,onSelectPath:r,fileHref:g,depth:o+1})]},x.path??x.name);const v=La(x.fileKind??"other");return(0,e.jsxs)(pe,{className:K("flex w-full items-center gap-2 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",cn,x.path===a&&"text-foreground"),style:{paddingInlineStart:`${on+o*dn}px`},to:g(l,x.path),onClick:n(()=>x.path&&r(x.path),"onClick"),children:[(0,e.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:(0,e.jsx)(v,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("span",{className:"truncate",children:x.name})]},x.path??x.name)})})}n(Pt,"SkillTree");var Xa=[{value:"overview",label:"Overview",icon:Lt},{value:"files",label:"Files",icon:Dt},{value:"versions",label:"Versions",icon:An},{value:"agents",label:"Agents",icon:da}];function bt(t){return t?.usedByAgents.find(l=>l.versionId)?.versionId??null}n(bt,"currentVersionSelection");function Ks(t){return t?`v${t.revisionNumber}${t.label?` · ${t.label}`:""}`:"Latest"}n(Ks,"versionLabel");function Za(t,l){const a=[...t].sort((m,r)=>r.revisionNumber-m.revisionNumber),u=l?a.find(m=>m.id===l)??null:a[0]??null;return u?{leftVersionId:(a.find(m=>m.revisionNumber<u.revisionNumber)??null)?.id??null,rightVersionId:u.id}:{leftVersionId:null,rightVersionId:null}}n(Za,"getSkillVersionDiffSelection");function Ja({open:t,onOpenChange:l,versions:a,leftVersionId:u,rightVersionId:m,onLeftVersionChange:r,onRightVersionChange:g}){const o=[...a].sort((b,M)=>M.revisionNumber-b.revisionNumber),x=o.find(b=>b.id===u)??null,N=o.find(b=>b.id===m)??null,v=(0,c.useMemo)(()=>{const b=new Set;for(const M of x?.fileInventory??[])b.add(M.path);for(const M of N?.fileInventory??[])b.add(M.path);return Array.from(b).sort((M,Z)=>M==="SKILL.md"?-1:Z==="SKILL.md"?1:M.localeCompare(Z))},[x,N]),[I,k]=(0,c.useState)("SKILL.md"),p=v.includes(I)?I:v[0]??"SKILL.md",T=x?.fileInventory.find(b=>b.path===p),$=N?.fileInventory.find(b=>b.path===p),X=(0,c.useMemo)(()=>Vr(T?.content??"",$?.content??""),[T?.content,$?.content]),j={context:"bg-transparent",removed:"bg-red-500/10 text-red-900 dark:text-red-100",added:"bg-green-500/10 text-green-900 dark:text-green-100"},L={context:" ",removed:"-",added:"+"};return(0,c.useEffect)(()=>{t&&v.length>0&&!v.includes(I)&&k(v[0])},[v,t,I]),(0,e.jsx)(vs,{open:t,onOpenChange:l,children:(0,e.jsxs)(bs,{className:"flex max-h-(--sz-85vh) w-full !max-w-(--pct-90) flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,e.jsx)(js,{className:"shrink-0",children:(0,e.jsx)(ys,{children:"Diff · skill files"})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(le,{variant:"outline",className:"border-red-500/30 bg-red-500/10 uppercase tracking-wider text-red-400",children:"Old"}),(0,e.jsxs)("select",{value:u??"",onChange:n(b=>r(b.target.value||null),"onChange"),className:"h-8 w-44 rounded-md border border-border bg-background px-2 text-xs",children:[(0,e.jsx)("option",{value:"",children:"Initial"}),o.map(b=>(0,e.jsx)("option",{value:b.id,children:Ks(b)},b.id))]})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(le,{variant:"outline",className:"border-green-500/30 bg-green-500/10 uppercase tracking-wider text-green-400",children:"New"}),(0,e.jsx)("select",{value:N?.id??"",onChange:n(b=>g(b.target.value||null),"onChange"),className:"h-8 w-44 rounded-md border border-border bg-background px-2 text-xs",children:o.map(b=>(0,e.jsx)("option",{value:b.id,children:Ks(b)},b.id))})]})]})]}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3",children:[(0,e.jsx)("aside",{className:"hidden w-56 shrink-0 overflow-auto border-r border-border pr-3 md:block",children:v.map(b=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>k(b),"onClick"),className:K("flex w-full items-center gap-2 px-2 py-1.5 text-left font-mono text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",p===b&&"bg-accent/50 text-foreground"),children:[(0,e.jsx)(Lt,{className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:b})]},b))}),(0,e.jsx)("div",{className:"min-w-0 flex-1 overflow-auto rounded-md border border-border text-xs",children:N?x?.id===N.id?(0,e.jsx)("div",{className:"p-6 text-center text-sm text-muted-foreground",children:"Both sides are the same version."}):(0,e.jsxs)("div",{className:"font-mono text-xs leading-6",children:[(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-1) border-b border-border/60 bg-muted/30 px-3 py-2 text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)("span",{children:"Old"}),(0,e.jsx)("span",{children:"New"}),(0,e.jsx)("span",{}),(0,e.jsx)("span",{children:p})]}),X.map((b,M)=>(0,e.jsxs)("div",{className:K("grid grid-cols-(--gtc-1) gap-0 border-b border-border/30 px-3",j[b.kind]),children:[(0,e.jsx)("span",{className:"select-none border-r border-border/30 pr-3 text-right text-muted-foreground",children:b.oldLineNumber??""}),(0,e.jsx)("span",{className:"select-none border-r border-border/30 px-3 text-right text-muted-foreground",children:b.newLineNumber??""}),(0,e.jsx)("span",{className:"select-none px-3 text-center text-muted-foreground",children:L[b.kind]}),(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-0 text-inherit",children:b.text.length>0?b.text:" "})]},`${b.kind}-${M}-${b.oldLineNumber??"x"}-${b.newLineNumber??"x"}`))]}):(0,e.jsx)("div",{className:"p-6 text-center text-sm text-muted-foreground",children:"Select a version to compare."})})]})]})})}n(Ja,"SkillVersionDiffDialog");function el({folderPath:t,onMove:l}){const{copied:a,failed:u,copy:m}=Qr(),r=t&&t.length>0?t:"Unfiled";return(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Location"}),(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-2.5 py-1.5",children:[(0,e.jsx)(Dt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:r,children:r})]}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsxs)(y,{size:"sm",variant:"outline",onClick:n(()=>{m(r)},"onClick"),children:[(0,e.jsx)(In,{className:"mr-1.5 h-3.5 w-3.5"}),a?"Copied":u?"Copy failed":"Copy path"]}),l?(0,e.jsxs)(y,{size:"sm",variant:"outline",onClick:l,children:[(0,e.jsx)(Tn,{className:"mr-1.5 h-3.5 w-3.5"}),"Move"]}):null]})]})}n(el,"SkillLocationCard");function sl({categories:t,pending:l,onSave:a}){const[u,m]=(0,c.useState)("");function r(g){const o=g.trim().toLowerCase();if(!o||t.includes(o)){m("");return}a([...t,o]),m("")}return n(r,"addTag"),(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)(Ir,{className:"h-3 w-3"}),"Tags"]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[t.map(g=>(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-accent/40 px-2 py-0.5 text-xs text-foreground",children:[g,(0,e.jsx)("button",{type:"button","aria-label":`Remove tag ${g}`,disabled:l,onClick:n(()=>a(t.filter(o=>o!==g)),"onClick"),className:"text-muted-foreground hover:text-foreground disabled:opacity-50",children:(0,e.jsx)(Fr,{className:"h-3 w-3"})})]},g)),t.length===0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"No tags yet."}):null]}),(0,e.jsx)(Re,{value:u,onChange:n(g=>m(g.target.value),"onChange"),onKeyDown:n(g=>{g.key==="Enter"&&(g.preventDefault(),r(u))},"onKeyDown"),onBlur:n(()=>u.trim()&&r(u),"onBlur"),placeholder:"Add a tag…",disabled:l,className:"mt-2 h-8 text-sm"})]})}n(sl,"SkillTagsEditor");function tl({detail:t,folderDisplayPath:l,catalogSource:a,routeSkills:u,loading:m,activeTab:r,onTabChange:g,selectedPath:o,file:x,fileLoading:N,viewMode:v,editMode:I,draft:k,setViewMode:p,setEditMode:T,setDraft:$,onSave:X,savePending:j,versions:L,versionsLoading:b,attachAgents:M,onSubmitAttach:Z,attachPending:fe,expandedDirs:R,onToggleDir:O,onSelectPath:be,updateStatus:D,updateStatusLoading:W,onCheckUpdates:de,checkUpdatesPending:Se,onInstallUpdate:Pe,installUpdatePending:_e,onToggleStar:Ce,starPending:ss,onFork:je,onUpdateSettings:ie,updateSettingsPending:ce,onMoveToFolder:ve,onDelete:Oe,deletePending:ts,studioHref:ns}){const[Rs,rs]=(0,c.useState)(!1),[as,Ns]=(0,c.useState)(!1),[J,U]=(0,c.useState)("company"),[Ue,ue]=(0,c.useState)(""),Fe=(0,c.useRef)(null),[ye,V]=(0,c.useState)(!1),[me,ne]=(0,c.useState)(!1);(0,c.useEffect)(()=>{const h=Fe.current;!h||ye||ne(h.scrollHeight-h.clientHeight>1)},[t?.description,t?.tagline,t?.id,ye]),(0,c.useEffect)(()=>{V(!1)},[t?.id]),(0,c.useEffect)(()=>{!t||as||(U(t.sharingScope==="public_link"?"company":t.sharingScope),ue(t.categories.join(", ")))},[t,as]);const ke=[...L].sort((h,P)=>P.revisionNumber-h.revisionNumber),[w,Ie]=(0,c.useState)(null),[Zs,ls]=(0,c.useState)(null);function qs(h){const P=Za(ke,h);Ie(P.leftVersionId),ls(P.rightVersionId),rs(!!P.rightVersionId)}n(qs,"openVersionDiff");const is=x?.content??"",ws=I&&!!x?.editable&&k!==is;if((0,c.useEffect)(()=>{if(!ws)return;const h=n(P=>{P.preventDefault(),P.returnValue=""},"handler");return window.addEventListener("beforeunload",h),()=>window.removeEventListener("beforeunload",h)},[ws]),!t)return m?(0,e.jsx)(Be,{variant:"detail"}):(0,e.jsx)(es,{icon:ge,message:"Skill not found."});const C=t,Js=ns??Kn(C.id),re=Ys(C.sourceBadge,C.sourceLabel),os=re.icon,Ve=x?.markdown?Rn(x.content):x?.content??"",et=Xs(C.sourceRef),ds=Xs(D?.latestRef),Qe=L.find(h=>h.id===bt(C))??null,cs=En(C)??re.label,$s=Pn(Ue),zs=fn($s)!==fn(C.categories),Ee=J!==(C.sharingScope==="public_link"?"company":C.sharingScope),He=zs||Ee,Ss=new Map(M.map(h=>[h.id,h])),A=a&&a.type==="github"?a:null,Cs=A?A.hostname==="github.com"?"GitHub":A.hostname:null,Te=A?`${A.owner}/${A.repo}${A.path?`/${A.path}`:""}`:null,_s=A?A.url??`https://${A.hostname}/${A.owner}/${A.repo}/tree/${A.ref}/${A.path}`.replace(/\/$/,""):null,ee=C.sourcePath||C.sourceLocator||null,us=C.homepageUrl??(ee&&/^(https?:\/\/|[\w.-]+\.[a-z]{2,}\/)/i.test(ee)?ee.startsWith("http")?ee:`https://${ee}`:null);function se(){return(0,e.jsxs)("div",{className:"grid min-h-(--sz-560px) gap-0 lg:grid-cols-(--gtc-28)",children:[(0,e.jsxs)("aside",{className:"border-b border-border pb-3 lg:border-b-0 lg:border-r lg:pb-0 lg:pr-3",children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Files"}),(0,e.jsx)(Pt,{nodes:qn(C.fileInventory),skillId:C.id,selectedPath:o,expandedDirs:R,onToggleDir:O,onSelectPath:be,fileHref:n((h,P)=>Ms(C,u??[C],P),"fileHref")})]}),(0,e.jsxs)("section",{className:"min-w-0 lg:pl-5",children:[(0,e.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsx)("div",{className:"min-w-0 truncate font-mono text-sm",children:x?.path??o}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[x?.markdown&&!I?(0,e.jsxs)("div",{className:"flex items-center border border-border",children:[(0,e.jsx)("button",{className:K("px-3 py-1.5 text-sm",v==="preview"?"text-foreground":"text-muted-foreground"),onClick:n(()=>p("preview"),"onClick"),children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Br,{className:"h-3.5 w-3.5"})," View"]})}),(0,e.jsx)("button",{className:K("border-l border-border px-3 py-1.5 text-sm",v==="code"?"text-foreground":"text-muted-foreground"),onClick:n(()=>p("code"),"onClick"),children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Fa,{className:"h-3.5 w-3.5"})," Code"]})})]}):null,C.editable&&x?.editable?I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>T(!1),"onClick"),disabled:j,children:"Cancel"}),(0,e.jsxs)(y,{size:"sm",onClick:X,disabled:j,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Saving...":"Save"]})]}):(0,e.jsxs)(y,{variant:"ghost",size:"sm",onClick:n(()=>T(!0),"onClick"),children:[(0,e.jsx)(Nn,{className:"mr-1.5 h-3.5 w-3.5"})," Edit"]}):C.editable?null:(0,e.jsxs)(y,{type:"button",variant:"outline",size:"sm",onClick:je,title:C.editableReason??"Fork this skill to edit it.",children:[(0,e.jsx)(ks,{className:"mr-1.5 h-3.5 w-3.5"}),C.sourceType==="github"?"Make a copy":"Fork"]})]})]}),N?(0,e.jsx)(Be,{variant:"detail"}):x?x.encoding==="base64"?(0,e.jsx)(Ca,{file:x}):I&&x.editable?x.markdown?(0,e.jsx)(Dr,{value:k,onChange:$,bordered:!1,className:"min-h-(--sz-520px)"}):(0,e.jsx)(jt,{value:k,onChange:n(h=>$(h.target.value),"onChange"),className:"min-h-(--sz-520px) rounded-none border-0 bg-transparent px-0 py-0 font-mono text-sm shadow-none focus-visible:ring-0"}):x.markdown&&v==="preview"?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:Ve}):(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap wrap-break-word border-0 bg-transparent p-0 font-mono text-sm text-foreground",children:(0,e.jsx)("code",{children:x.content})}):(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a file to inspect."})]})]})}n(se,"renderFilesBody");function Ae(){return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("section",{children:[(0,e.jsx)("h2",{className:"mb-2 text-sm font-medium",children:"About"}),N?(0,e.jsx)(Be,{variant:"detail"}):x?.markdown?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:Ve||C.description||"No overview yet."}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:C.description??"No overview yet."})]}),(0,e.jsxs)("section",{className:"grid min-w-0 gap-3 text-sm sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Key"}),(0,e.jsx)("div",{className:"mt-1 truncate font-mono",children:C.key})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Source"}),(0,e.jsx)("div",{className:"mt-1 min-w-0 [overflow-wrap:anywhere]",children:ee??re.label})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Version"}),(0,e.jsx)("div",{className:"mt-1",children:Ks(C.currentVersion??null)})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Mode"}),(0,e.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:C.editable?"Editable":(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{children:"Read only"}),(0,e.jsxs)(y,{type:"button",variant:"outline",size:"xs",onClick:je,children:[(0,e.jsx)(ks,{className:"mr-1 h-3 w-3"}),C.sourceType==="github"?"Make a copy":"Fork"]})]})})]})]})]})}n(Ae,"renderOverviewBody");function Q(){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:b?"Loading versions...":`${L.length} ${L.length===1?"version":"versions"}`}),(0,e.jsxs)(y,{type:"button",variant:"outline",size:"sm",onClick:n(()=>qs(),"onClick"),disabled:ke.length<2,children:[(0,e.jsx)(An,{className:"mr-1.5 h-3.5 w-3.5"})," Compare"]})]}),(0,e.jsx)("div",{className:"border-y border-border",children:b?(0,e.jsx)(Be,{variant:"list"}):ke.length===0?(0,e.jsx)("div",{className:"py-6 text-sm text-muted-foreground",children:"No saved versions yet."}):ke.map(h=>(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border px-0 py-3 text-sm last:border-b-0 sm:grid-cols-(--gtc-13)",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"font-medium",children:Ks(h)}),(0,e.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[fr(h.createdAt)," · ",h.fileInventory.length," files"]})]}),(0,e.jsx)(y,{type:"button",variant:"ghost",size:"sm",onClick:n(()=>qs(h.id),"onClick"),children:"View diff"})]},h.id))}),(0,e.jsx)(Ja,{open:Rs,onOpenChange:rs,versions:ke,leftVersionId:w,rightVersionId:Zs,onLeftVersionChange:Ie,onRightVersionChange:ls})]})}n(Q,"renderVersionsBody");function st(){const h=C.usedByAgents;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:[h.length," ",h.length===1?"agent":"agents"," attached",Qe?` · ${Ks(Qe)}`:" · Latest"]}),(0,e.jsx)(vn,{agents:M,attachedAgentIds:h.map(P=>P.id),versions:L,selectedVersionId:bt(C),pending:fe,onSubmit:Z})]}),h.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-border py-8 text-center text-sm text-muted-foreground",children:"No agents are using this skill yet. Use “Add to agent” to attach it."}):(0,e.jsx)("div",{className:"border-y border-border",children:h.map(P=>{const ae=Ss.get(P.id);return(0,e.jsxs)("div",{className:"flex items-center gap-3 border-b border-border py-3 text-sm last:border-b-0",children:[(0,e.jsx)(rn,{agent:ae,size:16,className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"truncate font-medium",children:P.name}),ae?.paused?(0,e.jsxs)(le,{variant:"outline",className:"[&>svg]:size-2.5 border-amber-500/30 bg-amber-500/10 px-1.5 text-(length:--text-nano) uppercase tracking-wide text-amber-500",children:[(0,e.jsx)(Nt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Paused"]}):null]}),(0,e.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:P.adapterType})]}),(0,e.jsx)(pe,{to:`/agents/${P.urlKey}/skills`,className:"shrink-0 text-xs text-muted-foreground no-underline hover:text-foreground",children:"View"})]},P.id)})})]})}n(st,"renderAgentsBody");const tt=r==="files"?se():r==="versions"?Q():r==="agents"?st():Ae();return(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsx)("div",{className:"border-b border-border px-4 py-5",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,e.jsx)(Bt,{card:{key:t.key,name:t.name,slug:t.slug,iconUrl:t.iconUrl,color:t.color},size:44}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)("h1",{className:"truncate text-2xl font-semibold",children:t.name}),(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":`Installed from ${re.label}`,children:(0,e.jsx)(os,{className:"h-4 w-4"})})}),(0,e.jsxs)(ze,{children:["Installed from ",re.label]})]})]}),t.authorName?(0,e.jsxs)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:["by ",(0,e.jsx)("span",{className:"text-foreground",children:t.authorName})]}):null,cs?(0,e.jsxs)("div",{className:"mt-1 max-w-2xl",children:[(0,e.jsx)("p",{ref:Fe,className:K("text-sm text-muted-foreground",!ye&&"line-clamp-4"),children:cs}),me?(0,e.jsx)("button",{type:"button",onClick:n(()=>V(h=>!h),"onClick"),className:"mt-0.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:ye?"Show less":"View all"}):null]}):null]})]}),(0,e.jsx)("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:t.categories.slice(0,4).map(h=>(0,e.jsx)(_n,{label:h},h))})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-1",children:[(0,e.jsx)(y,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsxs)(pe,{to:Js,children:[(0,e.jsx)(Bn,{className:"mr-1.5 h-3.5 w-3.5"}),"Open in Studio"]})}),(0,e.jsxs)("div",{className:"flex items-center overflow-hidden rounded-md border border-border",children:[(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(wt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.attachedAgentCount}),(0,e.jsx)("span",{className:"hidden sm:inline",children:t.attachedAgentCount===1?"install":"installs"})]})}),(0,e.jsx)(ze,{children:"Agents in this company that currently have this skill installed."})]}),(0,e.jsxs)("button",{type:"button",onClick:Ce,disabled:ss,className:"inline-flex items-center gap-1.5 border-l border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50",title:t.starredByCurrentActor?"Unstar this skill":"Star this skill",children:[(0,e.jsx)(kn,{className:K("h-3.5 w-3.5",t.starredByCurrentActor&&"fill-current text-yellow-400")}),(0,e.jsx)("span",{className:"hidden sm:inline",children:t.starredByCurrentActor?"Starred":"Star"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.starCount})]}),(0,e.jsxs)("button",{type:"button",onClick:je,className:"inline-flex items-center gap-1.5 border-l border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground",title:"Fork this skill",children:[(0,e.jsx)(ks,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:C.sourceType==="github"?"Make a copy":"Fork"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.forkCount})]})]})]})]})}),(0,e.jsxs)("div",{className:"grid gap-6 px-4 py-4 xl:grid-cols-(--gtc-29)",children:[(0,e.jsxs)("main",{className:"min-w-0",children:[(0,e.jsx)(Sn,{value:r,onValueChange:n(h=>g(h),"onValueChange"),children:(0,e.jsx)(wn,{variant:"line",className:"mb-5 w-full max-w-full justify-start overflow-x-auto border-b border-border p-0 pb-1.5 [scrollbar-width:none]",children:Xa.map(h=>{const P=h.icon;return(0,e.jsxs)(Ts,{value:h.value,className:"px-3",children:[(0,e.jsx)(P,{className:"mr-1.5 h-3.5 w-3.5"}),h.label]},h.value)})})}),tt]}),(0,e.jsxs)("aside",{className:"min-w-0 space-y-6 border-t border-border pt-4 xl:border-l xl:border-t-0 xl:pl-5 xl:pt-0",children:[(0,e.jsx)(Na,{skill:t}),(0,e.jsx)(el,{folderPath:l??Mn(t.folderPath),onMove:ve}),(0,e.jsx)(sl,{categories:t.categories,pending:ce,onSave:n(h=>ie({categories:h,sharingScope:t.sharingScope==="public_link"?"company":t.sharingScope}),"onSave")}),(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Agents"}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(vn,{agents:M,attachedAgentIds:t.usedByAgents.map(h=>h.id),versions:L,selectedVersionId:bt(t),pending:fe,onSubmit:Z,fullWidth:!0}),t.usedByAgents.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No agents attached yet."}):(0,e.jsxs)("div",{className:"space-y-0.5",children:[t.usedByAgents.slice(0,3).map(h=>{const P=Ss.get(h.id);return(0,e.jsxs)(pe,{to:`/agents/${h.urlKey}/skills`,className:"flex items-center gap-2 rounded-md px-1.5 py-1 text-sm no-underline hover:bg-accent/40",children:[(0,e.jsx)(rn,{agent:P,size:16,className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:h.name}),P?.paused?(0,e.jsx)(Nt,{className:"h-3 w-3 shrink-0 text-amber-500","aria-label":"Paused"}):null]},h.id)}),t.usedByAgents.length>3?(0,e.jsxs)("p",{className:"px-1.5 pt-0.5 text-xs text-muted-foreground",children:["and ",t.usedByAgents.length-3," more"]}):null]})]})]}),(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Source"}),A?(0,e.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,e.jsx)(It,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-foreground",children:Cs}),(0,e.jsxs)("a",{href:_s??void 0,target:"_blank",rel:"noreferrer",title:Te??void 0,className:"mt-0.5 flex max-w-full items-start gap-1 text-xs text-muted-foreground no-underline transition-colors [overflow-wrap:anywhere] hover:text-foreground",children:[(0,e.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:Te}),(0,e.jsx)(fs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"mt-0.5 truncate font-mono text-(length:--text-micro) text-muted-foreground",title:A.commit,children:[A.ref,A.commit?` · ${A.commit.slice(0,7)}`:""]})]})]}):(0,e.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,e.jsx)(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-foreground",children:re.label}),ee?us?(0,e.jsxs)("a",{href:us,target:"_blank",rel:"noreferrer",title:ee??void 0,className:"mt-0.5 flex max-w-full items-start gap-1 text-xs text-muted-foreground no-underline transition-colors [overflow-wrap:anywhere] hover:text-foreground",children:[(0,e.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:ee}),(0,e.jsx)(fs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]}):(0,e.jsx)("div",{className:"mt-0.5 min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]",title:ee??void 0,children:ee}):(0,e.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:re.managedLabel})]})]})]}),t.sourceType==="github"?(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Updates"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)(qe,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)(Sa,{className:"h-3.5 w-3.5 shrink-0","aria-label":"Pinned source revision"})}),(0,e.jsx)(ze,{children:"Pinned source revision"})]}),(0,e.jsx)("span",{className:"truncate font-mono text-foreground",children:et??"untracked"})]}),(0,e.jsxs)(y,{variant:"outline",size:"sm",className:"w-full",onClick:de,disabled:Se||W,children:[(0,e.jsx)(Ws,{className:K("mr-1.5 h-3.5 w-3.5",(Se||W)&&"animate-spin")}),"Check for updates"]}),D?.supported&&D.hasUpdate?(0,e.jsxs)(y,{size:"sm",className:"w-full",onClick:Pe,disabled:_e,children:[(0,e.jsx)(St,{className:K("mr-1.5 h-3.5 w-3.5",_e&&"animate-spin")}),"Install update",ds?` ${ds}`:""]}):D?.supported&&!D.hasUpdate&&!W?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Up to date."}):null]})]}):null,(0,e.jsx)("section",{children:(0,e.jsxs)("button",{type:"button",onClick:n(()=>{U(t.sharingScope==="public_link"?"company":t.sharingScope),ue(t.categories.join(", ")),Ns(!0)},"onClick"),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-accent/30 hover:text-foreground",children:[(0,e.jsx)(ta,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{className:"flex-1",children:"Settings"})]})})]})]}),ws?(0,e.jsxs)("div",{className:"fixed bottom-6 left-1/2 z-40 flex -translate-x-1/2 items-center gap-3 rounded-full border border-border bg-background/95 px-4 py-2 shadow-lg backdrop-blur",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Unsaved changes"}),(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>{$(is),T(!1)},"onClick"),disabled:j,children:"Discard"}),(0,e.jsxs)(y,{size:"sm",onClick:X,disabled:j,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Saving…":"Save changes"]})]}):null,(0,e.jsx)(vs,{open:as,onOpenChange:Ns,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Skill settings"}),(0,e.jsxs)(As,{children:["Manage how ",t.name," is grouped and shared."]})]}),(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)(Re,{value:Ue,onChange:n(h=>ue(h.target.value),"onChange"),placeholder:"engineering, review, memory",className:"h-9",disabled:ce}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Separate categories with commas. Leave empty to clear categories."})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sharing"}),(0,e.jsxs)("select",{value:J,onChange:n(h=>U(h.target.value),"onChange"),disabled:ce,className:"h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground",children:[(0,e.jsx)("option",{value:"company",children:"Company — visible inside this company"}),(0,e.jsx)("option",{value:"private",children:"Private — only visible in your library"})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Public link sharing is coming later."})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 border-t border-border pt-4",children:[(0,e.jsx)(y,{type:"button",variant:"ghost",size:"sm",onClick:n(()=>{U(C.sharingScope==="public_link"?"company":C.sharingScope),ue(C.categories.join(", "))},"onClick"),disabled:!He||ce,children:"Reset"}),(0,e.jsxs)(y,{type:"button",size:"sm",onClick:n(()=>ie({sharingScope:J,categories:$s}),"onClick"),disabled:!He||ce,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),ce?"Saving…":"Save settings"]})]}),t.editable?(0,e.jsxs)("div",{className:"rounded-md border border-destructive/40 p-3",children:[(0,e.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-destructive",children:"Danger zone"}),(0,e.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,e.jsx)("p",{className:"min-w-0 text-xs text-muted-foreground",children:"Remove this skill from the company library."}),(0,e.jsxs)(y,{variant:"destructive",size:"sm",className:"shrink-0",onClick:Oe,disabled:ts,title:t.usedByAgents.length>0?"Detach this skill from all agents before removing it.":void 0,children:[(0,e.jsx)(Tr,{className:"mr-1.5 h-3.5 w-3.5"}),ts?"Removing…":"Remove"]})]})]}):null]})]})})]})}n(tl,"SkillDetailPage");function El(){const{"*":t}=kr(),l=Cr(),a=jr(),[u,m]=Sr(),{selectedCompanyId:r}=yr(),{setBreadcrumbs:g}=Rr(),{pushToast:o}=pa(),x=Kr(),N=ea(),v=n((s,i,d,F)=>{N.capture(s,F)||o({tone:"error",title:i,body:s instanceof Error&&s.message?s.message:d})},"reportSkillError"),[I,k]=(0,c.useState)(""),[p,T]=(0,c.useState)(""),[$,X]=(0,c.useState)(!1),[j,L]=(0,c.useState)(null),[b,M]=(0,c.useState)({}),[Z,fe]=(0,c.useState)("preview"),[R,O]=(0,c.useState)(!1),[be,D]=(0,c.useState)(""),[W,de]=(0,c.useState)(null),[Se,Pe]=(0,c.useState)(null),[_e,Ce]=(0,c.useState)(null),[ss,je]=(0,c.useState)(!1),[ie,ce]=(0,c.useState)(null),[ve,Oe]=(0,c.useState)(null),[ts,ns]=(0,c.useState)(""),[Rs,rs]=(0,c.useState)("all"),[as,Ns]=(0,c.useState)(""),[J,U]=(0,c.useState)("SKILL.md"),[Ue,ue]=(0,c.useState)(null),[Fe,ye]=(0,c.useState)({}),[V,me]=(0,c.useState)({open:!1,catalogSkill:null,conflict:null,defaultSlug:null,defaultForce:!1,defaultAction:"install",error:null}),[ne,ke]=(0,c.useState)(""),[w,Ie]=(0,c.useState)("agents"),[Zs,ls]=(0,c.useState)(null),[qs,is]=(0,c.useState)(!1),[ws,C]=(0,c.useState)(!1),[Js,re]=(0,c.useState)(!1),[os,Ve]=(0,c.useState)(null),[et,ds]=(0,c.useState)(null),[Qe,cs]=(0,c.useState)(null),[$s,zs]=(0,c.useState)(!1),[Ee,He]=(0,c.useState)(null),[Ss,A]=(0,c.useState)(!1),[Cs,Te]=(0,c.useState)([]),[_s,ee]=(0,c.useState)([]),us=(0,c.useMemo)(()=>ya(t),[t]),se=t==="studio/new",Ae=se?null:us.skillToken,Q=us.filePath,st=u.get("view")==="catalog"?"catalog":"installed",tt=u.get("source")??"all";["all","company","bundled","optional","external"].includes(tt);const h=u.get("catalog"),P=u.get("tab"),ae=Ma(P),On=["overview","files","versions","agents"].includes(P)?P:us.hasExplicitFilePath||Q!=="SKILL.md"?"files":"overview",Ge=u.get("category"),oe=se&&u.get("forkFrom")?.trim()||null,nt=se&&u.get("folderId")?.trim()||null,rt=!se&&!Ae&&!h,G=ba(u.get("folder"));function Et(s){m(i=>Ka(i,s))}n(Et,"setDiscoveryTab");function ms(s){m(i=>{const d=new URLSearchParams(i);d.set("tab","installed"),d.delete("category");const F=sa(s);return F?d.set("folder",F):d.delete("folder"),d})}n(ms,"setFolderSelection");function xs(s=[],i=null){ee(s),Ve(null),ds(i),re(!0)}n(xs,"openCreateFolder");function Tt(s){m(i=>{const d=new URLSearchParams(i);return s==="overview"?d.delete("tab"):d.set("tab",s),d})}n(Tt,"setDetailTab");function Un(s){m(i=>{const d=new URLSearchParams(i);return s?d.set("category",s):d.delete("category"),d})}n(Un,"setDiscoveryCategory");function Vn(s,i="SKILL.md"){m(d=>{const F=new URLSearchParams(d);return s?F.set("catalog",s):F.delete("catalog"),F}),U(i)}n(Vn,"selectCatalog"),(0,c.useEffect)(()=>{se&&ls(null)},[se,oe]),(0,c.useEffect)(()=>{u.has("view")&&m(s=>{const i=new URLSearchParams(s);return i.delete("view"),i},{replace:!0})},[u,m]);const We=xe({queryKey:f.companySkills.list(r??""),queryFn:n(()=>_.list(r),"queryFn"),enabled:!!r}),Ne=xe({queryKey:f.folders.list(r??"","skill"),queryFn:n(()=>he.list(r,"skill"),"queryFn"),enabled:!!(r&&(rt&&ae==="installed"||Ae))}),te=We.data??[],Fs=(0,c.useMemo)(()=>aa(Ae,te),[Ae,te]),S=Fs.skill?.id??null,hs=xe({queryKey:f.companySkills.detail(r??"",S??""),queryFn:n(()=>_.detail(r,S),"queryFn"),enabled:!!(r&&S)}),Me=xe({queryKey:f.companySkills.file(r??"",S??"",Q),queryFn:n(()=>_.file(r,S,Q),"queryFn"),enabled:!!(r&&S&&Q)}),At=xe({queryKey:f.companySkills.versions(r??"",S??""),queryFn:n(()=>_.versions(r,S),"queryFn"),enabled:!!(r&&S)}),Ye=xe({queryKey:f.companySkills.detail(r??"",oe??""),queryFn:n(()=>_.detail(r,oe),"queryFn"),enabled:!!(r&&se&&oe)}),Qn=(0,c.useMemo)(()=>{if(!se)return gt();const s=oe?Ye.data?Gr(Ye.data):gt():gt();return nt?{...s,folderId:nt}:s},[se,Ye.data,oe,nt]),Hn=(0,c.useMemo)(()=>{if(G==="all"||G==="unfiled")return null;const s=Je(Ne.data).byId.get(G);return!s||s.path==="bundled"||s.path.startsWith("bundled/")||s.path==="projects"||s.path.startsWith("projects/")?null:s.id},[G,Ne.data]),Os=xe({queryKey:f.companySkills.updateStatus(r??"",S??""),queryFn:n(()=>_.updateStatus(r,S),"queryFn"),enabled:!!(r&&S&&(hs.data?.sourceType==="github"||W?.sourceType==="github")),staleTime:6e4});(0,c.useEffect)(()=>{if(!Fs.skill||!Fs.shouldRedirect||We.isLoading)return;const s=u.toString();l({pathname:Ms(Fs.skill,te,Q),search:s?`?${s}`:""},{replace:!0})},[te,l,Fs,u,Q,We.isLoading]),(0,c.useEffect)(()=>{L(S)},[S]),(0,c.useEffect)(()=>{if(!S||Q==="SKILL.md")return;const s=mn(Q);s.length!==0&&M(i=>{const d=new Set(i[S]??[]);let F=!1;for(const E of s)d.has(E)||(d.add(E),F=!0);return F?{...i,[S]:d}:i})},[Q,S]),(0,c.useEffect)(()=>{O(!1)},[S,Q]),(0,c.useEffect)(()=>{hs.data&&de(hs.data)},[hs.data]),(0,c.useEffect)(()=>{Me.data&&(Pe(Me.data),D(Me.data.markdown?Ct(Me.data.content).body:Me.data.content))},[Me.data]),(0,c.useEffect)(()=>{S||(de(null),Pe(null))},[S]);const B=hs.data??W;(0,c.useEffect)(()=>{g([{label:"Skills",href:"/skills"},...se?[{label:oe?"Fork skill":"New skill"}]:B?Ra(B,Ne.data).slice(1):Ae?[{label:"Detail"}]:[]])},[B,se,Ae,g,Ne.data,oe]);const Us=Me.data??Se;function ps(s,i){return Ms(s,ca(te,s),i)}n(ps,"routeForSkill");function at(s,i){const d=te.find(F=>F.id===s)??(B?.id===s?B:null);return d?ps(d,i):Ms(s,i)}n(at,"routeForSkillId");function Gn(){ce(S),Oe(B??null),je(!0)}n(Gn,"openDeleteDialog");function Vs(s){je(s),s||(ce(null),Oe(null))}n(Vs,"closeDeleteDialog");const lt=Y({mutationFn:n(s=>_.importFromSource(r,s),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.companySkills.list(r)}),s.imported[0]&&l(ps(s.imported[0])),o({tone:"success",title:"Skills imported",body:`${s.imported.length} skill${s.imported.length===1?"":"s"} added.`}),s.warnings[0]&&o({tone:"warn",title:"Import warnings",body:s.warnings[0]}),T("")},"onSuccess"),onError:n(s=>{v(s,"Skill import failed","Failed to import skill source.","Importing skills")},"onError")}),Mt=Y({mutationFn:n(s=>_.scanProjects(r,s?{projectIds:[s]}:{}),"mutationFn"),onMutate:n(s=>{Ce(s?"Refreshing project skills...":"Scanning project workspaces for skills...")},"onMutate"),onSuccess:n(async s=>{Ce("Refreshing skills list..."),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]);const i=Da(s);Ce(i),o({tone:"success",title:"Project skill scan complete",body:i}),s.conflicts[0]?o({tone:"warn",title:"Skill conflicts found",body:s.conflicts[0].reason}):s.warnings[0]&&o({tone:"warn",title:"Scan warnings",body:s.warnings[0]})},"onSuccess"),onError:n(s=>{Ce(null),v(s,"Project skill scan failed","Failed to scan project workspaces.","Scanning projects for skills")},"onError")}),Kt=Y({mutationFn:n(s=>_.create(r,s),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.companySkills.list(r)}),l(ps(s)),ls(null),o({tone:"success",title:s.forkedFromSkillId?"Skill fork created":"Skill created",body:`${s.name} is now editable in the Paperclip workspace.`})},"onSuccess"),onError:n(s=>{const i=s instanceof Error?s.message:"Failed to create skill.";ls(i),v(s,"Skill creation failed","Failed to create skill.","Creating a skill")},"onError")}),Rt=Y({mutationFn:n(()=>_.updateFile(r,S,Q,Us?.markdown?Ia(Us.content,be):be),"mutationFn"),onSuccess:n(async s=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S)}),a.invalidateQueries({queryKey:f.companySkills.file(r,S,Q)})]),D(s.markdown?Ct(s.content).body:s.content),O(!1),o({tone:"success",title:"Skill saved",body:s.path})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Save failed",body:s instanceof Error?s.message:"Failed to save skill file."})},"onError")}),qt=Y({mutationFn:n(()=>{if(!B)throw new Error("Select a skill first.");return B.starredByCurrentActor?_.unstar(r,B.id):_.star(r,B.id)},"mutationFn"),onSuccess:n(async()=>{B&&await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,B.id)})])},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Star failed",body:s instanceof Error?s.message:"Failed to update star."})},"onError")}),$t=Y({mutationFn:n(s=>_.update(r,s.skillId,s.updates),"mutationFn"),onSuccess:n(async s=>{a.setQueryData(f.companySkills.detail(r,s.id),i=>i&&{...i,...s}),a.setQueryData(f.companySkills.list(r),i=>i?.map(d=>d.id===s.id?{...d,...s}:d)),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,s.id)})]),o({tone:"success",title:"Skill settings updated",body:$a(s)})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Skill settings update failed",body:s instanceof Error?s.message:"Failed to update skill settings."})},"onError")}),zt=Y({mutationFn:n(()=>_.installUpdate(r,S),"mutationFn"),onSuccess:n(async s=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S)}),a.invalidateQueries({queryKey:f.companySkills.updateStatus(r,S)}),a.invalidateQueries({queryKey:f.companySkills.file(r,S,Q)})]),l(ps(s,Q)),o({tone:"success",title:"Skill updated",body:s.sourceRef?`Pinned to ${Xs(s.sourceRef)}`:s.name})},"onSuccess"),onError:n(s=>{v(s,"Update failed","Failed to install skill update.","Updating this skill")},"onError")}),De=xe({queryKey:f.companySkills.catalog(),queryFn:n(()=>_.catalogList(),"queryFn"),enabled:!!r,staleTime:6e4}),_t=xe({queryKey:f.companySkills.catalogDetail(h??""),queryFn:n(()=>_.catalogDetail(h),"queryFn"),enabled:!!(r&&h),staleTime:6e4}),Wn=xe({queryKey:f.companySkills.catalogFile(h??"",J),queryFn:n(()=>_.catalogFile(h,J),"queryFn"),enabled:!!(r&&h&&J),staleTime:6e4}),Ot=xe({queryKey:f.agents.list(r??""),queryFn:n(()=>Hs.list(r),"queryFn"),enabled:!!r}),Is=(0,c.useMemo)(()=>new Map(te.map(s=>[s.key,s])),[te]);(0,c.useMemo)(()=>{const s=new Set;for(const i of De.data??[])s.add(i.category);return Array.from(s).sort()},[De.data]);const Ke=(0,c.useMemo)(()=>za(te,De.data??[]),[te,De.data]),Yn=(0,c.useMemo)(()=>({all:Ke.length,installed:Ke.filter(s=>s.installed).length,catalog:Ke.filter(s=>s.catalogRef!=null).length,bundled:Ke.filter(s=>s.required).length}),[Ke]),Xe=(0,c.useMemo)(()=>_a(Ke,ae),[Ke,ae]),Xn=(0,c.useMemo)(()=>{const s=new Map;for(const i of Xe)for(const d of i.categories)s.set(d,(s.get(d)??0)+1);return Array.from(s.entries()).map(([i,d])=>({slug:i,count:d})).sort((i,d)=>d.count-i.count||i.slug.localeCompare(d.slug))},[Xe]),Ut=ne.trim().length>0,it=(0,c.useMemo)(()=>{if(G==="all"||G==="unfiled")return null;const s=Je(Ne.data);return s.byId.has(G)?ln(s,G):null},[G,Ne.data]),Zn=(0,c.useMemo)(()=>Oa(Xe.filter(s=>Ge&&!s.categories.includes(Ge)||ae==="installed"&&!Ut&&(G==="unfiled"&&s.folderId||it&&(!s.folderId||!it.has(s.folderId)))?!1:bn(s,ne.trim())),w,ae!=="bundled"),[Xe,Ge,ne,Ut,w,ae,G,it]),q=_t.data??(De.data??[]).find(s=>s.id===h||s.key===h)??null;(0,c.useEffect)(()=>{ue(q?.id??null)},[q?.id]),(0,c.useEffect)(()=>{if(!q||J==="SKILL.md")return;const s=mn(J);s.length!==0&&ye(i=>{const d=new Set(i[q.id]??[]);let F=!1;for(const E of s)d.has(E)||(d.add(E),F=!0);return F?{...i,[q.id]:d}:i})},[J,q]),(0,c.useMemo)(()=>{const s={all:te.length,company:0,bundled:0,optional:0,external:0};for(const i of te){const d=Pa(i);s[d]+=1}return s},[te]);const ot=Y({mutationFn:n(s=>_.installCatalog(r,{catalogSkillId:s.catalogSkillId,slug:s.slug,force:s.force}),"mutationFn"),onSuccess:n(async(s,i)=>{const d=s.action==="created"?i.agentIds:[];let F=0,E=0;for(const Le of d)try{await Hs.syncSkills(Le,[{key:s.skill.key,versionId:null}],"add",r??void 0),F+=1}catch{E+=1}await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,s.skill.id)})]),me(Le=>({...Le,open:!1,error:null})),o({tone:"success",title:s.action==="created"?"Skill installed":s.action==="updated"?"Skill updated":"Skill is up to date",body:s.action==="created"?F>0?`${s.skill.name} — enabled for ${F} agent${F===1?"":"s"}.`:`${s.skill.name} is in the library but not enabled for any agent yet. Use "Add to agent" to enable it.`:s.skill.name}),E>0&&o({tone:"warn",title:"Skill installed, but enabling failed",body:`Could not enable ${s.skill.name} for ${E} agent${E===1?"":"s"}. Use "Add to agent" on the skill page.`}),s.warnings[0]&&o({tone:"warn",title:"Install warnings",body:s.warnings[0]}),s.action==="created"&&l(ps(s.skill))},"onSuccess"),onError:n(s=>{const i=s instanceof Error?s.message:"Failed to install catalog skill.";me(d=>({...d,error:i})),N.capture(s,"Installing this skill")},"onError")}),Vt=Y({mutationFn:n(s=>he.create(r,{kind:"skill",parentId:et,...s}),"mutationFn"),onSuccess:n(async s=>{if(re(!1),Ve(null),ds(null),await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),_s.length>0){const i=_s;ee([]);try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s.id}))),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})])}catch(d){o({tone:"error",title:"Folder created, move failed",body:d instanceof Error?d.message:"Failed to move the selected skills."});return}}else ms(s.id);o({tone:"success",title:"Folder created",body:s.name})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder save failed",body:s instanceof Error?s.message:"Failed to save folder."})},"onError")}),dt=Y({mutationFn:n(({folderId:s,payload:i})=>he.update(r,s,i),"mutationFn"),onSuccess:n(async()=>{re(!1),Ve(null),await a.invalidateQueries({queryKey:f.folders.list(r,"skill")})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder save failed",body:s instanceof Error?s.message:"Failed to update folder."})},"onError")}),Qt=Y({mutationFn:n(({folderId:s,parentId:i})=>he.moveFolder(r,s,{parentId:i,position:0}),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),ms(s.id),o({tone:"success",title:"Folder moved",body:Mn(s.path)??s.name})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder move failed",body:s instanceof Error?s.message:"Failed to move folder."})},"onError")}),Ht=Y({mutationFn:n(s=>he.delete(r,s),"mutationFn"),onSuccess:n(async(s,i)=>{G===i&&ms("all"),cs(null),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]),o({tone:"success",title:"Folder deleted",body:"Skills moved to Unfiled."})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder delete failed",body:s instanceof Error?s.message:"Failed to delete folder."})},"onError")}),Gt=Y({mutationFn:n(({itemId:s,folderId:i})=>he.moveItem(r,{kind:"skill",itemId:s,folderId:i}),"mutationFn"),onSuccess:n(async()=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})])},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Move failed",body:s instanceof Error?s.message:"Failed to move skill."})},"onError")});async function Jn(s){const i=Cs;if(i.length!==0)try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s}))),Te([]),A(!1),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]),o({tone:"success",title:"Skills moved",body:`${i.length} skill${i.length===1?"":"s"} filed.`})}catch(d){o({tone:"error",title:"Failed to move skills",body:d instanceof Error?d.message:"Failed to move the selected skills."})}}n(Jn,"moveSelectedSkills");const Qs=Y({mutationFn:n(()=>he.ensureMy(r),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),ms(s.id)},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Couldn't open My Skills",body:s instanceof Error?s.message:"Failed to create your personal folder."})},"onError")});async function er(){const s=Je(Ne.data);if((G==="all"||G==="unfiled"?null:s.byId.get(G)??null)?.systemKey==="my"){try{const i=await Qs.mutateAsync();l(ft(null,i.id))}catch{return}return}l(ft(null,Hn))}n(er,"openNewSkill");async function sr(s){if((s?Je(Ne.data).byId.get(s):null)?.systemKey==="my"){try{xs([],(await Qs.mutateAsync()).id)}catch{return}return}xs([],s)}n(sr,"openCreateFolderIn");async function tr(s,i){if(i==="company"){Qt.mutate({folderId:s.id,parentId:null});return}try{const d=await Qs.mutateAsync();Qt.mutate({folderId:s.id,parentId:d.id})}catch{return}}n(tr,"moveFolderBetweenScopes");async function nr(s,i){try{const d=await he.create(r,{kind:"skill",parentId:s,name:i,color:null});return await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),d.id}catch(d){return o({tone:"error",title:"Folder create failed",body:d instanceof Error?d.message:"Failed to create folder."}),null}}n(nr,"createFolderInline");async function rr(s){if(!Ee)return;const i=Ee.skillIds;try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s}))),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),...i.map(d=>a.invalidateQueries({queryKey:f.companySkills.detail(r,d)}))]),He(null),Te([]),A(!1),o({tone:"success",title:i.length===1?"Skill moved":"Skills moved",body:s?`Filed under ${we?.folders.find(d=>d.id===s)?.name??"folder"}.`:"Moved to Unfiled."})}catch(d){o({tone:"error",title:"Move failed",body:d instanceof Error?d.message:"Failed to move."})}}n(rr,"performDialogMove");const Wt=(0,c.useMemo)(()=>(Ot.data??[]).map(s=>{const i=x(s.adapterType),d=[],F=new Set((B?.usedByAgents??[]).map(E=>E.id));return{id:s.id,name:s.name,adapterType:s.adapterType,supportsSkills:!!i.supportsSkills,required:!1,icon:s.icon,paused:s.status==="paused"||s.pausedAt!=null,attached:F.has(s.id),requiredKeys:d}}),[Ot.data,x,B]),Yt=Y({mutationFn:n(async s=>Hs.syncSkills(s.agentId,s.desiredSkills,"replace",r??void 0),"mutationFn"),onSuccess:n(async()=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S??"")}),a.invalidateQueries({queryKey:f.companySkills.versions(r,S??"")})])},"onSuccess")});async function ar(s,i=null){if(!B)return;const d=B.key,F=new Set(s),E=(B.usedByAgents??[]).map(H=>H.id),Le=new Set(E),ut=new Map((B.usedByAgents??[]).map(H=>[H.id,H.versionId??null])),xr=s.filter(H=>!Le.has(H)),hr=E.filter(H=>!F.has(H)),pr=s.filter(H=>Le.has(H)&&(ut.get(H)??null)!==i),sn=new Set([...xr,...hr,...pr]);if(sn.size!==0)try{for(const H of sn){const tn=await Hs.skills(H,r??void 0),nn=(tn.desiredSkillEntries??tn.desiredSkills.map(mt=>({key:mt,versionId:null}))).filter(mt=>mt.key!==d);F.has(H)&&nn.push({key:d,versionId:i}),await Yt.mutateAsync({agentId:H,desiredSkills:nn})}o({tone:"success",title:"Agents updated",body:`${s.length} agent(s) attached.`})}catch(H){o({tone:"error",title:"Update failed",body:H instanceof Error?H.message:"Failed to update agent skills."})}}n(ar,"handleAttachSubmit");function Xt(s){const i=Is.get(s.key)??null,d=i?.originHash??null,F=i?d&&d!==s.contentHash?"update":i.sourceType!=="catalog"?"replace":"update":"install";me({open:!0,catalogSkill:s,conflict:i,defaultSlug:i?.slug??s.slug,defaultForce:F==="replace",defaultAction:F,error:null})}n(Xt,"openInstallDialog");const Ds=Y({mutationFn:n(()=>_.delete(r,ie),"mutationFn"),onSuccess:n(async s=>{Vs(!1),de(null),Pe(null),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),...ie?[a.invalidateQueries({queryKey:f.companySkills.detail(r,ie)}),a.invalidateQueries({queryKey:f.companySkills.updateStatus(r,ie)})]:[],...ie?[a.invalidateQueries({queryKey:f.companySkills.file(r,ie,Q)})]:[]]),await a.refetchQueries({queryKey:f.companySkills.list(r),type:"active"}),l("/skills",{replace:!0}),o({tone:"success",title:"Skill removed",body:`${s.name} was removed from the company skill library.`})},"onSuccess"),onError:n(s=>{v(s,"Remove failed","Failed to remove skill.","Removing this skill")},"onError")}),we=Ne.data??null,z=rt&&ae==="installed",ct=(0,c.useMemo)(()=>{if(!we||ae!=="installed")return we;const s=Xe.filter(E=>Ge&&!E.categories.includes(Ge)?!1:bn(E,ne.trim())),i=new Map;let d=0;for(const E of s)E.folderId?i.set(E.folderId,(i.get(E.folderId)??0)+1):d+=1;const F=Je(we);return{...we,allCount:s.length,unfiledCount:d,folders:we.folders.map(E=>{let Le=0;for(const ut of ln(F,E.id))Le+=i.get(ut)??0;return{...E,itemCount:Le}})}},[we,ae,Xe,Ge,ne]),lr=(0,c.useMemo)(()=>la(Je(we),B?.folderId),[we,B?.folderId]);if(!r)return(0,e.jsx)(es,{icon:ge,message:"Select a company to manage skills."});function ir(){const s=p.trim();if(s.length===0){X(!0);return}lt.mutate(s)}n(ir,"handleAddSkillSource");function or(s){if(s.skillId){l(at(s.skillId));return}s.catalogRef&&Vn(s.catalogRef)}n(or,"openDiscoveryCard");const Zt=new URLSearchParams(u);Zt.delete("catalog");const Jt=Zt.toString(),dr=Jt?`/skills?${Jt}`:"/skills",cr=B?(De.data??[]).find(s=>s.key===B.key)?.source??null:null,en=Ye.data?ps(Ye.data):"/skills",ur=oe?"Fork skill":"Create a new skill",mr=oe?"Review the fork metadata and create an editable company copy.":"Create an editable company skill in the Paperclip workspace.";return(0,e.jsxs)(e.Fragment,{children:[N.denial?(0,e.jsx)("div",{className:"px-4 pt-4",children:(0,e.jsx)(oa,{denial:N.denial,onDismiss:N.reset})}):null,(0,e.jsx)(vs,{open:ss,onOpenChange:Vs,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Remove skill"}),(0,e.jsx)(As,{children:"Remove this skill from the company library. If any agents still use it, removal will be blocked until it is detached."})]}),(0,e.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,e.jsx)("p",{children:ve?`You are about to remove ${ve.name}.`:"You are about to remove this skill."}),ve?.usedByAgents?.length?(0,e.jsxs)("div",{className:"rounded-md border border-border px-3 py-3 text-muted-foreground",children:["Currently used by ",ve.usedByAgents.map(s=>s.name).join(", "),"."]}):null,(ve?.usedByAgents.length??0)>0?(0,e.jsx)("p",{className:"text-muted-foreground",children:"Detach this skill from all agents to enable removal."}):null]}),(0,e.jsx)(vt,{children:(ve?.usedByAgents.length??0)>0?(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>Vs(!1),"onClick"),children:"Close"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>Vs(!1),"onClick"),disabled:Ds.isPending,children:"Cancel"}),(0,e.jsx)(y,{variant:"destructive",onClick:n(()=>Ds.mutate(),"onClick"),disabled:Ds.isPending||!ie,children:Ds.isPending?"Removing...":"Remove skill"})]})})]})}),(0,e.jsx)(vs,{open:$,onOpenChange:X,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Add a skill source"}),(0,e.jsx)(As,{children:"Paste a local path, GitHub URL, or `skills.sh` command into the field first."})]}),(0,e.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,e.jsxs)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Browse skills.sh"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Find install commands and paste one here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),(0,e.jsxs)("a",{href:"https://github.com/search?q=SKILL.md&type=code",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Search GitHub"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Look for repositories with `SKILL.md`, then paste the repo URL here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]})]}),(0,e.jsx)(vt,{showCloseButton:!0})]})}),(0,e.jsx)(Ya,{open:V.open,onOpenChange:n(s=>me(i=>({...i,open:s,error:s?i.error:null})),"onOpenChange"),skill:V.catalogSkill,packageName:V.catalogSkill?.packageName??V.conflict?.packageName??null,packageVersion:V.catalogSkill?.packageVersion??V.conflict?.packageVersion??null,conflict:V.conflict,defaultSlug:V.defaultSlug,defaultForce:V.defaultForce,defaultAction:V.defaultAction,agents:Wt,isPending:ot.isPending,error:V.error,onConfirm:n(({slug:s,force:i,agentIds:d})=>{V.catalogSkill&&ot.mutate({catalogSkillId:V.catalogSkill.id,slug:s,force:i,agentIds:d})},"onConfirm")}),(0,e.jsx)(vs,{open:qs,onOpenChange:is,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Import a skill"}),(0,e.jsx)(As,{children:"Paste a local path, GitHub URL, or `skills.sh` command to import a skill into this company."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-b border-border pb-2",children:[(0,e.jsx)(Re,{value:p,onChange:n(s=>T(s.target.value),"onChange"),placeholder:"Paste path, GitHub URL, or skills.sh command",className:"h-9 rounded-none border-0 px-0 shadow-none focus-visible:ring-0"}),(0,e.jsx)(y,{size:"sm",onClick:ir,disabled:lt.isPending,children:lt.isPending?(0,e.jsx)(Ws,{className:"h-4 w-4 animate-spin"}):"Import"})]}),(0,e.jsxs)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-sm text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Browse skills.sh"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Find install commands and paste one here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),(0,e.jsxs)("a",{href:"https://github.com/search?q=SKILL.md&type=code",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-sm text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Search GitHub"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Look for repositories with `SKILL.md`, then paste the repo URL."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]})]})]})}),r?(0,e.jsx)(xa,{open:ws,onOpenChange:C,companyId:r,onImportFromPath:n(()=>{C(!1),is(!0)},"onImportFromPath")}):null,(0,e.jsx)(ia,{open:Js,kind:"skill",folder:os,pending:Vt.isPending||dt.isPending,onOpenChange:n(s=>{re(s),s||ds(null)},"onOpenChange"),onSubmit:n(s=>{os?dt.mutate({folderId:os.id,payload:s}):Vt.mutate(s)},"onSubmit")}),(0,e.jsx)(Xr,{open:Qe!==null,folder:Qe,itemLabelPlural:"skills",pending:Ht.isPending,onOpenChange:n(s=>{s||cs(null)},"onOpenChange"),onConfirm:n(()=>{Qe&&Ht.mutate(Qe.id)},"onConfirm")}),(0,e.jsx)(ja,{open:$s,onOpenChange:zs,result:ct,selection:G,allLabel:"All skills",itemLabelPlural:"Skills",onSelect:ms,onCreate:n(()=>xs(),"onCreate")}),(0,e.jsx)(va,{open:Ee!==null,onOpenChange:n(s=>{s||He(null)},"onOpenChange"),result:ct,title:Ee?.title??"Move to folder",subtitle:Ee?.subtitle??null,currentFolderId:Ee?.currentFolderId??null,onMove:n(s=>{rr(s)},"onMove"),onCreateFolder:nr}),se?(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsxs)("div",{className:"border-b border-border px-4 py-5",children:[(0,e.jsxs)(pe,{to:en,className:"mb-3 inline-flex items-center gap-1.5 text-sm text-muted-foreground no-underline transition-colors hover:text-foreground",children:[(0,e.jsx)(an,{className:"h-4 w-4"}),"Back"]}),(0,e.jsx)("h1",{className:"text-2xl font-semibold",children:ur}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:mr})]}),(0,e.jsx)("div",{className:"px-4 py-4",children:(0,e.jsx)("div",{className:"max-w-3xl",children:oe&&Ye.isLoading?(0,e.jsx)(Be,{variant:"detail"}):oe&&!Ye.data?(0,e.jsx)(es,{icon:ge,message:"Fork source skill not found."}):(0,e.jsx)(Ha,{initialDraft:Qn,onCreate:n(s=>Kt.mutate(s),"onCreate"),isPending:Kt.isPending,error:Zs,onCancel:n(()=>l(en),"onCancel")})})})]}):rt?(0,e.jsx)(Qa,{tab:ae,tabCounts:Yn,onTabChange:Et,categories:Xn,categoryTotal:Xe.length,activeCategory:Ge,onCategoryChange:Un,search:ne,onSearchChange:ke,sort:w,onSortChange:Ie,cards:Zn,onOpenCard:or,loading:We.isLoading||De.isLoading,error:We.error?.message??De.error?.message??null,totalCount:Ke.length,onCreate:n(()=>{er()},"onCreate"),onImport:n(()=>is(!0),"onImport"),onImportFromProject:n(()=>C(!0),"onImportFromProject"),onBrowseCatalog:n(()=>Et("catalog"),"onBrowseCatalog"),onScan:n(s=>Mt.mutate(s),"onScan"),scanPending:Mt.isPending,scanStatus:_e,folderResult:z?ct:null,folderSelection:G,foldersLoading:Ne.isLoading,selectMode:z&&Ss,selectedSkillIds:Cs,onFolderSelect:z?ms:void 0,onOpenMobileFolders:z?()=>zs(!0):void 0,onCreateFolder:z?()=>xs():void 0,onCreateFolderIn:z?s=>{sr(s)}:void 0,onEnsureMyFolder:z?()=>Qs.mutate():void 0,onOpenMoveCard:z?s=>{s.skillId&&He({skillIds:[s.skillId],title:`Move "${s.name}"`,subtitle:"Choose a destination folder.",currentFolderId:s.folderId??null})}:void 0,onRenameFolder:z?(s,i)=>dt.mutate({folderId:s.id,payload:{name:i}}):void 0,onEditFolder:z?s=>{Ve(s),re(!0)}:void 0,onMoveFolder:z?(s,i)=>{tr(s,i)}:void 0,onDeleteFolder:z?cs:void 0,onToggleSelectMode:z?()=>{A(s=>!s),Ss&&Te([])}:void 0,onSelectCard:z?(s,i)=>{s.skillId&&Te(d=>i?Array.from(new Set([...d,s.skillId])):d.filter(F=>F!==s.skillId))}:void 0,onMoveCard:z?(s,i)=>{if(!s.skillId)return;const d=s.skillId,F=s.folderId??null;Gt.mutate({itemId:d,folderId:i}),o({tone:"success",title:"Skill moved",body:i?`Moved "${s.name}" to ${we?.folders.find(E=>E.id===i)?.name??"folder"}.`:`Moved "${s.name}" to Unfiled.`,action:{label:"Undo",onClick:n(()=>Gt.mutate({itemId:d,folderId:F}),"onClick")}})}:void 0,onCreateFolderAndMoveCard:z?s=>{s.skillId&&xs([s.skillId])}:void 0,onMoveSelected:z?s=>{Jn(s)}:void 0,onCreateFolderAndMoveSelected:z?()=>xs(Cs):void 0,onClearSelected:z?()=>Te([]):void 0,folderNudgeStorageKey:z?`paperclip:skills-folder-nudge:${r??"none"}`:void 0}):st==="installed"&&S?(0,e.jsx)(tl,{detail:B,folderDisplayPath:lr,catalogSource:cr,routeSkills:te,loading:We.isLoading||hs.isLoading,activeTab:On,onTabChange:Tt,selectedPath:Q,file:Us,fileLoading:Me.isLoading&&!Us,viewMode:Z,editMode:R,draft:be,setViewMode:fe,setEditMode:O,setDraft:D,onSave:n(()=>Rt.mutate(),"onSave"),savePending:Rt.isPending,versions:At.data??[],versionsLoading:At.isLoading,attachAgents:Wt,onSubmitAttach:ar,attachPending:Yt.isPending,expandedDirs:b[S]??new Set,onToggleDir:n(s=>{M(i=>{const d=new Set(i[S]??[]);return d.has(s)?d.delete(s):d.add(s),{...i,[S]:d}})},"onToggleDir"),onSelectPath:n(s=>{Tt("files"),l(at(S,s))},"onSelectPath"),updateStatus:Os.data,updateStatusLoading:Os.isLoading,onCheckUpdates:n(()=>{Os.refetch()},"onCheckUpdates"),checkUpdatesPending:Os.isFetching,onInstallUpdate:n(()=>zt.mutate(),"onInstallUpdate"),installUpdatePending:zt.isPending,onToggleStar:n(()=>qt.mutate(),"onToggleStar"),starPending:qt.isPending,onFork:n(()=>B&&l(ft(B.id)),"onFork"),onUpdateSettings:n(s=>B&&$t.mutate({skillId:B.id,updates:s}),"onUpdateSettings"),onMoveToFolder:B?()=>He({skillIds:[B.id],title:`Move "${B.name}"`,subtitle:"Choose a destination folder.",currentFolderId:B.folderId??null}):void 0,updateSettingsPending:$t.isPending,onDelete:Gn,deletePending:Ds.isPending,studioHref:Kn(S)}):h?(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,e.jsxs)(pe,{to:dr,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground no-underline transition-colors hover:text-foreground",children:[(0,e.jsx)(an,{className:"h-4 w-4"}),"Back to store"]})}),De.isLoading||_t.isLoading?(0,e.jsx)(Be,{variant:"detail"}):q?(0,e.jsxs)("div",{className:"grid gap-0 xl:grid-cols-(--gtc-30)",children:[(0,e.jsxs)("aside",{className:"border-b border-border px-3 py-4 xl:border-b-0 xl:border-r",children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Files"}),(0,e.jsx)(Pt,{nodes:qn(q.files.map(s=>({path:s.path,kind:s.kind}))),skillId:q.id,selectedPath:J,expandedDirs:Fe[q.id]??new Set,onToggleDir:n(s=>ye(i=>{const d=new Set(i[q.id]??[]);return d.has(s)?d.delete(s):d.add(s),{...i,[q.id]:d}}),"onToggleDir"),onSelectPath:n(s=>U(s),"onSelectPath"),fileHref:n(()=>`/skills?catalog=${encodeURIComponent(h)}`,"fileHref")})]}),(0,e.jsx)("div",{className:"min-w-0",children:(0,e.jsx)(Ga,{skill:q,packageName:q.packageName??Is.get(q.key)?.packageName??null,packageVersion:q.packageVersion??Is.get(q.key)?.packageVersion??null,installedSkill:Is.get(q.key)??null,installedSkillId:Is.get(q.key)?.id??null,fileQuery:Wn,selectedPath:J,onInstall:n(()=>Xt(q),"onInstall"),onUpdate:n(()=>Xt(q),"onUpdate"),onOpenInstalled:n(s=>l(at(s)),"onOpenInstalled"),loadingPrimaryAction:ot.isPending})})]}):(0,e.jsx)(es,{icon:ge,message:"Catalog skill not found."})]}):(0,e.jsx)("div",{className:"min-h-(--sz-calc-30)",children:We.isLoading?(0,e.jsx)(Be,{variant:"detail"}):(0,e.jsx)(es,{icon:ge,message:"Skill not found."})})]})}n(El,"CompanySkills");export{El as CompanySkills};
|
|
10
|
+
`):l}n(Ia,"mergeFrontmatter");function Rn(t){const l={name:"",path:null,kind:"dir",children:[]};for(const u of t){const m=u.path.split("/").filter(Boolean);let r=l,g="";for(const[o,x]of m.entries()){g=g?`${g}/${x}`:x;const N=o===m.length-1;let v=r.children.find(I=>I.name===x);v||(v={name:x,path:N?u.path:g,kind:N?"file":"dir",fileKind:N?u.kind:void 0,children:[]},r.children.push(v)),r=v}}function a(u){u.children.sort((m,r)=>m.kind!==r.kind?m.kind==="dir"?-1:1:m.name==="SKILL.md"?-1:r.name==="SKILL.md"?1:m.name.localeCompare(r.name)),u.children.forEach(a)}return n(a,"sortNode"),a(l),l.children}n(Rn,"buildTree");function Ys(t,l){const a=l?.toLowerCase()??"",u=a.includes("skills.sh")||a.includes("vercel-labs/skills");switch(t){case"skills_sh":return{icon:un,label:l??"skills.sh",managedLabel:"skills.sh managed"};case"github":return u?{icon:un,label:l??"skills.sh",managedLabel:"skills.sh managed"}:{icon:It,label:l??"GitHub",managedLabel:"GitHub managed"};case"url":return{icon:ca,label:l??"URL",managedLabel:"URL managed"};case"local":return{icon:Ft,label:l??"Folder",managedLabel:"Folder managed"};case"paperclip":return{icon:Or,label:l??"Paperclip",managedLabel:"Paperclip managed"};default:return{icon:ge,label:l??"Catalog",managedLabel:"Catalog managed"}}}n(Ys,"sourceMeta");function Xs(t){return t?t.slice(0,7):null}n(Xs,"shortRef");function Da(t){const l=[`${t.discovered} found`,`${t.imported.length} imported`,`${t.updated.length} updated`];return t.conflicts.length>0&&l.push(`${t.conflicts.length} conflicts`),t.skipped.length>0&&l.push(`${t.skipped.length} skipped`),`${l.join(", ")} across ${t.scannedWorkspaces} workspace${t.scannedWorkspaces===1?"":"s"}.`}n(Da,"formatProjectScanSummary");function La(t){return t==="script"||t==="reference"?$r:Lt}n(La,"fileIcon");function mn(t){const l=t.split("/").filter(Boolean),a=[];for(let u=0;u<l.length-1;u+=1)a.push(l.slice(0,u+1).join("/"));return a}n(mn,"parentDirectoryPaths");function xn(t,l){if(!t||typeof t!="object")return null;const a=t[l];if(typeof a!="string")return null;const u=a.trim();return u.length>0?u:null}n(xn,"readonlyMetadataValue");function Ba(t){const l=xn(t,"sourceKind")??xn(t,"catalogKind");return l==="bundled"?"bundled":l==="optional"?"optional":null}n(Ba,"readonlyMetadataKind");function Pa(t){if(t.sourceBadge==="paperclip"||t.sourceType==="local_path"&&!t.sourceBadge.toString().includes("github"))return"company";if(t.sourceType==="catalog"||t.sourceBadge==="catalog"){const l=t.catalogKind??Ba(t.metadata);return l==="bundled"?"bundled":l==="optional"?"optional":"company"}return t.sourceBadge==="github"||t.sourceBadge==="skills_sh"||t.sourceBadge==="url"||t.sourceBadge==="local"?"external":"company"}n(Pa,"classifySource");function $n({level:t}){const l={markdown_only:{icon:wa,label:"Markdown only",tooltip:"Text only — no scripts, no binaries, no assets.",className:"border-border bg-muted/40 text-muted-foreground"},assets:{icon:Ft,label:"Includes assets",tooltip:"Ships images, fonts, or other non-script files.",className:"border-cyan-500/30 bg-cyan-500/10 text-cyan-800 dark:text-cyan-200"},scripts_executables:{icon:Dn,label:"Includes scripts",tooltip:"Ships executable scripts. Review before installing.",className:"border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200"}},a=l[t]??l.markdown_only,u=a.icon;return(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:K("text-(length:--text-micro)",a.className),children:[(0,e.jsx)(u,{className:"h-3 w-3","aria-hidden":"true"}),a.label]})}),(0,e.jsx)(ze,{children:a.tooltip})]})}n($n,"TrustChip");function zn({compatibility:t}){if(t==="compatible")return null;const l={unknown:{icon:Rr,label:"Unknown format",tooltip:"Paperclip could not validate this skill as Agent Skills markdown. Install at your own risk.",className:"border-yellow-500/40 bg-yellow-500/10 text-yellow-800 dark:text-yellow-200"},invalid:{icon:Hr,label:"Invalid",tooltip:"This skill cannot be installed — content is not valid Agent Skills markdown.",className:"border-destructive/40 bg-destructive/10 text-destructive"}}[t],a=l.icon;return(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:K("text-(length:--text-micro)",l.className),children:[(0,e.jsx)(a,{className:"h-3 w-3","aria-hidden":"true"}),l.label]})}),(0,e.jsx)(ze,{children:l.tooltip})]})}n(zn,"CompatChip");function Ea({packageName:t,packageVersion:l}){return t?(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted/30 px-1.5 py-0.5 font-mono text-(length:--text-nano) text-muted-foreground",children:[(0,e.jsx)(ge,{className:"h-3 w-3","aria-hidden":"true"}),(0,e.jsxs)("span",{children:[t,l?` v${l}`:""]})]})}),(0,e.jsx)(ze,{children:"Installed from the app-shipped skills catalog. Provenance is signed by package version and content hash."})]}):null}n(Ea,"ProvenanceBadge");function Ta(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}n(Ta,"formatBytes");var Aa=["all","installed","catalog","bundled"];function Ma(t){return Aa.includes(t)?t:"installed"}n(Ma,"resolveDiscoveryTab");function Ka(t,l){const a=new URLSearchParams(t);return l==="installed"?a.delete("tab"):a.set("tab",l),a.delete("category"),l!=="installed"&&a.delete("folder"),a}n(Ka,"withDiscoveryTab");function qa(t,l){return[{label:"Skills",href:"/skills"},...(t.folderId?ta(Je(l),t.folderId):[]).map((a,u)=>({label:u===0?ka(a):a.name,href:`/skills?folder=${encodeURIComponent(a.id)}`})),{label:t.name}]}n(qa,"skillDetailBreadcrumbs");var hn={agents:"Most agents",stars:"Most stars",forks:"Most forks",recent:"Recently updated",alphabetical:"Alphabetical"},Ra=["agents","stars","forks","recent","alphabetical"];function pn(t,l){return t.packageVersion?`v${t.packageVersion}`:l?"core":t.sourceRef?Xs(t.sourceRef):null}n(pn,"discoveryVersionLabel");function gn(t){const l=[],a=new Set;for(const u of t){const m=u?.trim();!m||a.has(m)||(a.add(m),l.push(m))}return l}n(gn,"uniqueCategories");function fn(t){return[...t].sort().join(",")}n(fn,"categorySetKey");function $a(t){return`${t.sharingScope==="private"?"Sharing: private":"Sharing: company"} | ${t.categories.length?`Categories: ${t.categories.join(", ")}`:"Categories: none"}`}n($a,"skillSettingsToastBody");function za(t,l){const a=new Map(l.map(r=>[r.key,r])),u=[],m=new Set;for(const r of t){m.add(r.key);const g=a.get(r.key)??null,o=r.catalogKind==="bundled"||g?.kind==="bundled";u.push({key:r.key,skillId:r.id,folderId:r.folderId??null,catalogRef:g?g.id:null,name:r.name,slug:r.slug,author:r.authorName??r.sourceLabel??"you",version:pn(r,o),tagline:r.tagline??null,description:r.description??null,categories:gn([...r.categories??[],g?.category]),iconUrl:r.iconUrl,color:r.color,starCount:r.starCount??0,agentCount:r.attachedAgentCount??0,forkCount:r.forkCount??0,installed:!0,required:o,forkedFrom:!!r.forkedFromSkillId,updatedAt:new Date(r.updatedAt).getTime()||0,sourceBadge:r.sourceBadge,sourceLabel:r.sourceLabel})}for(const r of l){if(m.has(r.key))continue;const g=r.kind==="bundled";u.push({key:r.key,skillId:null,folderId:null,catalogRef:r.id,name:r.name,slug:r.slug,author:r.packageName??"Paperclip",version:pn({packageVersion:r.packageVersion??null,sourceRef:null},g),tagline:null,description:r.description,categories:gn([r.category,...r.tags??[]]),iconUrl:null,color:null,starCount:0,agentCount:0,forkCount:0,installed:!1,required:g,forkedFrom:!1,updatedAt:0,sourceBadge:"catalog",sourceLabel:r.packageName??"Catalog"})}return u}n(za,"buildDiscoveryCards");function _a(t,l){switch(l){case"installed":return t.filter(a=>a.installed);case"catalog":return t.filter(a=>a.catalogRef!=null);case"bundled":return t.filter(a=>a.required);default:return t}}n(_a,"cardsForTab");function Oa(t,l,a){const u=n((m,r)=>m.name.localeCompare(r.name),"byName");return[...t].sort((m,r)=>{if(a&&m.required!==r.required)return m.required?1:-1;switch(l){case"stars":return r.starCount-m.starCount||u(m,r);case"forks":return r.forkCount-m.forkCount||u(m,r);case"recent":return r.updatedAt-m.updatedAt||u(m,r);case"alphabetical":return u(m,r);default:return r.agentCount-m.agentCount||u(m,r)}})}n(Oa,"sortDiscoveryCards");function bn(t,l){return l?[t.name,t.slug,t.author,t.tagline??"",t.description??"",t.categories.join(" ")].join(" ").toLowerCase().includes(l.toLowerCase()):!0}n(bn,"discoveryMatchesSearch");function jn({icon:t,value:l}){return(0,e.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,e.jsx)(t,{className:"h-3 w-3","aria-hidden":"true"}),l]})}n(jn,"SkillStat");function _n({label:t}){return(0,e.jsx)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-nano) capitalize text-muted-foreground",children:t})}n(_n,"SkillCategoryChip");function Ua({card:t,folders:l,selected:a=!1,selectMode:u=!1,showFolderBadge:m=!1,onOpen:r,onSelectChange:g,onMove:o,onCreateFolderAndMove:x,onOpenMove:N}){const v=m&&t.installed?t.folderId?l?.find(p=>p.id===t.folderId)??null:null:void 0,I=t.folderId?l?.find(p=>p.id===t.folderId)??null:null,k=t.installed&&!t.required&&!(I&&ha(I));return(0,e.jsxs)("div",{onClick:n(()=>r(t),"onClick"),onKeyDown:n(p=>{p.target===p.currentTarget&&(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),r(t))},"onKeyDown"),role:"button",tabIndex:0,className:K("group flex h-full min-h-(--sz-11_5rem) flex-col rounded-lg border border-border bg-card p-4 text-left cursor-pointer transition-colors hover:border-foreground/20 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t.required&&"bg-muted/30"),children:[(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[u&&k?(0,e.jsx)("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-border",checked:a,"aria-label":`Select ${t.name}`,onClick:n(p=>p.stopPropagation(),"onClick"),onChange:n(p=>g?.(t,p.target.checked),"onChange")}):null,(0,e.jsx)(Bt,{card:t}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("div",{className:"truncate font-mono text-sm font-medium text-foreground",children:t.name}),(0,e.jsxs)("div",{className:"truncate text-xs text-muted-foreground",children:["by ",t.author,t.version?` · ${t.version}`:""]}),v!==void 0?(0,e.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(ga,{color:v?.color,className:"h-2 w-2"}),(0,e.jsx)("span",{className:"truncate",children:v?v.name:"Unfiled"})]}):null]}),(()=>{const p=Ys(t.sourceBadge??"catalog",t.sourceLabel??null),T=p.icon;return(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground",title:`From ${p.label}`,"aria-label":`From ${p.label}`,children:(0,e.jsx)(T,{className:"h-3.5 w-3.5","aria-hidden":"true"})})})(),k&&l&&o&&x?(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsx)(y,{variant:"ghost",size:"icon-sm",className:"-mr-1 -mt-1 opacity-70 group-hover:opacity-100","aria-label":`More actions for ${t.name}`,onClick:n(p=>p.stopPropagation(),"onClick"),children:(0,e.jsx)(Er,{className:"h-4 w-4"})})}),(0,e.jsxs)(Es,{align:"end",onClick:n(p=>p.stopPropagation(),"onClick"),children:[N?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(Ze,{onSelect:n(()=>N(t),"onSelect"),children:[(0,e.jsx)(Tn,{className:"h-3.5 w-3.5"}),"Move to folder…"]}),(0,e.jsx)(Pr,{})]}):null,(0,e.jsx)(da,{folders:l,currentFolderId:t.folderId,onMove:n(p=>o(t,p),"onMove"),onCreateAndMove:n(()=>x(t),"onCreateAndMove")})]})]}):null]}),t.forkedFrom?(0,e.jsxs)("div",{className:"mt-2 inline-flex items-center gap-1 text-(length:--text-micro) text-muted-foreground",children:[(0,e.jsx)(ks,{className:"h-3 w-3","aria-hidden":"true"}),"Forked"]}):null,(0,e.jsx)("p",{className:"mt-2 line-clamp-2 min-h-8 text-xs text-muted-foreground",children:En({tagline:t.tagline,description:t.description,key:t.key,name:t.name})??""}),(0,e.jsxs)("div",{className:"mt-auto pt-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-(length:--text-micro) text-muted-foreground",children:[(0,e.jsxs)("span",{children:[t.agentCount," ",t.agentCount===1?"agent":"agents"]}),t.starCount>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,e.jsx)(jn,{icon:kn,value:String(t.starCount)})]}):null,t.forkCount>0?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"·"}),(0,e.jsx)(jn,{icon:ks,value:String(t.forkCount)})]}):null]}),(0,e.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:[t.installed?(0,e.jsx)(le,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 text-(length:--text-nano) text-emerald-700 dark:text-emerald-300",children:"Installed"}):null,t.categories.slice(0,2).map(p=>(0,e.jsx)(_n,{label:p},p)),t.required?(0,e.jsxs)(le,{variant:"outline",className:"ml-auto border-border bg-muted/60 text-(length:--text-nano) text-muted-foreground",children:[(0,e.jsx)(wr,{className:"h-3 w-3","aria-hidden":"true"}),"Bundled"]}):null]})]})]})}n(Ua,"SkillCard");function Va({categories:t,total:l,active:a,onSelect:u}){return(0,e.jsxs)("nav",{className:"flex flex-col gap-0.5 px-2",children:[(0,e.jsxs)("button",{type:"button",onClick:n(()=>u(null),"onClick"),className:K("flex items-center justify-between rounded-md px-2 py-1.5 text-sm transition-colors hover:bg-accent/40",a==null?"bg-accent/60 font-medium text-foreground":"text-muted-foreground"),children:[(0,e.jsx)("span",{children:"All"}),(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:l})]}),t.map(m=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>u(m.slug),"onClick"),className:K("flex items-center justify-between rounded-md px-2 py-1.5 text-sm capitalize transition-colors hover:bg-accent/40",a===m.slug?"bg-accent/60 font-medium text-foreground":"text-muted-foreground"),children:[(0,e.jsx)("span",{className:"truncate",children:m.slug}),(0,e.jsx)("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:m.count})]},m.slug))]})}n(Va,"CategoryNav");function Qa({tab:t,tabCounts:l,onTabChange:a,categories:u,categoryTotal:m,activeCategory:r,onCategoryChange:g,search:o,onSearchChange:x,sort:N,onSortChange:v,cards:I,onOpenCard:k,loading:p,error:T,totalCount:$,onCreate:X,onImport:j,onImportFromProject:L,onBrowseCatalog:b,onScan:M,scanPending:Z,scanStatus:fe,folderResult:q,folderSelection:O="all",foldersLoading:be=!1,selectMode:D=!1,selectedSkillIds:W=[],onFolderSelect:de,onCreateFolder:Se,onRenameFolder:Pe,onEditFolder:_e,onMoveFolder:Ce,onDeleteFolder:ss,onToggleSelectMode:je,onSelectCard:ie,onMoveCard:ce,onCreateFolderAndMoveCard:ve,onMoveSelected:Oe,onCreateFolderAndMoveSelected:ts,onClearSelected:ns,onOpenMobileFolders:qs,onCreateFolderIn:rs,onEnsureMyFolder:as,onOpenMoveCard:Ns,folderNudgeStorageKey:J}){const[U,Ue]=(0,c.useState)("all"),ue=(0,c.useMemo)(()=>{const w=new Set;for(const Ie of I)Ie.sourceBadge&&w.add(Ie.sourceBadge);return Array.from(w).sort()},[I]);(0,c.useEffect)(()=>{U!=="all"&&!ue.includes(U)&&Ue("all")},[ue,U]);const Fe=(0,c.useMemo)(()=>U==="all"?I:I.filter(w=>w.sourceBadge===U),[I,U]),ye=U!=="all",V=!!(rs&&Pe&&_e&&Ce&&ss),me=!!(q&&q.folders.length>0&&de&&V),ne=(0,c.useMemo)(()=>{if(!q||O==="all"||O==="unfiled")return null;const w=q.folders.find(Ie=>Ie.id===O);return w?.systemKey?.startsWith("project:")?w:null},[q,O]),ke=ne?.systemKey?.slice(8)||null;return(0,e.jsxs)("div",{className:"flex min-h-(--sz-calc-30) md:h-(--sz-calc-33) md:min-h-0 md:overflow-hidden",children:[me?(0,e.jsx)("div",{className:"hidden shrink-0 pl-4 pt-4 md:block",children:(0,e.jsx)(sa,{result:q,selection:O,loading:be,tags:u,activeTag:r,onSelect:de,onSelectTag:g,onCreateFolder:rs,onRenameFolder:Pe,onEditFolder:_e,onMoveFolder:Ce,onDeleteFolder:ss,onEnsureMyFolder:as})}):null,(0,e.jsxs)("aside",{className:K("hidden w-60 shrink-0 flex-col overflow-hidden border-r border-border md:flex",me&&"md:hidden"),children:[(0,e.jsxs)("div",{className:"border-b border-border px-4 py-4",children:[(0,e.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Skills Store"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Discover, install, fork, share"})]}),(0,e.jsx)("div",{className:"px-4 pb-1 pt-3 text-(length:--text-micro) font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:(0,e.jsx)(Va,{categories:u,total:m,active:r,onSelect:g})})]}),(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex h-9 min-w-(--sz-12rem) flex-1 items-center gap-2 rounded-md border border-border px-2.5",children:[(0,e.jsx)(Mr,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsx)("input",{value:o,onChange:n(w=>x(w.target.value),"onChange"),placeholder:"Search skills, authors, categories…",className:"h-full w-full bg-transparent text-base outline-none placeholder:text-muted-foreground sm:text-sm"})]}),(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Sort"}),(0,e.jsx)("span",{className:"ml-1.5",children:hn[N]}),(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"end",children:(0,e.jsx)(xt,{value:N,onValueChange:n(w=>v(w),"onValueChange"),children:Ra.map(w=>(0,e.jsx)(Ls,{value:w,children:hn[w]},w))})})]}),ue.length>1?(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Source"}),(0,e.jsx)("span",{className:"ml-1.5 capitalize",children:U==="all"?"All":Ys(U,null).label}),(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"end",children:(0,e.jsxs)(xt,{value:U,onValueChange:Ue,children:[(0,e.jsx)(Ls,{value:"all",children:"All sources"}),ue.map(w=>(0,e.jsx)(Ls,{value:w,children:Ys(w,null).label},w))]})})]}):null,(0,e.jsx)(y,{variant:"ghost",size:"icon-sm",onClick:n(()=>M(),"onClick"),disabled:Z,"aria-label":"Scan project workspaces for skills",title:"Scan project workspaces for skills",children:(0,e.jsx)(Ws,{className:K("h-4 w-4",Z&&"animate-spin")})}),(0,e.jsx)(y,{asChild:!0,variant:"outline",size:"sm",children:(0,e.jsxs)(pe,{to:"/skills/studio",children:[(0,e.jsx)(Bn,{className:"h-3.5 w-3.5"}),"Studio"]})}),(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{size:"sm",variant:"default",children:[(0,e.jsx)(yt,{className:"mr-1 h-3.5 w-3.5"}),"New",(0,e.jsx)(gs,{className:"ml-1 h-3.5 w-3.5"})]})}),(0,e.jsxs)(Es,{align:"end",children:[(0,e.jsxs)(Ze,{onSelect:X,children:[(0,e.jsx)(Nn,{className:"mr-2 h-4 w-4"}),"Create new skill"]}),(0,e.jsxs)(Ze,{onSelect:b,children:[(0,e.jsx)(ge,{className:"mr-2 h-4 w-4"}),"Browse catalog"]}),(0,e.jsx)(Ze,{asChild:!0,children:(0,e.jsxs)(pe,{to:"/skills/sources/new",children:[(0,e.jsx)(It,{className:"mr-2 h-4 w-4"}),"Import from GitHub"]})}),(0,e.jsx)(Ze,{asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources",children:"Manage sources"})}),(0,e.jsxs)(Ze,{onSelect:j,children:[(0,e.jsx)(Nr,{className:"mr-2 h-4 w-4"}),"Import from path or URL"]}),(0,e.jsxs)(Ze,{onSelect:L,children:[(0,e.jsx)(Lr,{className:"mr-2 h-4 w-4"}),"Import skills from project"]})]})]}),q&&de?(0,e.jsx)("div",{className:"w-full md:hidden",children:(0,e.jsx)(zr,{result:q,selection:O,allLabel:"All skills",onClick:qs??(()=>{})})}):null,Se&&!me?(0,e.jsxs)(y,{variant:"outline",size:"sm",onClick:Se,children:[(0,e.jsx)(yt,{className:"mr-1 h-3.5 w-3.5"}),"New folder"]}):null,je?(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:je,children:D?"Done":"Select"}):null]}),u.length>0?(0,e.jsx)("div",{className:"border-b border-border px-4 py-2 md:hidden",children:(0,e.jsxs)(Ps,{children:[(0,e.jsx)(Bs,{asChild:!0,children:(0,e.jsxs)(y,{variant:"outline",size:"sm",className:"w-full justify-between",children:[(0,e.jsx)("span",{className:"capitalize",children:r??"All categories"}),(0,e.jsx)(gs,{className:"h-3.5 w-3.5"})]})}),(0,e.jsx)(Es,{align:"start",className:"max-h-72 overflow-auto",children:(0,e.jsxs)(xt,{value:r??"__all__",onValueChange:n(w=>g(w==="__all__"?null:w),"onValueChange"),children:[(0,e.jsxs)(Ls,{value:"__all__",children:["All (",m,")"]}),u.map(w=>(0,e.jsxs)(Ls,{value:w.slug,className:"capitalize",children:[w.slug," (",w.count,")"]},w.slug))]})})]})}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-4",children:[(0,e.jsx)(Sn,{value:t,onValueChange:n(w=>a(w),"onValueChange"),children:(0,e.jsxs)(wn,{variant:"line",className:"p-0",children:[(0,e.jsxs)(Ts,{value:"all",className:"px-3",children:[(0,e.jsx)("span",{children:"All"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.all})]}),(0,e.jsxs)(Ts,{value:"installed",className:"px-3",children:[(0,e.jsx)("span",{children:"Installed"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.installed})]}),(0,e.jsxs)(Ts,{value:"catalog",className:"px-3",children:[(0,e.jsx)("span",{children:"Catalog"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.catalog})]}),(0,e.jsxs)(Ts,{value:"bundled",className:"px-3",children:[(0,e.jsx)("span",{children:"Bundled"}),(0,e.jsx)("span",{className:"ml-1.5 text-(length:--text-micro) text-muted-foreground",children:l.bundled})]})]})}),(0,e.jsx)(y,{variant:"ghost",size:"sm",asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources",children:"Sources"})})]}),(0,e.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:[fe?(0,e.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:fe}):null,me&&de?(0,e.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-2",children:[(0,e.jsx)(fa,{result:q,selection:O,onSelect:de}),ne&&ke?(0,e.jsxs)(y,{variant:"ghost",size:"sm",onClick:n(()=>M(ke),"onClick"),disabled:Z,"aria-label":`Refresh ${ne.name} project skills`,title:`Refresh skills from ${ne.name}`,children:[(0,e.jsx)(Ws,{className:K("h-3.5 w-3.5",Z&&"animate-spin")}),"Refresh"]}):null]}):null,J&&Se&&q&&q.folders.length===0&&!p&&I.length>0?(0,e.jsx)(Yr,{storageKey:J,itemLabelPlural:"skills",onCreateFolder:Se}):null,D&&Oe&&ts&&ns?(0,e.jsx)("div",{className:"mb-3",children:(0,e.jsx)(Xr,{selectedCount:W.length,folders:q?.folders??[],onMove:Oe,onCreateAndMove:ts,onClear:ns,onDone:je??ns})}):null,p?(0,e.jsx)(Be,{variant:"list"}):T?(0,e.jsx)("div",{className:"py-6 text-sm text-destructive",children:T}):Fe.length===0?(0,e.jsxs)("div",{className:"py-12",children:[(0,e.jsx)(es,{icon:Qr,message:$===0?"No skills yet. Create one or install from the catalog.":o||r||ye?"No skills match your filters.":"No skills in this tab yet."}),$===0?(0,e.jsxs)("div",{className:"mt-3 flex flex-col items-center gap-2",children:[(0,e.jsxs)(y,{size:"sm",onClick:b,children:[(0,e.jsx)(ge,{className:"mr-1.5 h-3.5 w-3.5"})," Browse catalog"]}),(0,e.jsx)(y,{size:"sm",variant:"outline",asChild:!0,children:(0,e.jsx)(pe,{to:"/skills/sources/new",children:"Import from GitHub"})}),(0,e.jsx)(y,{size:"sm",variant:"ghost",onClick:X,children:"Create a skill"})]}):o||r||ye?(0,e.jsx)("div",{className:"mt-3 flex justify-center",children:(0,e.jsx)(y,{size:"sm",variant:"ghost",onClick:n(()=>{x(""),g(null),Ue("all")},"onClick"),children:"Clear filters"})}):null]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("p",{className:"mb-3 text-xs text-muted-foreground",children:[Fe.length," ",Fe.length===1?"skill":"skills",r?(0,e.jsxs)("span",{className:"capitalize",children:[" · ",r]}):null]}),(0,e.jsx)("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(19rem,1fr))]",children:Fe.map(w=>(0,e.jsx)(Ua,{card:w,folders:q?.folders,selected:W.includes(w.skillId??""),selectMode:D,showFolderBadge:!!(q&&o.trim()),onOpen:k,onSelectChange:ie,onMove:ce,onCreateFolderAndMove:ve,onOpenMove:Ns},w.key))})]})]})]})]})}n(Qa,"DiscoveryGrid");function Ha({initialDraft:t,onCreate:l,isPending:a,error:u,onCancel:m}){const[r,g]=(0,c.useState)(0),[o,x]=(0,c.useState)(t),[N,v]=(0,c.useState)(t.slug.trim().length>0),I=o.categories.join(", "),k=["Basics","Design","Content","Review"];(0,c.useEffect)(()=>{g(0),x(t),v(t.slug.trim().length>0)},[t]);function p(j){x(L=>({...L,...j}))}n(p,"patchDraft");const T=o.name.trim().length>0,$=o.slug.trim()||gt(o.name);function X(){l(Gr(o))}return n(X,"submit"),(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsx)("div",{className:"flex items-center gap-2 border-b border-border pb-3",children:k.map((j,L)=>(0,e.jsx)("button",{type:"button",onClick:n(()=>g(L),"onClick"),className:K("rounded-md px-2 py-1 text-xs",r===L?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),children:j},j))}),o.forkedFromName?(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:[(0,e.jsx)(ks,{className:"h-3.5 w-3.5"}),"Forking ",o.forkedFromName]}):null,r===0?(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(qe,{value:o.name,onChange:n(j=>{const L=j.target.value;p({name:L,slug:N?o.slug:gt(L),markdown:o.markdown===Gs(o.name,o.tagline)?Gs(L,o.tagline):o.markdown})},"onChange"),placeholder:"Skill name",className:"h-9"}),(0,e.jsx)(qe,{value:o.slug,onChange:n(j=>{const L=gt(j.target.value);v(L.length>0),p({slug:L})},"onChange"),placeholder:"skill-shortname",className:"h-9 font-mono"}),(0,e.jsx)(jt,{value:o.tagline,onChange:n(j=>{const L=j.target.value;p({tagline:L,description:o.description?o.description:L,markdown:o.markdown===Gs(o.name,o.tagline)?Gs(o.name,L):o.markdown})},"onChange"),placeholder:"One-line promise for the skill",className:"min-h-20"})]}):r===1?(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)(Bt,{size:48,card:{key:$||o.name||"new-skill",name:o.name||"New Skill",slug:$||"skill",iconUrl:null,color:o.color}}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"truncate text-sm font-medium",children:o.name||"New Skill"}),(0,e.jsx)("div",{className:"truncate text-xs text-muted-foreground",children:o.tagline||"No tagline yet."})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-2 block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Color"}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[ma.map(j=>(0,e.jsx)("button",{type:"button",onClick:n(()=>p({color:j}),"onClick"),className:K("h-7 w-7 rounded-md border",o.color===j?"border-foreground":"border-border"),style:{backgroundColor:j},"aria-label":`Use ${j}`},j)),(0,e.jsx)(qe,{value:o.color,onChange:n(j=>p({color:j.target.value}),"onChange"),className:"h-7 w-28 font-mono text-xs"})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-2 block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)(qe,{value:I,onChange:n(j=>p({categories:Pn(j.target.value)}),"onChange"),placeholder:"engineering, review, memory",className:"h-9"})]})]}):r===2?(0,e.jsx)("div",{className:"space-y-2",children:(0,e.jsx)(jt,{value:o.markdown,onChange:n(j=>p({markdown:j.target.value}),"onChange"),className:"h-(--sz-calc-34) resize-y font-mono text-xs"})}):(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-26) gap-y-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Name"}),(0,e.jsx)("span",{children:o.name||"Untitled"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Slug"}),(0,e.jsx)("span",{className:"font-mono",children:$||"skill"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Scope"}),(0,e.jsx)("span",{children:o.sharingScope==="private"?"Private":"Company"}),(0,e.jsx)("span",{className:"text-muted-foreground",children:"Categories"}),(0,e.jsx)("span",{children:o.categories.length?o.categories.join(", "):"none"})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("label",{className:"block text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sharing"}),(0,e.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3",children:[["company","private"].map(j=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>p({sharingScope:j}),"onClick"),className:K("rounded-md border px-3 py-2 text-left text-sm",o.sharingScope===j?"border-foreground bg-accent/50":"border-border"),children:[(0,e.jsx)("span",{className:"block font-medium",children:j==="company"?"Company":"Private"}),(0,e.jsx)("span",{className:"mt-1 block text-xs text-muted-foreground",children:j==="company"?"Visible inside this company.":"Only visible in your library."})]},j)),(0,e.jsxs)("button",{type:"button",disabled:!0,className:"rounded-md border border-dashed border-border px-3 py-2 text-left text-sm text-muted-foreground",children:[(0,e.jsx)("span",{className:"block font-medium",children:"Public link"}),(0,e.jsx)("span",{className:"mt-1 block text-xs",children:"Coming later."})]})]})]})]}),u?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}):null,(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-border pt-3",children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:m,disabled:a,children:"Cancel"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>g(j=>Math.max(0,j-1)),"onClick"),disabled:a||r===0,children:"Back"}),r<k.length-1?(0,e.jsx)(y,{size:"sm",onClick:n(()=>g(j=>Math.min(k.length-1,j+1)),"onClick"),disabled:!T,children:"Next"}):(0,e.jsx)(y,{size:"sm",onClick:X,disabled:a||!T,children:a?"Creating...":o.forkedFromSkillId?"Create fork":"Create skill"})]})]})]})}n(Ha,"NewSkillWizard");function Ga({skill:t,packageName:l,packageVersion:a,installedSkill:u,installedSkillId:m,fileQuery:r,selectedPath:g,onInstall:o,onUpdate:x,onOpenInstalled:N,loadingPrimaryAction:v}){if(!t)return(0,e.jsx)(es,{icon:ge,message:"Select a catalog skill to inspect."});const I=u?.originHash??null,k=!!(u&&I&&I!==t.contentHash),p=!!u;let T;t.compatibility==="invalid"?T=(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)("span",{children:(0,e.jsxs)(y,{disabled:!0,children:[(0,e.jsx)(wt,{className:"mr-1.5 h-3.5 w-3.5"}),"Install skill"]})})}),(0,e.jsx)(ze,{children:"This skill cannot be installed — its content is not valid Agent Skills markdown."})]}):p?k?T=(0,e.jsxs)(y,{onClick:x,disabled:v,className:"border-amber-500/40 bg-amber-500/20 text-amber-900 dark:text-amber-100 hover:bg-amber-500/30",children:[(0,e.jsx)(St,{className:"mr-1.5 h-3.5 w-3.5"}),"Update from catalog"]}):T=(0,e.jsxs)(y,{variant:"ghost",onClick:n(()=>m&&N(m),"onClick"),children:[(0,e.jsx)(Cn,{className:"mr-1.5 h-3.5 w-3.5"}),"Installed · Open in library"]}):T=(0,e.jsxs)(y,{onClick:o,disabled:v,children:[t.trustLevel==="scripts_executables"?(0,e.jsx)(Dn,{className:"mr-1.5 h-3.5 w-3.5"}):(0,e.jsx)(wt,{className:"mr-1.5 h-3.5 w-3.5"}),v?"Preparing...":"Install skill in this organization"]});const $=r.data?.markdown?qn(r.data.content):r.data?.content??"";return(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"border-b border-border px-5 py-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("h1",{className:"flex items-center gap-2 truncate text-2xl font-semibold",children:[(0,e.jsx)(ge,{className:K("h-5 w-5 shrink-0 text-muted-foreground",t.kind==="optional"&&"opacity-70"),"aria-hidden":"true"}),t.name]}),(0,e.jsx)("p",{className:"mt-2 max-w-3xl text-sm text-muted-foreground",children:t.description}),(0,e.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"rounded border border-border bg-muted/40 px-1.5 py-0.5 uppercase tracking-wide",children:t.kind}),(0,e.jsx)("span",{children:"·"}),(0,e.jsx)("span",{children:t.category}),(0,e.jsx)("span",{children:"·"}),(0,e.jsx)(Ea,{packageName:l,packageVersion:a})]})]}),(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:T})]}),(0,e.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-2 border-t border-border pt-4",children:[(0,e.jsx)($n,{level:t.trustLevel}),(0,e.jsx)(zn,{compatibility:t.compatibility}),k?(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)(le,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-(length:--text-micro) text-amber-800 dark:text-amber-200",children:[(0,e.jsx)(St,{className:"h-3 w-3","aria-hidden":"true"}),"Update available"]})}),(0,e.jsx)(ze,{children:"Catalog content hash has changed since this skill was installed."})]}):null,t.requires.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Requires: ",t.requires.join(", ")]}):null,t.recommendedForRoles.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Roles: ",t.recommendedForRoles.join(" · ")]}):null,t.tags.length>0?(0,e.jsxs)(le,{variant:"outline",className:"border-border bg-muted/40 text-(length:--text-micro) text-muted-foreground",children:["Tags: ",t.tags.join(" · ")]}):null]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"Key"}),(0,e.jsx)("span",{className:"font-mono",children:t.key}),(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"·"}),(0,e.jsx)("span",{className:"uppercase tracking-(--tracking-caps)",children:"Hash"}),(0,e.jsxs)("span",{className:"font-mono",children:[t.contentHash.slice(0,24),"…"]}),(0,e.jsx)(_r,{text:t.contentHash,copiedLabel:"Copied hash",ariaLabel:"Copy content hash",title:"Copy content hash",className:"inline-flex h-6 w-6 items-center justify-center rounded-sm border border-border text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,e.jsx)(In,{className:"h-3 w-3"})})]})]}),(0,e.jsx)("div",{className:"border-b border-border px-5 py-3",children:(0,e.jsx)("div",{className:"truncate font-mono text-sm",children:g})}),(0,e.jsx)("div",{className:"min-h-(--sz-400px) px-5 py-5",children:r.isLoading?(0,e.jsx)(Be,{variant:"detail"}):r.error?(0,e.jsx)("div",{className:"text-sm text-destructive",children:r.error instanceof Error?r.error.message:"Failed to load file"}):r.data?r.data.markdown?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:$}):(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap wrap-break-word border-0 bg-transparent p-0 font-mono text-sm text-foreground",children:(0,e.jsx)("code",{children:r.data.content})}):(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a file to inspect."})})]})}n(Ga,"CatalogDetailPane");function Wa(t){return new Set(t.filter(l=>l.supportsSkills&&!l.required).map(l=>l.id))}n(Wa,"defaultInstallAgentSelection");function Ya({open:t,onOpenChange:l,skill:a,packageName:u,packageVersion:m,conflict:r,defaultSlug:g,defaultForce:o,defaultAction:x,agents:N,isPending:v,error:I,onConfirm:k}){const[p,T]=(0,c.useState)(""),[$,X]=(0,c.useState)(!1),[j,L]=(0,c.useState)(!1),[b,M]=(0,c.useState)(new Set),[Z,fe]=(0,c.useState)(!1),q=(0,c.useRef)(!1);if((0,c.useEffect)(()=>{t&&(T(g??""),X(o),L(x==="replace"||o))},[t,g,o,x]),(0,c.useEffect)(()=>{t&&!q.current&&fe(!1),q.current=t},[t]),(0,c.useEffect)(()=>{!t||Z||M(x==="install"?Wa(N):new Set)},[t,Z,x,N]),!a)return null;let O="Install skill",be="default";return x==="update"?O="Install update":x==="replace"&&(O="Replace existing skill",be="destructive"),v&&(O="Installing…"),(0,e.jsx)(vs,{open:t,onOpenChange:n(D=>v?null:l(D),"onOpenChange"),children:(0,e.jsxs)(bs,{className:"sm:max-w-2xl",showCloseButton:!v,children:[(0,e.jsxs)(js,{children:[(0,e.jsxs)(ys,{children:[x==="update"?"Update":x==="replace"?"Replace":"Install"," · ",a.name]}),(0,e.jsxs)(As,{children:[(0,e.jsx)("span",{className:"capitalize",children:a.kind})," · ",a.category,u?(0,e.jsxs)(e.Fragment,{children:[" · ",u,m?` v${m}`:""]}):null]})]}),(0,e.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,e.jsx)("div",{className:"rounded-md border border-border p-3",children:(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-26) gap-y-2 text-xs",children:[(0,e.jsx)("div",{className:"text-muted-foreground",children:"Trust"}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)($n,{level:a.trustLevel}),a.trustLevel==="markdown_only"?(0,e.jsx)("span",{className:"text-muted-foreground",children:"Safe"}):a.trustLevel==="scripts_executables"?(0,e.jsx)("span",{className:"text-amber-800 dark:text-amber-200",children:"Review required"}):(0,e.jsx)("span",{className:"text-muted-foreground",children:"Non-script assets"})]}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Compatibility"}),(0,e.jsx)("div",{className:"flex items-center gap-2",children:a.compatibility==="compatible"?(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 text-muted-foreground",children:[(0,e.jsx)(Cn,{className:"h-3 w-3","aria-hidden":"true"}),"Compatible"]}):(0,e.jsx)(zn,{compatibility:a.compatibility})}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Requires"}),(0,e.jsx)("div",{className:"text-foreground",children:a.requires.length===0?"none":a.requires.join(", ")}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Roles"}),(0,e.jsx)("div",{className:"text-foreground",children:a.recommendedForRoles.length===0?"any":a.recommendedForRoles.join(" · ")}),(0,e.jsx)("div",{className:"text-muted-foreground",children:"Provenance"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"truncate",children:[u??"—",m?` v${m}`:""]}),(0,e.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground",children:a.contentHash})]})]})}),(0,e.jsxs)("div",{className:"rounded-md border border-border",children:[(0,e.jsxs)("div",{className:"border-b border-border px-3 py-2 text-xs uppercase tracking-wide text-muted-foreground",children:["Files (",a.files.length,")"]}),(0,e.jsx)("div",{className:"max-h-48 overflow-y-auto",children:a.files.map(D=>(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-27) items-center gap-x-3 border-b border-border/50 px-3 py-1.5 text-xs last:border-b-0",children:[(0,e.jsx)("span",{className:"truncate font-mono text-muted-foreground",children:D.path}),(0,e.jsx)("span",{className:"rounded border border-border bg-muted/40 px-1 py-0.5 text-(length:--text-nano) uppercase text-muted-foreground",children:D.kind}),(0,e.jsx)("span",{className:"text-(length:--text-micro) text-muted-foreground",children:Ta(D.sizeBytes)})]},D.path))})]}),r?(0,e.jsxs)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-xs text-amber-800 dark:text-amber-200",children:["An existing skill with key ",(0,e.jsx)("span",{className:"font-mono",children:r.key})," is installed (",r.sourceLabel??r.sourceType,"). Installing will ",x==="update"?"overwrite the catalog content":"replace the existing skill","."]}):null,x==="install"?(0,e.jsxs)("div",{className:"rounded-md border border-border p-3",children:[(0,e.jsx)("div",{className:"mb-1 text-xs uppercase tracking-wide text-muted-foreground",children:"Enable for agents"}),(0,e.jsx)("p",{className:"mb-2 text-xs text-muted-foreground",children:"Installing adds the skill to the company library. Agents can only use it once it is enabled for them."}),(0,e.jsx)(Ln,{agents:N,selectedAgentIds:b,onChange:n(D=>{fe(!0),M(D)},"onChange"),showSelectionPreview:!1,emptyMessage:"No agents in this company support skills yet.",isAgentDisabled:n(D=>{const W=D;return W.required||!W.supportsSkills},"isAgentDisabled"),getDescription:n(D=>{const W=D;return`${W.adapterType}${W.required?" · required":""}${W.supportsSkills?"":" · skills not supported"}`},"getDescription")})]}):null,(0,e.jsxs)("button",{type:"button",onClick:n(()=>L(D=>!D),"onClick"),className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[j?(0,e.jsx)(gs,{className:"h-3 w-3"}):(0,e.jsx)(Fn,{className:"h-3 w-3"}),"Advanced"]}),j?(0,e.jsxs)("div",{className:"space-y-3 rounded-md border border-border p-3 text-xs",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"mb-1 block uppercase tracking-wide text-muted-foreground",children:"Slug override"}),(0,e.jsx)(qe,{value:p,onChange:n(D=>T(D.target.value),"onChange"),placeholder:g??a.slug,className:"h-8"})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(Ar,{checked:$,onCheckedChange:n(D=>X(!!D),"onCheckedChange")}),(0,e.jsx)("span",{children:"Force replace existing same-key skill"})]})]}):null,I?(0,e.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 p-3 text-xs text-destructive",children:I}):null]}),(0,e.jsxs)(vt,{children:[(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>l(!1),"onClick"),disabled:v,children:"Cancel"}),(0,e.jsx)(y,{variant:be,onClick:n(()=>k({slug:p.trim().length>0?p.trim():null,force:$,agentIds:x==="install"?Array.from(b):[]}),"onClick"),disabled:v,children:O})]})]})})}n(Ya,"InstallPreviewDialog");function vn({agents:t,attachedAgentIds:l,versions:a,selectedVersionId:u,pending:m,onSubmit:r,fullWidth:g=!1}){const[o,x]=(0,c.useState)(u),N=(0,c.useMemo)(()=>new Set(l),[l]),v=t.filter(k=>k.supportsSkills),I=[...a].sort((k,p)=>p.revisionNumber-k.revisionNumber);return(0,e.jsx)(Ln,{agents:t,selectedAgentIds:N,onSave:n(k=>r(Array.from(k),o),"onSave"),pending:m,triggerLabel:"Add to agent",triggerIcon:(0,e.jsx)(yt,{className:"mr-1.5 h-3.5 w-3.5"}),triggerVariant:"default",triggerSize:"sm",triggerFullWidth:g,triggerClassName:K(g&&"w-full"),contentAlign:"end",showSelectionPreview:!1,onOpenChange:n(k=>{k&&x(u)},"onOpenChange"),headerContent:I.length>0?(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs",children:[(0,e.jsx)("span",{className:"shrink-0 text-muted-foreground",children:"Version"}),(0,e.jsxs)("select",{value:o??"__latest__",onChange:n(k=>x(k.target.value==="__latest__"?null:k.target.value),"onChange"),className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs text-foreground",children:[(0,e.jsx)("option",{value:"__latest__",children:"Latest"}),I.map(k=>(0,e.jsxs)("option",{value:k.id,children:["v",k.revisionNumber,k.label?` · ${k.label}`:""]},k.id))]})]}):null,emptyMessage:v.length===0?"No agents in this company support skills yet.":"No agents yet.",isAgentDisabled:n(k=>{const p=k;return p.required||!p.supportsSkills},"isAgentDisabled"),getDescription:n(k=>{const p=k;return`${p.adapterType}${p.required?" · required":""}${p.supportsSkills?"":" · skills not supported"}`},"getDescription"),renderNameSuffix:n(k=>k.paused?(0,e.jsxs)(le,{variant:"outline",className:"[&>svg]:size-2.5 border-amber-500/30 bg-amber-500/10 px-1.5 text-(length:--text-nano) uppercase tracking-wide text-amber-500",children:[(0,e.jsx)(Nt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Paused"]}):null,"renderNameSuffix")})}n(vn,"AttachAgentsPopover");function Pt({nodes:t,skillId:l,selectedPath:a,expandedDirs:u,onToggleDir:m,onSelectPath:r,fileHref:g=n((x,N)=>Ms(x,N),"fileHref"),depth:o=0}){return(0,e.jsx)("div",{children:t.map(x=>{const N=x.kind==="dir"&&x.path?u.has(x.path):!1;if(x.kind==="dir")return(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:K("group grid w-full grid-cols-(--gtc-3) items-center gap-x-1 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",cn),children:[(0,e.jsxs)("button",{type:"button",className:"flex min-w-0 items-center gap-2 py-1 text-left",style:{paddingLeft:`${on+o*dn}px`},onClick:n(()=>x.path&&m(x.path),"onClick"),children:[(0,e.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:N?(0,e.jsx)(Dt,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Ft,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("span",{className:"truncate",children:x.name})]}),(0,e.jsx)("button",{type:"button",className:"flex h-9 w-9 items-center justify-center self-center rounded-sm text-muted-foreground opacity-70 transition-(--tp-background-color-color-opacity) hover:bg-accent hover:text-foreground group-hover:opacity-100",onClick:n(()=>x.path&&m(x.path),"onClick"),children:N?(0,e.jsx)(gs,{className:"h-3.5 w-3.5"}):(0,e.jsx)(Fn,{className:"h-3.5 w-3.5"})})]}),N&&(0,e.jsx)(Pt,{nodes:x.children,skillId:l,selectedPath:a,expandedDirs:u,onToggleDir:m,onSelectPath:r,fileHref:g,depth:o+1})]},x.path??x.name);const v=La(x.fileKind??"other");return(0,e.jsxs)(pe,{className:K("flex w-full items-center gap-2 pr-3 text-left text-sm text-muted-foreground hover:bg-accent/30 hover:text-foreground",cn,x.path===a&&"text-foreground"),style:{paddingInlineStart:`${on+o*dn}px`},to:g(l,x.path),onClick:n(()=>x.path&&r(x.path),"onClick"),children:[(0,e.jsx)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center",children:(0,e.jsx)(v,{className:"h-3.5 w-3.5"})}),(0,e.jsx)("span",{className:"truncate",children:x.name})]},x.path??x.name)})})}n(Pt,"SkillTree");var Xa=[{value:"overview",label:"Overview",icon:Lt},{value:"files",label:"Files",icon:Dt},{value:"versions",label:"Versions",icon:An},{value:"agents",label:"Agents",icon:ia}];function bt(t){return t?.usedByAgents.find(l=>l.versionId)?.versionId??null}n(bt,"currentVersionSelection");function Ks(t){return t?`v${t.revisionNumber}${t.label?` · ${t.label}`:""}`:"Latest"}n(Ks,"versionLabel");function Za(t,l){const a=[...t].sort((m,r)=>r.revisionNumber-m.revisionNumber),u=l?a.find(m=>m.id===l)??null:a[0]??null;return u?{leftVersionId:(a.find(m=>m.revisionNumber<u.revisionNumber)??null)?.id??null,rightVersionId:u.id}:{leftVersionId:null,rightVersionId:null}}n(Za,"getSkillVersionDiffSelection");function Ja({open:t,onOpenChange:l,versions:a,leftVersionId:u,rightVersionId:m,onLeftVersionChange:r,onRightVersionChange:g}){const o=[...a].sort((b,M)=>M.revisionNumber-b.revisionNumber),x=o.find(b=>b.id===u)??null,N=o.find(b=>b.id===m)??null,v=(0,c.useMemo)(()=>{const b=new Set;for(const M of x?.fileInventory??[])b.add(M.path);for(const M of N?.fileInventory??[])b.add(M.path);return Array.from(b).sort((M,Z)=>M==="SKILL.md"?-1:Z==="SKILL.md"?1:M.localeCompare(Z))},[x,N]),[I,k]=(0,c.useState)("SKILL.md"),p=v.includes(I)?I:v[0]??"SKILL.md",T=x?.fileInventory.find(b=>b.path===p),$=N?.fileInventory.find(b=>b.path===p),X=(0,c.useMemo)(()=>Ur(T?.content??"",$?.content??""),[T?.content,$?.content]),j={context:"bg-transparent",removed:"bg-red-500/10 text-red-900 dark:text-red-100",added:"bg-green-500/10 text-green-900 dark:text-green-100"},L={context:" ",removed:"-",added:"+"};return(0,c.useEffect)(()=>{t&&v.length>0&&!v.includes(I)&&k(v[0])},[v,t,I]),(0,e.jsx)(vs,{open:t,onOpenChange:l,children:(0,e.jsxs)(bs,{className:"flex max-h-(--sz-85vh) w-full !max-w-(--pct-90) flex-col overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[(0,e.jsx)(js,{className:"shrink-0",children:(0,e.jsx)(ys,{children:"Diff · skill files"})}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs",children:[(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(le,{variant:"outline",className:"border-red-500/30 bg-red-500/10 uppercase tracking-wider text-red-400",children:"Old"}),(0,e.jsxs)("select",{value:u??"",onChange:n(b=>r(b.target.value||null),"onChange"),className:"h-8 w-44 rounded-md border border-border bg-background px-2 text-xs",children:[(0,e.jsx)("option",{value:"",children:"Initial"}),o.map(b=>(0,e.jsx)("option",{value:b.id,children:Ks(b)},b.id))]})]}),(0,e.jsxs)("label",{className:"flex items-center gap-2",children:[(0,e.jsx)(le,{variant:"outline",className:"border-green-500/30 bg-green-500/10 uppercase tracking-wider text-green-400",children:"New"}),(0,e.jsx)("select",{value:N?.id??"",onChange:n(b=>g(b.target.value||null),"onChange"),className:"h-8 w-44 rounded-md border border-border bg-background px-2 text-xs",children:o.map(b=>(0,e.jsx)("option",{value:b.id,children:Ks(b)},b.id))})]})]})]}),(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3",children:[(0,e.jsx)("aside",{className:"hidden w-56 shrink-0 overflow-auto border-r border-border pr-3 md:block",children:v.map(b=>(0,e.jsxs)("button",{type:"button",onClick:n(()=>k(b),"onClick"),className:K("flex w-full items-center gap-2 px-2 py-1.5 text-left font-mono text-xs text-muted-foreground hover:bg-accent/40 hover:text-foreground",p===b&&"bg-accent/50 text-foreground"),children:[(0,e.jsx)(Lt,{className:"h-3.5 w-3.5 shrink-0"}),(0,e.jsx)("span",{className:"truncate",children:b})]},b))}),(0,e.jsx)("div",{className:"min-w-0 flex-1 overflow-auto rounded-md border border-border text-xs",children:N?x?.id===N.id?(0,e.jsx)("div",{className:"p-6 text-center text-sm text-muted-foreground",children:"Both sides are the same version."}):(0,e.jsxs)("div",{className:"font-mono text-xs leading-6",children:[(0,e.jsxs)("div",{className:"grid grid-cols-(--gtc-1) border-b border-border/60 bg-muted/30 px-3 py-2 text-(length:--text-micro) uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)("span",{children:"Old"}),(0,e.jsx)("span",{children:"New"}),(0,e.jsx)("span",{}),(0,e.jsx)("span",{children:p})]}),X.map((b,M)=>(0,e.jsxs)("div",{className:K("grid grid-cols-(--gtc-1) gap-0 border-b border-border/30 px-3",j[b.kind]),children:[(0,e.jsx)("span",{className:"select-none border-r border-border/30 pr-3 text-right text-muted-foreground",children:b.oldLineNumber??""}),(0,e.jsx)("span",{className:"select-none border-r border-border/30 px-3 text-right text-muted-foreground",children:b.newLineNumber??""}),(0,e.jsx)("span",{className:"select-none px-3 text-center text-muted-foreground",children:L[b.kind]}),(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-0 text-inherit",children:b.text.length>0?b.text:" "})]},`${b.kind}-${M}-${b.oldLineNumber??"x"}-${b.newLineNumber??"x"}`))]}):(0,e.jsx)("div",{className:"p-6 text-center text-sm text-muted-foreground",children:"Select a version to compare."})})]})]})})}n(Ja,"SkillVersionDiffDialog");function el({folderPath:t,onMove:l}){const{copied:a,failed:u,copy:m}=Vr(),r=t&&t.length>0?t:"Unfiled";return(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Location"}),(0,e.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-2.5 py-1.5",children:[(0,e.jsx)(Dt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:r,children:r})]}),(0,e.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,e.jsxs)(y,{size:"sm",variant:"outline",onClick:n(()=>{m(r)},"onClick"),children:[(0,e.jsx)(In,{className:"mr-1.5 h-3.5 w-3.5"}),a?"Copied":u?"Copy failed":"Copy path"]}),l?(0,e.jsxs)(y,{size:"sm",variant:"outline",onClick:l,children:[(0,e.jsx)(Tn,{className:"mr-1.5 h-3.5 w-3.5"}),"Move"]}):null]})]})}n(el,"SkillLocationCard");function sl({categories:t,pending:l,onSave:a}){const[u,m]=(0,c.useState)("");function r(g){const o=g.trim().toLowerCase();if(!o||t.includes(o)){m("");return}a([...t,o]),m("")}return n(r,"addTag"),(0,e.jsxs)("section",{children:[(0,e.jsxs)("div",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:[(0,e.jsx)(Ir,{className:"h-3 w-3"}),"Tags"]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[t.map(g=>(0,e.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-border bg-accent/40 px-2 py-0.5 text-xs text-foreground",children:[g,(0,e.jsx)("button",{type:"button","aria-label":`Remove tag ${g}`,disabled:l,onClick:n(()=>a(t.filter(o=>o!==g)),"onClick"),className:"text-muted-foreground hover:text-foreground disabled:opacity-50",children:(0,e.jsx)(Fr,{className:"h-3 w-3"})})]},g)),t.length===0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"No tags yet."}):null]}),(0,e.jsx)(qe,{value:u,onChange:n(g=>m(g.target.value),"onChange"),onKeyDown:n(g=>{g.key==="Enter"&&(g.preventDefault(),r(u))},"onKeyDown"),onBlur:n(()=>u.trim()&&r(u),"onBlur"),placeholder:"Add a tag…",disabled:l,className:"mt-2 h-8 text-sm"})]})}n(sl,"SkillTagsEditor");function tl({detail:t,folderDisplayPath:l,catalogSource:a,routeSkills:u,loading:m,activeTab:r,onTabChange:g,selectedPath:o,file:x,fileLoading:N,viewMode:v,editMode:I,draft:k,setViewMode:p,setEditMode:T,setDraft:$,onSave:X,savePending:j,versions:L,versionsLoading:b,attachAgents:M,onSubmitAttach:Z,attachPending:fe,expandedDirs:q,onToggleDir:O,onSelectPath:be,updateStatus:D,updateStatusLoading:W,onCheckUpdates:de,checkUpdatesPending:Se,onInstallUpdate:Pe,installUpdatePending:_e,onToggleStar:Ce,starPending:ss,onFork:je,onUpdateSettings:ie,updateSettingsPending:ce,onMoveToFolder:ve,onDelete:Oe,deletePending:ts,studioHref:ns}){const[qs,rs]=(0,c.useState)(!1),[as,Ns]=(0,c.useState)(!1),[J,U]=(0,c.useState)("company"),[Ue,ue]=(0,c.useState)(""),Fe=(0,c.useRef)(null),[ye,V]=(0,c.useState)(!1),[me,ne]=(0,c.useState)(!1);(0,c.useEffect)(()=>{const h=Fe.current;!h||ye||ne(h.scrollHeight-h.clientHeight>1)},[t?.description,t?.tagline,t?.id,ye]),(0,c.useEffect)(()=>{V(!1)},[t?.id]),(0,c.useEffect)(()=>{!t||as||(U(t.sharingScope==="public_link"?"company":t.sharingScope),ue(t.categories.join(", ")))},[t,as]);const ke=[...L].sort((h,P)=>P.revisionNumber-h.revisionNumber),[w,Ie]=(0,c.useState)(null),[Zs,ls]=(0,c.useState)(null);function Rs(h){const P=Za(ke,h);Ie(P.leftVersionId),ls(P.rightVersionId),rs(!!P.rightVersionId)}n(Rs,"openVersionDiff");const is=x?.content??"",ws=I&&!!x?.editable&&k!==is;if((0,c.useEffect)(()=>{if(!ws)return;const h=n(P=>{P.preventDefault(),P.returnValue=""},"handler");return window.addEventListener("beforeunload",h),()=>window.removeEventListener("beforeunload",h)},[ws]),!t)return m?(0,e.jsx)(Be,{variant:"detail"}):(0,e.jsx)(es,{icon:ge,message:"Skill not found."});const C=t,Js=ns??Kn(C.id),re=Ys(C.sourceBadge,C.sourceLabel),os=re.icon,Ve=x?.markdown?qn(x.content):x?.content??"",et=Xs(C.sourceRef),ds=Xs(D?.latestRef),Qe=L.find(h=>h.id===bt(C))??null,cs=En(C)??re.label,$s=Pn(Ue),zs=fn($s)!==fn(C.categories),Ee=J!==(C.sharingScope==="public_link"?"company":C.sharingScope),He=zs||Ee,Ss=new Map(M.map(h=>[h.id,h])),A=a&&a.type==="github"?a:null,Cs=A?A.hostname==="github.com"?"GitHub":A.hostname:null,Te=A?`${A.owner}/${A.repo}${A.path?`/${A.path}`:""}`:null,_s=A?A.url??`https://${A.hostname}/${A.owner}/${A.repo}/tree/${A.ref}/${A.path}`.replace(/\/$/,""):null,ee=C.sourcePath||C.sourceLocator||null,us=C.homepageUrl??(ee&&/^(https?:\/\/|[\w.-]+\.[a-z]{2,}\/)/i.test(ee)?ee.startsWith("http")?ee:`https://${ee}`:null);function se(){return(0,e.jsxs)("div",{className:"grid min-h-(--sz-560px) gap-0 lg:grid-cols-(--gtc-28)",children:[(0,e.jsxs)("aside",{className:"border-b border-border pb-3 lg:border-b-0 lg:border-r lg:pb-0 lg:pr-3",children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Files"}),(0,e.jsx)(Pt,{nodes:Rn(C.fileInventory),skillId:C.id,selectedPath:o,expandedDirs:q,onToggleDir:O,onSelectPath:be,fileHref:n((h,P)=>Ms(C,u??[C],P),"fileHref")})]}),(0,e.jsxs)("section",{className:"min-w-0 lg:pl-5",children:[(0,e.jsxs)("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-3 border-b border-border pb-3",children:[(0,e.jsx)("div",{className:"min-w-0 truncate font-mono text-sm",children:x?.path??o}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[x?.markdown&&!I?(0,e.jsxs)("div",{className:"flex items-center border border-border",children:[(0,e.jsx)("button",{className:K("px-3 py-1.5 text-sm",v==="preview"?"text-foreground":"text-muted-foreground"),onClick:n(()=>p("preview"),"onClick"),children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Br,{className:"h-3.5 w-3.5"})," View"]})}),(0,e.jsx)("button",{className:K("border-l border-border px-3 py-1.5 text-sm",v==="code"?"text-foreground":"text-muted-foreground"),onClick:n(()=>p("code"),"onClick"),children:(0,e.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Fa,{className:"h-3.5 w-3.5"})," Code"]})})]}):null,C.editable&&x?.editable?I?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>T(!1),"onClick"),disabled:j,children:"Cancel"}),(0,e.jsxs)(y,{size:"sm",onClick:X,disabled:j,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Saving...":"Save"]})]}):(0,e.jsxs)(y,{variant:"ghost",size:"sm",onClick:n(()=>T(!0),"onClick"),children:[(0,e.jsx)(Nn,{className:"mr-1.5 h-3.5 w-3.5"})," Edit"]}):C.editable?null:(0,e.jsxs)(y,{type:"button",variant:"outline",size:"sm",onClick:je,title:C.editableReason??"Fork this skill to edit it.",children:[(0,e.jsx)(ks,{className:"mr-1.5 h-3.5 w-3.5"}),C.sourceType==="github"?"Make a copy":"Fork"]})]})]}),N?(0,e.jsx)(Be,{variant:"detail"}):x?x.encoding==="base64"?(0,e.jsx)(Ca,{file:x}):I&&x.editable?x.markdown?(0,e.jsx)(Dr,{value:k,onChange:$,bordered:!1,className:"min-h-(--sz-520px)"}):(0,e.jsx)(jt,{value:k,onChange:n(h=>$(h.target.value),"onChange"),className:"min-h-(--sz-520px) rounded-none border-0 bg-transparent px-0 py-0 font-mono text-sm shadow-none focus-visible:ring-0"}):x.markdown&&v==="preview"?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:Ve}):(0,e.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap wrap-break-word border-0 bg-transparent p-0 font-mono text-sm text-foreground",children:(0,e.jsx)("code",{children:x.content})}):(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:"Select a file to inspect."})]})]})}n(se,"renderFilesBody");function Ae(){return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsxs)("section",{children:[(0,e.jsx)("h2",{className:"mb-2 text-sm font-medium",children:"About"}),N?(0,e.jsx)(Be,{variant:"detail"}):x?.markdown?(0,e.jsx)(kt,{softBreaks:!1,linkIssueReferences:!1,children:Ve||C.description||"No overview yet."}):(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:C.description??"No overview yet."})]}),(0,e.jsxs)("section",{className:"grid min-w-0 gap-3 text-sm sm:grid-cols-2",children:[(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Key"}),(0,e.jsx)("div",{className:"mt-1 truncate font-mono",children:C.key})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Source"}),(0,e.jsx)("div",{className:"mt-1 min-w-0 [overflow-wrap:anywhere]",children:ee??re.label})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Version"}),(0,e.jsx)("div",{className:"mt-1",children:Ks(C.currentVersion??null)})]}),(0,e.jsxs)("div",{className:"min-w-0 border-b border-border py-2",children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Mode"}),(0,e.jsx)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:C.editable?"Editable":(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{children:"Read only"}),(0,e.jsxs)(y,{type:"button",variant:"outline",size:"xs",onClick:je,children:[(0,e.jsx)(ks,{className:"mr-1 h-3 w-3"}),C.sourceType==="github"?"Make a copy":"Fork"]})]})})]})]})]})}n(Ae,"renderOverviewBody");function Q(){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsx)("div",{className:"text-sm text-muted-foreground",children:b?"Loading versions...":`${L.length} ${L.length===1?"version":"versions"}`}),(0,e.jsxs)(y,{type:"button",variant:"outline",size:"sm",onClick:n(()=>Rs(),"onClick"),disabled:ke.length<2,children:[(0,e.jsx)(An,{className:"mr-1.5 h-3.5 w-3.5"})," Compare"]})]}),(0,e.jsx)("div",{className:"border-y border-border",children:b?(0,e.jsx)(Be,{variant:"list"}):ke.length===0?(0,e.jsx)("div",{className:"py-6 text-sm text-muted-foreground",children:"No saved versions yet."}):ke.map(h=>(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border px-0 py-3 text-sm last:border-b-0 sm:grid-cols-(--gtc-13)",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"font-medium",children:Ks(h)}),(0,e.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[fr(h.createdAt)," · ",h.fileInventory.length," files"]})]}),(0,e.jsx)(y,{type:"button",variant:"ghost",size:"sm",onClick:n(()=>Rs(h.id),"onClick"),children:"View diff"})]},h.id))}),(0,e.jsx)(Ja,{open:qs,onOpenChange:rs,versions:ke,leftVersionId:w,rightVersionId:Zs,onLeftVersionChange:Ie,onRightVersionChange:ls})]})}n(Q,"renderVersionsBody");function st(){const h=C.usedByAgents;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:[h.length," ",h.length===1?"agent":"agents"," attached",Qe?` · ${Ks(Qe)}`:" · Latest"]}),(0,e.jsx)(vn,{agents:M,attachedAgentIds:h.map(P=>P.id),versions:L,selectedVersionId:bt(C),pending:fe,onSubmit:Z})]}),h.length===0?(0,e.jsx)("div",{className:"rounded-md border border-dashed border-border py-8 text-center text-sm text-muted-foreground",children:"No agents are using this skill yet. Use “Add to agent” to attach it."}):(0,e.jsx)("div",{className:"border-y border-border",children:h.map(P=>{const ae=Ss.get(P.id);return(0,e.jsxs)("div",{className:"flex items-center gap-3 border-b border-border py-3 text-sm last:border-b-0",children:[(0,e.jsx)(rn,{agent:ae,size:16,className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)("span",{className:"truncate font-medium",children:P.name}),ae?.paused?(0,e.jsxs)(le,{variant:"outline",className:"[&>svg]:size-2.5 border-amber-500/30 bg-amber-500/10 px-1.5 text-(length:--text-nano) uppercase tracking-wide text-amber-500",children:[(0,e.jsx)(Nt,{className:"h-2.5 w-2.5","aria-hidden":"true"}),"Paused"]}):null]}),(0,e.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:P.adapterType})]}),(0,e.jsx)(pe,{to:`/agents/${P.urlKey}/skills`,className:"shrink-0 text-xs text-muted-foreground no-underline hover:text-foreground",children:"View"})]},P.id)})})]})}n(st,"renderAgentsBody");const tt=r==="files"?se():r==="versions"?Q():r==="agents"?st():Ae();return(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsx)("div",{className:"border-b border-border px-4 py-5",children:(0,e.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,e.jsx)(Bt,{card:{key:t.key,name:t.name,slug:t.slug,iconUrl:t.iconUrl,color:t.color},size:44}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)("h1",{className:"truncate text-2xl font-semibold",children:t.name}),(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground","aria-label":`Installed from ${re.label}`,children:(0,e.jsx)(os,{className:"h-4 w-4"})})}),(0,e.jsxs)(ze,{children:["Installed from ",re.label]})]})]}),t.authorName?(0,e.jsxs)("p",{className:"mt-0.5 text-sm text-muted-foreground",children:["by ",(0,e.jsx)("span",{className:"text-foreground",children:t.authorName})]}):null,cs?(0,e.jsxs)("div",{className:"mt-1 max-w-2xl",children:[(0,e.jsx)("p",{ref:Fe,className:K("text-sm text-muted-foreground",!ye&&"line-clamp-4"),children:cs}),me?(0,e.jsx)("button",{type:"button",onClick:n(()=>V(h=>!h),"onClick"),className:"mt-0.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:ye?"Show less":"View all"}):null]}):null]})]}),(0,e.jsx)("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:t.categories.slice(0,4).map(h=>(0,e.jsx)(_n,{label:h},h))})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-1",children:[(0,e.jsx)(y,{variant:"outline",size:"sm",asChild:!0,children:(0,e.jsxs)(pe,{to:Js,children:[(0,e.jsx)(Bn,{className:"mr-1.5 h-3.5 w-3.5"}),"Open in Studio"]})}),(0,e.jsxs)("div",{className:"flex items-center overflow-hidden rounded-md border border-border",children:[(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-muted-foreground",children:[(0,e.jsx)(wt,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.attachedAgentCount}),(0,e.jsx)("span",{className:"hidden sm:inline",children:t.attachedAgentCount===1?"install":"installs"})]})}),(0,e.jsx)(ze,{children:"Agents in this company that currently have this skill installed."})]}),(0,e.jsxs)("button",{type:"button",onClick:Ce,disabled:ss,className:"inline-flex items-center gap-1.5 border-l border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground disabled:opacity-50",title:t.starredByCurrentActor?"Unstar this skill":"Star this skill",children:[(0,e.jsx)(kn,{className:K("h-3.5 w-3.5",t.starredByCurrentActor&&"fill-current text-yellow-400")}),(0,e.jsx)("span",{className:"hidden sm:inline",children:t.starredByCurrentActor?"Starred":"Star"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.starCount})]}),(0,e.jsxs)("button",{type:"button",onClick:je,className:"inline-flex items-center gap-1.5 border-l border-border px-2.5 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground",title:"Fork this skill",children:[(0,e.jsx)(ks,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:C.sourceType==="github"?"Make a copy":"Fork"}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:t.forkCount})]})]})]})]})}),(0,e.jsxs)("div",{className:"grid gap-6 px-4 py-4 xl:grid-cols-(--gtc-29)",children:[(0,e.jsxs)("main",{className:"min-w-0",children:[(0,e.jsx)(Sn,{value:r,onValueChange:n(h=>g(h),"onValueChange"),children:(0,e.jsx)(wn,{variant:"line",className:"mb-5 w-full max-w-full justify-start overflow-x-auto border-b border-border p-0 pb-1.5 [scrollbar-width:none]",children:Xa.map(h=>{const P=h.icon;return(0,e.jsxs)(Ts,{value:h.value,className:"px-3",children:[(0,e.jsx)(P,{className:"mr-1.5 h-3.5 w-3.5"}),h.label]},h.value)})})}),tt]}),(0,e.jsxs)("aside",{className:"min-w-0 space-y-6 border-t border-border pt-4 xl:border-l xl:border-t-0 xl:pl-5 xl:pt-0",children:[(0,e.jsx)(Na,{skill:t}),(0,e.jsx)(el,{folderPath:l??Mn(t.folderPath),onMove:ve}),(0,e.jsx)(sl,{categories:t.categories,pending:ce,onSave:n(h=>ie({categories:h,sharingScope:t.sharingScope==="public_link"?"company":t.sharingScope}),"onSave")}),(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Agents"}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(vn,{agents:M,attachedAgentIds:t.usedByAgents.map(h=>h.id),versions:L,selectedVersionId:bt(t),pending:fe,onSubmit:Z,fullWidth:!0}),t.usedByAgents.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"No agents attached yet."}):(0,e.jsxs)("div",{className:"space-y-0.5",children:[t.usedByAgents.slice(0,3).map(h=>{const P=Ss.get(h.id);return(0,e.jsxs)(pe,{to:`/agents/${h.urlKey}/skills`,className:"flex items-center gap-2 rounded-md px-1.5 py-1 text-sm no-underline hover:bg-accent/40",children:[(0,e.jsx)(rn,{agent:P,size:16,className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,e.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:h.name}),P?.paused?(0,e.jsx)(Nt,{className:"h-3 w-3 shrink-0 text-amber-500","aria-label":"Paused"}):null]},h.id)}),t.usedByAgents.length>3?(0,e.jsxs)("p",{className:"px-1.5 pt-0.5 text-xs text-muted-foreground",children:["and ",t.usedByAgents.length-3," more"]}):null]})]})]}),(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Source"}),A?(0,e.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,e.jsx)(It,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-foreground",children:Cs}),(0,e.jsxs)("a",{href:_s??void 0,target:"_blank",rel:"noreferrer",title:Te??void 0,className:"mt-0.5 flex max-w-full items-start gap-1 text-xs text-muted-foreground no-underline transition-colors [overflow-wrap:anywhere] hover:text-foreground",children:[(0,e.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:Te}),(0,e.jsx)(fs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]}),(0,e.jsxs)("div",{className:"mt-0.5 truncate font-mono text-(length:--text-micro) text-muted-foreground",title:A.commit,children:[A.ref,A.commit?` · ${A.commit.slice(0,7)}`:""]})]})]}):(0,e.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,e.jsx)(os,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"text-foreground",children:re.label}),ee?us?(0,e.jsxs)("a",{href:us,target:"_blank",rel:"noreferrer",title:ee??void 0,className:"mt-0.5 flex max-w-full items-start gap-1 text-xs text-muted-foreground no-underline transition-colors [overflow-wrap:anywhere] hover:text-foreground",children:[(0,e.jsx)("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:ee}),(0,e.jsx)(fs,{className:"h-3 w-3 shrink-0","aria-hidden":"true"})]}):(0,e.jsx)("div",{className:"mt-0.5 min-w-0 text-xs text-muted-foreground [overflow-wrap:anywhere]",title:ee??void 0,children:ee}):(0,e.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:re.managedLabel})]})]})]}),t.sourceType==="github"?(0,e.jsxs)("section",{children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Updates"}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,e.jsxs)(Re,{children:[(0,e.jsx)($e,{asChild:!0,children:(0,e.jsx)(Sa,{className:"h-3.5 w-3.5 shrink-0","aria-label":"Pinned source revision"})}),(0,e.jsx)(ze,{children:"Pinned source revision"})]}),(0,e.jsx)("span",{className:"truncate font-mono text-foreground",children:et??"untracked"})]}),(0,e.jsxs)(y,{variant:"outline",size:"sm",className:"w-full",onClick:de,disabled:Se||W,children:[(0,e.jsx)(Ws,{className:K("mr-1.5 h-3.5 w-3.5",(Se||W)&&"animate-spin")}),"Check for updates"]}),D?.supported&&D.hasUpdate?(0,e.jsxs)(y,{size:"sm",className:"w-full",onClick:Pe,disabled:_e,children:[(0,e.jsx)(St,{className:K("mr-1.5 h-3.5 w-3.5",_e&&"animate-spin")}),"Install update",ds?` ${ds}`:""]}):D?.supported&&!D.hasUpdate&&!W?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Up to date."}):null]})]}):null,(0,e.jsx)("section",{children:(0,e.jsxs)("button",{type:"button",onClick:n(()=>{U(t.sharingScope==="public_link"?"company":t.sharingScope),ue(t.categories.join(", ")),Ns(!0)},"onClick"),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-accent/30 hover:text-foreground",children:[(0,e.jsx)(ea,{className:"h-4 w-4 shrink-0"}),(0,e.jsx)("span",{className:"flex-1",children:"Settings"})]})})]})]}),ws?(0,e.jsxs)("div",{className:"fixed bottom-6 left-1/2 z-40 flex -translate-x-1/2 items-center gap-3 rounded-full border border-border bg-background/95 px-4 py-2 shadow-lg backdrop-blur",children:[(0,e.jsx)("span",{className:"text-sm text-muted-foreground",children:"Unsaved changes"}),(0,e.jsx)(y,{variant:"ghost",size:"sm",onClick:n(()=>{$(is),T(!1)},"onClick"),disabled:j,children:"Discard"}),(0,e.jsxs)(y,{size:"sm",onClick:X,disabled:j,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),j?"Saving…":"Save changes"]})]}):null,(0,e.jsx)(vs,{open:as,onOpenChange:Ns,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Skill settings"}),(0,e.jsxs)(As,{children:["Manage how ",t.name," is grouped and shared."]})]}),(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Categories"}),(0,e.jsx)(qe,{value:Ue,onChange:n(h=>ue(h.target.value),"onChange"),placeholder:"engineering, review, memory",className:"h-9",disabled:ce}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Separate categories with commas. Leave empty to clear categories."})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Sharing"}),(0,e.jsxs)("select",{value:J,onChange:n(h=>U(h.target.value),"onChange"),disabled:ce,className:"h-9 w-full rounded-md border border-border bg-background px-2 text-sm text-foreground",children:[(0,e.jsx)("option",{value:"company",children:"Company — visible inside this company"}),(0,e.jsx)("option",{value:"private",children:"Private — only visible in your library"})]}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Public link sharing is coming later."})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-2 border-t border-border pt-4",children:[(0,e.jsx)(y,{type:"button",variant:"ghost",size:"sm",onClick:n(()=>{U(C.sharingScope==="public_link"?"company":C.sharingScope),ue(C.categories.join(", "))},"onClick"),disabled:!He||ce,children:"Reset"}),(0,e.jsxs)(y,{type:"button",size:"sm",onClick:n(()=>ie({sharingScope:J,categories:$s}),"onClick"),disabled:!He||ce,children:[(0,e.jsx)(ht,{className:"mr-1.5 h-3.5 w-3.5"}),ce?"Saving…":"Save settings"]})]}),t.editable?(0,e.jsxs)("div",{className:"rounded-md border border-destructive/40 p-3",children:[(0,e.jsx)("div",{className:"text-xs font-semibold uppercase tracking-wide text-destructive",children:"Danger zone"}),(0,e.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-3",children:[(0,e.jsx)("p",{className:"min-w-0 text-xs text-muted-foreground",children:"Remove this skill from the company library."}),(0,e.jsxs)(y,{variant:"destructive",size:"sm",className:"shrink-0",onClick:Oe,disabled:ts,title:t.usedByAgents.length>0?"Detach this skill from all agents before removing it.":void 0,children:[(0,e.jsx)(Tr,{className:"mr-1.5 h-3.5 w-3.5"}),ts?"Removing…":"Remove"]})]})]}):null]})]})})]})}n(tl,"SkillDetailPage");function El(){const{"*":t}=kr(),l=Cr(),a=yr(),[u,m]=Sr(),{selectedCompanyId:r}=vr(),{setBreadcrumbs:g}=qr(),{pushToast:o}=pa(),x=Kr(),N=Zr(),v=n((s,i,d,F)=>{N.capture(s,F)||o({tone:"error",title:i,body:s instanceof Error&&s.message?s.message:d})},"reportSkillError"),[I,k]=(0,c.useState)(""),[p,T]=(0,c.useState)(""),[$,X]=(0,c.useState)(!1),[j,L]=(0,c.useState)(null),[b,M]=(0,c.useState)({}),[Z,fe]=(0,c.useState)("preview"),[q,O]=(0,c.useState)(!1),[be,D]=(0,c.useState)(""),[W,de]=(0,c.useState)(null),[Se,Pe]=(0,c.useState)(null),[_e,Ce]=(0,c.useState)(null),[ss,je]=(0,c.useState)(!1),[ie,ce]=(0,c.useState)(null),[ve,Oe]=(0,c.useState)(null),[ts,ns]=(0,c.useState)(""),[qs,rs]=(0,c.useState)("all"),[as,Ns]=(0,c.useState)(""),[J,U]=(0,c.useState)("SKILL.md"),[Ue,ue]=(0,c.useState)(null),[Fe,ye]=(0,c.useState)({}),[V,me]=(0,c.useState)({open:!1,catalogSkill:null,conflict:null,defaultSlug:null,defaultForce:!1,defaultAction:"install",error:null}),[ne,ke]=(0,c.useState)(""),[w,Ie]=(0,c.useState)("agents"),[Zs,ls]=(0,c.useState)(null),[Rs,is]=(0,c.useState)(!1),[ws,C]=(0,c.useState)(!1),[Js,re]=(0,c.useState)(!1),[os,Ve]=(0,c.useState)(null),[et,ds]=(0,c.useState)(null),[Qe,cs]=(0,c.useState)(null),[$s,zs]=(0,c.useState)(!1),[Ee,He]=(0,c.useState)(null),[Ss,A]=(0,c.useState)(!1),[Cs,Te]=(0,c.useState)([]),[_s,ee]=(0,c.useState)([]),us=(0,c.useMemo)(()=>ya(t),[t]),se=t==="studio/new",Ae=se?null:us.skillToken,Q=us.filePath,st=u.get("view")==="catalog"?"catalog":"installed",tt=u.get("source")??"all";["all","company","bundled","optional","external"].includes(tt);const h=u.get("catalog"),P=u.get("tab"),ae=Ma(P),On=["overview","files","versions","agents"].includes(P)?P:us.hasExplicitFilePath||Q!=="SKILL.md"?"files":"overview",Ge=u.get("category"),oe=se&&u.get("forkFrom")?.trim()||null,nt=se&&u.get("folderId")?.trim()||null,rt=!se&&!Ae&&!h,G=ba(u.get("folder"));function Et(s){m(i=>Ka(i,s))}n(Et,"setDiscoveryTab");function ms(s){m(i=>{const d=new URLSearchParams(i);d.set("tab","installed"),d.delete("category");const F=Jr(s);return F?d.set("folder",F):d.delete("folder"),d})}n(ms,"setFolderSelection");function xs(s=[],i=null){ee(s),Ve(null),ds(i),re(!0)}n(xs,"openCreateFolder");function Tt(s){m(i=>{const d=new URLSearchParams(i);return s==="overview"?d.delete("tab"):d.set("tab",s),d})}n(Tt,"setDetailTab");function Un(s){m(i=>{const d=new URLSearchParams(i);return s?d.set("category",s):d.delete("category"),d})}n(Un,"setDiscoveryCategory");function Vn(s,i="SKILL.md"){m(d=>{const F=new URLSearchParams(d);return s?F.set("catalog",s):F.delete("catalog"),F}),U(i)}n(Vn,"selectCatalog"),(0,c.useEffect)(()=>{se&&ls(null)},[se,oe]),(0,c.useEffect)(()=>{u.has("view")&&m(s=>{const i=new URLSearchParams(s);return i.delete("view"),i},{replace:!0})},[u,m]);const We=xe({queryKey:f.companySkills.list(r??""),queryFn:n(()=>_.list(r),"queryFn"),enabled:!!r}),Ne=xe({queryKey:f.folders.list(r??"","skill"),queryFn:n(()=>he.list(r,"skill"),"queryFn"),enabled:!!(r&&(rt&&ae==="installed"||Ae))}),te=We.data??[],Fs=(0,c.useMemo)(()=>na(Ae,te),[Ae,te]),S=Fs.skill?.id??null,hs=xe({queryKey:f.companySkills.detail(r??"",S??""),queryFn:n(()=>_.detail(r,S),"queryFn"),enabled:!!(r&&S)}),Me=xe({queryKey:f.companySkills.file(r??"",S??"",Q),queryFn:n(()=>_.file(r,S,Q),"queryFn"),enabled:!!(r&&S&&Q)}),At=xe({queryKey:f.companySkills.versions(r??"",S??""),queryFn:n(()=>_.versions(r,S),"queryFn"),enabled:!!(r&&S)}),Ye=xe({queryKey:f.companySkills.detail(r??"",oe??""),queryFn:n(()=>_.detail(r,oe),"queryFn"),enabled:!!(r&&se&&oe)}),Qn=(0,c.useMemo)(()=>{if(!se)return pt();const s=oe?Ye.data?ua(Ye.data):pt():pt();return nt?{...s,folderId:nt}:s},[se,Ye.data,oe,nt]),Hn=(0,c.useMemo)(()=>{if(G==="all"||G==="unfiled")return null;const s=Je(Ne.data).byId.get(G);return!s||s.path==="bundled"||s.path.startsWith("bundled/")||s.path==="projects"||s.path.startsWith("projects/")?null:s.id},[G,Ne.data]),Os=xe({queryKey:f.companySkills.updateStatus(r??"",S??""),queryFn:n(()=>_.updateStatus(r,S),"queryFn"),enabled:!!(r&&S&&(hs.data?.sourceType==="github"||W?.sourceType==="github")),staleTime:6e4});(0,c.useEffect)(()=>{if(!Fs.skill||!Fs.shouldRedirect||We.isLoading)return;const s=u.toString();l({pathname:Ms(Fs.skill,te,Q),search:s?`?${s}`:""},{replace:!0})},[te,l,Fs,u,Q,We.isLoading]),(0,c.useEffect)(()=>{L(S)},[S]),(0,c.useEffect)(()=>{if(!S||Q==="SKILL.md")return;const s=mn(Q);s.length!==0&&M(i=>{const d=new Set(i[S]??[]);let F=!1;for(const E of s)d.has(E)||(d.add(E),F=!0);return F?{...i,[S]:d}:i})},[Q,S]),(0,c.useEffect)(()=>{O(!1)},[S,Q]),(0,c.useEffect)(()=>{hs.data&&de(hs.data)},[hs.data]),(0,c.useEffect)(()=>{Me.data&&(Pe(Me.data),D(Me.data.markdown?Ct(Me.data.content).body:Me.data.content))},[Me.data]),(0,c.useEffect)(()=>{S||(de(null),Pe(null))},[S]);const B=hs.data??W;(0,c.useEffect)(()=>{g([{label:"Skills",href:"/skills"},...se?[{label:oe?"Fork skill":"New skill"}]:B?qa(B,Ne.data).slice(1):Ae?[{label:"Detail"}]:[]])},[B,se,Ae,g,Ne.data,oe]);const Us=Me.data??Se;function ps(s,i){return Ms(s,oa(te,s),i)}n(ps,"routeForSkill");function at(s,i){const d=te.find(F=>F.id===s)??(B?.id===s?B:null);return d?ps(d,i):Ms(s,i)}n(at,"routeForSkillId");function Gn(){ce(S),Oe(B??null),je(!0)}n(Gn,"openDeleteDialog");function Vs(s){je(s),s||(ce(null),Oe(null))}n(Vs,"closeDeleteDialog");const lt=Y({mutationFn:n(s=>_.importFromSource(r,s),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.companySkills.list(r)}),s.imported[0]&&l(ps(s.imported[0])),o({tone:"success",title:"Skills imported",body:`${s.imported.length} skill${s.imported.length===1?"":"s"} added.`}),s.warnings[0]&&o({tone:"warn",title:"Import warnings",body:s.warnings[0]}),T("")},"onSuccess"),onError:n(s=>{v(s,"Skill import failed","Failed to import skill source.","Importing skills")},"onError")}),Mt=Y({mutationFn:n(s=>_.scanProjects(r,s?{projectIds:[s]}:{}),"mutationFn"),onMutate:n(s=>{Ce(s?"Refreshing project skills...":"Scanning project workspaces for skills...")},"onMutate"),onSuccess:n(async s=>{Ce("Refreshing skills list..."),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]);const i=Da(s);Ce(i),o({tone:"success",title:"Project skill scan complete",body:i}),s.conflicts[0]?o({tone:"warn",title:"Skill conflicts found",body:s.conflicts[0].reason}):s.warnings[0]&&o({tone:"warn",title:"Scan warnings",body:s.warnings[0]})},"onSuccess"),onError:n(s=>{Ce(null),v(s,"Project skill scan failed","Failed to scan project workspaces.","Scanning projects for skills")},"onError")}),Kt=Y({mutationFn:n(s=>_.create(r,s),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.companySkills.list(r)}),l(ps(s)),ls(null),o({tone:"success",title:s.forkedFromSkillId?"Skill fork created":"Skill created",body:`${s.name} is now editable in the Paperclip workspace.`})},"onSuccess"),onError:n(s=>{const i=s instanceof Error?s.message:"Failed to create skill.";ls(i),v(s,"Skill creation failed","Failed to create skill.","Creating a skill")},"onError")}),qt=Y({mutationFn:n(()=>_.updateFile(r,S,Q,Us?.markdown?Ia(Us.content,be):be),"mutationFn"),onSuccess:n(async s=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S)}),a.invalidateQueries({queryKey:f.companySkills.file(r,S,Q)})]),D(s.markdown?Ct(s.content).body:s.content),O(!1),o({tone:"success",title:"Skill saved",body:s.path})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Save failed",body:s instanceof Error?s.message:"Failed to save skill file."})},"onError")}),Rt=Y({mutationFn:n(()=>{if(!B)throw new Error("Select a skill first.");return B.starredByCurrentActor?_.unstar(r,B.id):_.star(r,B.id)},"mutationFn"),onSuccess:n(async()=>{B&&await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,B.id)})])},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Star failed",body:s instanceof Error?s.message:"Failed to update star."})},"onError")}),$t=Y({mutationFn:n(s=>_.update(r,s.skillId,s.updates),"mutationFn"),onSuccess:n(async s=>{a.setQueryData(f.companySkills.detail(r,s.id),i=>i&&{...i,...s}),a.setQueryData(f.companySkills.list(r),i=>i?.map(d=>d.id===s.id?{...d,...s}:d)),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,s.id)})]),o({tone:"success",title:"Skill settings updated",body:$a(s)})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Skill settings update failed",body:s instanceof Error?s.message:"Failed to update skill settings."})},"onError")}),zt=Y({mutationFn:n(()=>_.installUpdate(r,S),"mutationFn"),onSuccess:n(async s=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S)}),a.invalidateQueries({queryKey:f.companySkills.updateStatus(r,S)}),a.invalidateQueries({queryKey:f.companySkills.file(r,S,Q)})]),l(ps(s,Q)),o({tone:"success",title:"Skill updated",body:s.sourceRef?`Pinned to ${Xs(s.sourceRef)}`:s.name})},"onSuccess"),onError:n(s=>{v(s,"Update failed","Failed to install skill update.","Updating this skill")},"onError")}),De=xe({queryKey:f.companySkills.catalog(),queryFn:n(()=>_.catalogList(),"queryFn"),enabled:!!r,staleTime:6e4}),_t=xe({queryKey:f.companySkills.catalogDetail(h??""),queryFn:n(()=>_.catalogDetail(h),"queryFn"),enabled:!!(r&&h),staleTime:6e4}),Wn=xe({queryKey:f.companySkills.catalogFile(h??"",J),queryFn:n(()=>_.catalogFile(h,J),"queryFn"),enabled:!!(r&&h&&J),staleTime:6e4}),Ot=xe({queryKey:f.agents.list(r??""),queryFn:n(()=>Hs.list(r),"queryFn"),enabled:!!r}),Is=(0,c.useMemo)(()=>new Map(te.map(s=>[s.key,s])),[te]);(0,c.useMemo)(()=>{const s=new Set;for(const i of De.data??[])s.add(i.category);return Array.from(s).sort()},[De.data]);const Ke=(0,c.useMemo)(()=>za(te,De.data??[]),[te,De.data]),Yn=(0,c.useMemo)(()=>({all:Ke.length,installed:Ke.filter(s=>s.installed).length,catalog:Ke.filter(s=>s.catalogRef!=null).length,bundled:Ke.filter(s=>s.required).length}),[Ke]),Xe=(0,c.useMemo)(()=>_a(Ke,ae),[Ke,ae]),Xn=(0,c.useMemo)(()=>{const s=new Map;for(const i of Xe)for(const d of i.categories)s.set(d,(s.get(d)??0)+1);return Array.from(s.entries()).map(([i,d])=>({slug:i,count:d})).sort((i,d)=>d.count-i.count||i.slug.localeCompare(d.slug))},[Xe]),Ut=ne.trim().length>0,it=(0,c.useMemo)(()=>{if(G==="all"||G==="unfiled")return null;const s=Je(Ne.data);return s.byId.has(G)?ln(s,G):null},[G,Ne.data]),Zn=(0,c.useMemo)(()=>Oa(Xe.filter(s=>Ge&&!s.categories.includes(Ge)||ae==="installed"&&!Ut&&(G==="unfiled"&&s.folderId||it&&(!s.folderId||!it.has(s.folderId)))?!1:bn(s,ne.trim())),w,ae!=="bundled"),[Xe,Ge,ne,Ut,w,ae,G,it]),R=_t.data??(De.data??[]).find(s=>s.id===h||s.key===h)??null;(0,c.useEffect)(()=>{ue(R?.id??null)},[R?.id]),(0,c.useEffect)(()=>{if(!R||J==="SKILL.md")return;const s=mn(J);s.length!==0&&ye(i=>{const d=new Set(i[R.id]??[]);let F=!1;for(const E of s)d.has(E)||(d.add(E),F=!0);return F?{...i,[R.id]:d}:i})},[J,R]),(0,c.useMemo)(()=>{const s={all:te.length,company:0,bundled:0,optional:0,external:0};for(const i of te){const d=Pa(i);s[d]+=1}return s},[te]);const ot=Y({mutationFn:n(s=>_.installCatalog(r,{catalogSkillId:s.catalogSkillId,slug:s.slug,force:s.force}),"mutationFn"),onSuccess:n(async(s,i)=>{const d=s.action==="created"?i.agentIds:[];let F=0,E=0;for(const Le of d)try{await Hs.syncSkills(Le,[{key:s.skill.key,versionId:null}],"add",r??void 0),F+=1}catch{E+=1}await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,s.skill.id)})]),me(Le=>({...Le,open:!1,error:null})),o({tone:"success",title:s.action==="created"?"Skill installed":s.action==="updated"?"Skill updated":"Skill is up to date",body:s.action==="created"?F>0?`${s.skill.name} — enabled for ${F} agent${F===1?"":"s"}.`:`${s.skill.name} is in the library but not enabled for any agent yet. Use "Add to agent" to enable it.`:s.skill.name}),E>0&&o({tone:"warn",title:"Skill installed, but enabling failed",body:`Could not enable ${s.skill.name} for ${E} agent${E===1?"":"s"}. Use "Add to agent" on the skill page.`}),s.warnings[0]&&o({tone:"warn",title:"Install warnings",body:s.warnings[0]}),s.action==="created"&&l(ps(s.skill))},"onSuccess"),onError:n(s=>{const i=s instanceof Error?s.message:"Failed to install catalog skill.";me(d=>({...d,error:i})),N.capture(s,"Installing this skill")},"onError")}),Vt=Y({mutationFn:n(s=>he.create(r,{kind:"skill",parentId:et,...s}),"mutationFn"),onSuccess:n(async s=>{if(re(!1),Ve(null),ds(null),await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),_s.length>0){const i=_s;ee([]);try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s.id}))),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})])}catch(d){o({tone:"error",title:"Folder created, move failed",body:d instanceof Error?d.message:"Failed to move the selected skills."});return}}else ms(s.id);o({tone:"success",title:"Folder created",body:s.name})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder save failed",body:s instanceof Error?s.message:"Failed to save folder."})},"onError")}),dt=Y({mutationFn:n(({folderId:s,payload:i})=>he.update(r,s,i),"mutationFn"),onSuccess:n(async()=>{re(!1),Ve(null),await a.invalidateQueries({queryKey:f.folders.list(r,"skill")})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder save failed",body:s instanceof Error?s.message:"Failed to update folder."})},"onError")}),Qt=Y({mutationFn:n(({folderId:s,parentId:i})=>he.moveFolder(r,s,{parentId:i,position:0}),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),ms(s.id),o({tone:"success",title:"Folder moved",body:Mn(s.path)??s.name})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder move failed",body:s instanceof Error?s.message:"Failed to move folder."})},"onError")}),Ht=Y({mutationFn:n(s=>he.delete(r,s),"mutationFn"),onSuccess:n(async(s,i)=>{G===i&&ms("all"),cs(null),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]),o({tone:"success",title:"Folder deleted",body:"Skills moved to Unfiled."})},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Folder delete failed",body:s instanceof Error?s.message:"Failed to delete folder."})},"onError")}),Gt=Y({mutationFn:n(({itemId:s,folderId:i})=>he.moveItem(r,{kind:"skill",itemId:s,folderId:i}),"mutationFn"),onSuccess:n(async()=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})])},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Move failed",body:s instanceof Error?s.message:"Failed to move skill."})},"onError")});async function Jn(s){const i=Cs;if(i.length!==0)try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s}))),Te([]),A(!1),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")})]),o({tone:"success",title:"Skills moved",body:`${i.length} skill${i.length===1?"":"s"} filed.`})}catch(d){o({tone:"error",title:"Failed to move skills",body:d instanceof Error?d.message:"Failed to move the selected skills."})}}n(Jn,"moveSelectedSkills");const Qs=Y({mutationFn:n(()=>he.ensureMy(r),"mutationFn"),onSuccess:n(async s=>{await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),ms(s.id)},"onSuccess"),onError:n(s=>{o({tone:"error",title:"Couldn't open My Skills",body:s instanceof Error?s.message:"Failed to create your personal folder."})},"onError")});async function er(){const s=Je(Ne.data);if((G==="all"||G==="unfiled"?null:s.byId.get(G)??null)?.systemKey==="my"){try{const i=await Qs.mutateAsync();l(ft(null,i.id))}catch{return}return}l(ft(null,Hn))}n(er,"openNewSkill");async function sr(s){if((s?Je(Ne.data).byId.get(s):null)?.systemKey==="my"){try{xs([],(await Qs.mutateAsync()).id)}catch{return}return}xs([],s)}n(sr,"openCreateFolderIn");async function tr(s,i){if(i==="company"){Qt.mutate({folderId:s.id,parentId:null});return}try{const d=await Qs.mutateAsync();Qt.mutate({folderId:s.id,parentId:d.id})}catch{return}}n(tr,"moveFolderBetweenScopes");async function nr(s,i){try{const d=await he.create(r,{kind:"skill",parentId:s,name:i,color:null});return await a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),d.id}catch(d){return o({tone:"error",title:"Folder create failed",body:d instanceof Error?d.message:"Failed to create folder."}),null}}n(nr,"createFolderInline");async function rr(s){if(!Ee)return;const i=Ee.skillIds;try{await Promise.all(i.map(d=>he.moveItem(r,{kind:"skill",itemId:d,folderId:s}))),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.folders.list(r,"skill")}),...i.map(d=>a.invalidateQueries({queryKey:f.companySkills.detail(r,d)}))]),He(null),Te([]),A(!1),o({tone:"success",title:i.length===1?"Skill moved":"Skills moved",body:s?`Filed under ${we?.folders.find(d=>d.id===s)?.name??"folder"}.`:"Moved to Unfiled."})}catch(d){o({tone:"error",title:"Move failed",body:d instanceof Error?d.message:"Failed to move."})}}n(rr,"performDialogMove");const Wt=(0,c.useMemo)(()=>(Ot.data??[]).map(s=>{const i=x(s.adapterType),d=[],F=new Set((B?.usedByAgents??[]).map(E=>E.id));return{id:s.id,name:s.name,adapterType:s.adapterType,supportsSkills:!!i.supportsSkills,required:!1,icon:s.icon,paused:s.status==="paused"||s.pausedAt!=null,attached:F.has(s.id),requiredKeys:d}}),[Ot.data,x,B]),Yt=Y({mutationFn:n(async s=>Hs.syncSkills(s.agentId,s.desiredSkills,"replace",r??void 0),"mutationFn"),onSuccess:n(async()=>{await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),a.invalidateQueries({queryKey:f.companySkills.detail(r,S??"")}),a.invalidateQueries({queryKey:f.companySkills.versions(r,S??"")})])},"onSuccess")});async function ar(s,i=null){if(!B)return;const d=B.key,F=new Set(s),E=(B.usedByAgents??[]).map(H=>H.id),Le=new Set(E),ut=new Map((B.usedByAgents??[]).map(H=>[H.id,H.versionId??null])),xr=s.filter(H=>!Le.has(H)),hr=E.filter(H=>!F.has(H)),pr=s.filter(H=>Le.has(H)&&(ut.get(H)??null)!==i),sn=new Set([...xr,...hr,...pr]);if(sn.size!==0)try{for(const H of sn){const tn=await Hs.skills(H,r??void 0),nn=(tn.desiredSkillEntries??tn.desiredSkills.map(mt=>({key:mt,versionId:null}))).filter(mt=>mt.key!==d);F.has(H)&&nn.push({key:d,versionId:i}),await Yt.mutateAsync({agentId:H,desiredSkills:nn})}o({tone:"success",title:"Agents updated",body:`${s.length} agent(s) attached.`})}catch(H){o({tone:"error",title:"Update failed",body:H instanceof Error?H.message:"Failed to update agent skills."})}}n(ar,"handleAttachSubmit");function Xt(s){const i=Is.get(s.key)??null,d=i?.originHash??null,F=i?d&&d!==s.contentHash?"update":i.sourceType!=="catalog"?"replace":"update":"install";me({open:!0,catalogSkill:s,conflict:i,defaultSlug:i?.slug??s.slug,defaultForce:F==="replace",defaultAction:F,error:null})}n(Xt,"openInstallDialog");const Ds=Y({mutationFn:n(()=>_.delete(r,ie),"mutationFn"),onSuccess:n(async s=>{Vs(!1),de(null),Pe(null),await Promise.all([a.invalidateQueries({queryKey:f.companySkills.list(r)}),...ie?[a.invalidateQueries({queryKey:f.companySkills.detail(r,ie)}),a.invalidateQueries({queryKey:f.companySkills.updateStatus(r,ie)})]:[],...ie?[a.invalidateQueries({queryKey:f.companySkills.file(r,ie,Q)})]:[]]),await a.refetchQueries({queryKey:f.companySkills.list(r),type:"active"}),l("/skills",{replace:!0}),o({tone:"success",title:"Skill removed",body:`${s.name} was removed from the company skill library.`})},"onSuccess"),onError:n(s=>{v(s,"Remove failed","Failed to remove skill.","Removing this skill")},"onError")}),we=Ne.data??null,z=rt&&ae==="installed",ct=(0,c.useMemo)(()=>{if(!we||ae!=="installed")return we;const s=Xe.filter(E=>Ge&&!E.categories.includes(Ge)?!1:bn(E,ne.trim())),i=new Map;let d=0;for(const E of s)E.folderId?i.set(E.folderId,(i.get(E.folderId)??0)+1):d+=1;const F=Je(we);return{...we,allCount:s.length,unfiledCount:d,folders:we.folders.map(E=>{let Le=0;for(const ut of ln(F,E.id))Le+=i.get(ut)??0;return{...E,itemCount:Le}})}},[we,ae,Xe,Ge,ne]),lr=(0,c.useMemo)(()=>ra(Je(we),B?.folderId),[we,B?.folderId]);if(!r)return(0,e.jsx)(es,{icon:ge,message:"Select a company to manage skills."});function ir(){const s=p.trim();if(s.length===0){X(!0);return}lt.mutate(s)}n(ir,"handleAddSkillSource");function or(s){if(s.skillId){l(at(s.skillId));return}s.catalogRef&&Vn(s.catalogRef)}n(or,"openDiscoveryCard");const Zt=new URLSearchParams(u);Zt.delete("catalog");const Jt=Zt.toString(),dr=Jt?`/skills?${Jt}`:"/skills",cr=B?(De.data??[]).find(s=>s.key===B.key)?.source??null:null,en=Ye.data?ps(Ye.data):"/skills",ur=oe?"Fork skill":"Create a new skill",mr=oe?"Review the fork metadata and create an editable company copy.":"Create an editable company skill in the Paperclip workspace.";return(0,e.jsxs)(e.Fragment,{children:[N.denial?(0,e.jsx)("div",{className:"px-4 pt-4",children:(0,e.jsx)(la,{denial:N.denial,onDismiss:N.reset})}):null,(0,e.jsx)(vs,{open:ss,onOpenChange:Vs,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Remove skill"}),(0,e.jsx)(As,{children:"Remove this skill from the company library. If any agents still use it, removal will be blocked until it is detached."})]}),(0,e.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,e.jsx)("p",{children:ve?`You are about to remove ${ve.name}.`:"You are about to remove this skill."}),ve?.usedByAgents?.length?(0,e.jsxs)("div",{className:"rounded-md border border-border px-3 py-3 text-muted-foreground",children:["Currently used by ",ve.usedByAgents.map(s=>s.name).join(", "),"."]}):null,(ve?.usedByAgents.length??0)>0?(0,e.jsx)("p",{className:"text-muted-foreground",children:"Detach this skill from all agents to enable removal."}):null]}),(0,e.jsx)(vt,{children:(ve?.usedByAgents.length??0)>0?(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>Vs(!1),"onClick"),children:"Close"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(y,{variant:"ghost",onClick:n(()=>Vs(!1),"onClick"),disabled:Ds.isPending,children:"Cancel"}),(0,e.jsx)(y,{variant:"destructive",onClick:n(()=>Ds.mutate(),"onClick"),disabled:Ds.isPending||!ie,children:Ds.isPending?"Removing...":"Remove skill"})]})})]})}),(0,e.jsx)(vs,{open:$,onOpenChange:X,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Add a skill source"}),(0,e.jsx)(As,{children:"Paste a local path, GitHub URL, or `skills.sh` command into the field first."})]}),(0,e.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,e.jsxs)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Browse skills.sh"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Find install commands and paste one here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),(0,e.jsxs)("a",{href:"https://github.com/search?q=SKILL.md&type=code",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Search GitHub"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Look for repositories with `SKILL.md`, then paste the repo URL here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]})]}),(0,e.jsx)(vt,{showCloseButton:!0})]})}),(0,e.jsx)(Ya,{open:V.open,onOpenChange:n(s=>me(i=>({...i,open:s,error:s?i.error:null})),"onOpenChange"),skill:V.catalogSkill,packageName:V.catalogSkill?.packageName??V.conflict?.packageName??null,packageVersion:V.catalogSkill?.packageVersion??V.conflict?.packageVersion??null,conflict:V.conflict,defaultSlug:V.defaultSlug,defaultForce:V.defaultForce,defaultAction:V.defaultAction,agents:Wt,isPending:ot.isPending,error:V.error,onConfirm:n(({slug:s,force:i,agentIds:d})=>{V.catalogSkill&&ot.mutate({catalogSkillId:V.catalogSkill.id,slug:s,force:i,agentIds:d})},"onConfirm")}),(0,e.jsx)(vs,{open:Rs,onOpenChange:is,children:(0,e.jsxs)(bs,{className:"sm:max-w-md",children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ys,{children:"Import a skill"}),(0,e.jsx)(As,{children:"Paste a local path, GitHub URL, or `skills.sh` command to import a skill into this company."})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-b border-border pb-2",children:[(0,e.jsx)(qe,{value:p,onChange:n(s=>T(s.target.value),"onChange"),placeholder:"Paste path, GitHub URL, or skills.sh command",className:"h-9 rounded-none border-0 px-0 shadow-none focus-visible:ring-0"}),(0,e.jsx)(y,{size:"sm",onClick:ir,disabled:lt.isPending,children:lt.isPending?(0,e.jsx)(Ws,{className:"h-4 w-4 animate-spin"}):"Import"})]}),(0,e.jsxs)("a",{href:"https://skills.sh",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-sm text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Browse skills.sh"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Find install commands and paste one here."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]}),(0,e.jsxs)("a",{href:"https://github.com/search?q=SKILL.md&type=code",target:"_blank",rel:"noreferrer",className:"flex items-start justify-between rounded-md border border-border px-3 py-3 text-sm text-foreground no-underline transition-colors hover:bg-accent/40",children:[(0,e.jsxs)("span",{children:[(0,e.jsx)("span",{className:"block font-medium",children:"Search GitHub"}),(0,e.jsx)("span",{className:"mt-1 block text-muted-foreground",children:"Look for repositories with `SKILL.md`, then paste the repo URL."})]}),(0,e.jsx)(fs,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"})]})]})]})}),r?(0,e.jsx)(xa,{open:ws,onOpenChange:C,companyId:r,onImportFromPath:n(()=>{C(!1),is(!0)},"onImportFromPath")}):null,(0,e.jsx)(aa,{open:Js,kind:"skill",folder:os,pending:Vt.isPending||dt.isPending,onOpenChange:n(s=>{re(s),s||ds(null)},"onOpenChange"),onSubmit:n(s=>{os?dt.mutate({folderId:os.id,payload:s}):Vt.mutate(s)},"onSubmit")}),(0,e.jsx)(Wr,{open:Qe!==null,folder:Qe,itemLabelPlural:"skills",pending:Ht.isPending,onOpenChange:n(s=>{s||cs(null)},"onOpenChange"),onConfirm:n(()=>{Qe&&Ht.mutate(Qe.id)},"onConfirm")}),(0,e.jsx)(ja,{open:$s,onOpenChange:zs,result:ct,selection:G,allLabel:"All skills",itemLabelPlural:"Skills",onSelect:ms,onCreate:n(()=>xs(),"onCreate")}),(0,e.jsx)(va,{open:Ee!==null,onOpenChange:n(s=>{s||He(null)},"onOpenChange"),result:ct,title:Ee?.title??"Move to folder",subtitle:Ee?.subtitle??null,currentFolderId:Ee?.currentFolderId??null,onMove:n(s=>{rr(s)},"onMove"),onCreateFolder:nr}),se?(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsxs)("div",{className:"border-b border-border px-4 py-5",children:[(0,e.jsxs)(pe,{to:en,className:"mb-3 inline-flex items-center gap-1.5 text-sm text-muted-foreground no-underline transition-colors hover:text-foreground",children:[(0,e.jsx)(an,{className:"h-4 w-4"}),"Back"]}),(0,e.jsx)("h1",{className:"text-2xl font-semibold",children:ur}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:mr})]}),(0,e.jsx)("div",{className:"px-4 py-4",children:(0,e.jsx)("div",{className:"max-w-3xl",children:oe&&Ye.isLoading?(0,e.jsx)(Be,{variant:"detail"}):oe&&!Ye.data?(0,e.jsx)(es,{icon:ge,message:"Fork source skill not found."}):(0,e.jsx)(Ha,{initialDraft:Qn,onCreate:n(s=>Kt.mutate(s),"onCreate"),isPending:Kt.isPending,error:Zs,onCancel:n(()=>l(en),"onCancel")})})})]}):rt?(0,e.jsx)(Qa,{tab:ae,tabCounts:Yn,onTabChange:Et,categories:Xn,categoryTotal:Xe.length,activeCategory:Ge,onCategoryChange:Un,search:ne,onSearchChange:ke,sort:w,onSortChange:Ie,cards:Zn,onOpenCard:or,loading:We.isLoading||De.isLoading,error:We.error?.message??De.error?.message??null,totalCount:Ke.length,onCreate:n(()=>{er()},"onCreate"),onImport:n(()=>is(!0),"onImport"),onImportFromProject:n(()=>C(!0),"onImportFromProject"),onBrowseCatalog:n(()=>Et("catalog"),"onBrowseCatalog"),onScan:n(s=>Mt.mutate(s),"onScan"),scanPending:Mt.isPending,scanStatus:_e,folderResult:z?ct:null,folderSelection:G,foldersLoading:Ne.isLoading,selectMode:z&&Ss,selectedSkillIds:Cs,onFolderSelect:z?ms:void 0,onOpenMobileFolders:z?()=>zs(!0):void 0,onCreateFolder:z?()=>xs():void 0,onCreateFolderIn:z?s=>{sr(s)}:void 0,onEnsureMyFolder:z?()=>Qs.mutate():void 0,onOpenMoveCard:z?s=>{s.skillId&&He({skillIds:[s.skillId],title:`Move "${s.name}"`,subtitle:"Choose a destination folder.",currentFolderId:s.folderId??null})}:void 0,onRenameFolder:z?(s,i)=>dt.mutate({folderId:s.id,payload:{name:i}}):void 0,onEditFolder:z?s=>{Ve(s),re(!0)}:void 0,onMoveFolder:z?(s,i)=>{tr(s,i)}:void 0,onDeleteFolder:z?cs:void 0,onToggleSelectMode:z?()=>{A(s=>!s),Ss&&Te([])}:void 0,onSelectCard:z?(s,i)=>{s.skillId&&Te(d=>i?Array.from(new Set([...d,s.skillId])):d.filter(F=>F!==s.skillId))}:void 0,onMoveCard:z?(s,i)=>{if(!s.skillId)return;const d=s.skillId,F=s.folderId??null;Gt.mutate({itemId:d,folderId:i}),o({tone:"success",title:"Skill moved",body:i?`Moved "${s.name}" to ${we?.folders.find(E=>E.id===i)?.name??"folder"}.`:`Moved "${s.name}" to Unfiled.`,action:{label:"Undo",onClick:n(()=>Gt.mutate({itemId:d,folderId:F}),"onClick")}})}:void 0,onCreateFolderAndMoveCard:z?s=>{s.skillId&&xs([s.skillId])}:void 0,onMoveSelected:z?s=>{Jn(s)}:void 0,onCreateFolderAndMoveSelected:z?()=>xs(Cs):void 0,onClearSelected:z?()=>Te([]):void 0,folderNudgeStorageKey:z?`paperclip:skills-folder-nudge:${r??"none"}`:void 0}):st==="installed"&&S?(0,e.jsx)(tl,{detail:B,folderDisplayPath:lr,catalogSource:cr,routeSkills:te,loading:We.isLoading||hs.isLoading,activeTab:On,onTabChange:Tt,selectedPath:Q,file:Us,fileLoading:Me.isLoading&&!Us,viewMode:Z,editMode:q,draft:be,setViewMode:fe,setEditMode:O,setDraft:D,onSave:n(()=>qt.mutate(),"onSave"),savePending:qt.isPending,versions:At.data??[],versionsLoading:At.isLoading,attachAgents:Wt,onSubmitAttach:ar,attachPending:Yt.isPending,expandedDirs:b[S]??new Set,onToggleDir:n(s=>{M(i=>{const d=new Set(i[S]??[]);return d.has(s)?d.delete(s):d.add(s),{...i,[S]:d}})},"onToggleDir"),onSelectPath:n(s=>{Tt("files"),l(at(S,s))},"onSelectPath"),updateStatus:Os.data,updateStatusLoading:Os.isLoading,onCheckUpdates:n(()=>{Os.refetch()},"onCheckUpdates"),checkUpdatesPending:Os.isFetching,onInstallUpdate:n(()=>zt.mutate(),"onInstallUpdate"),installUpdatePending:zt.isPending,onToggleStar:n(()=>Rt.mutate(),"onToggleStar"),starPending:Rt.isPending,onFork:n(()=>B&&l(ft(B.id)),"onFork"),onUpdateSettings:n(s=>B&&$t.mutate({skillId:B.id,updates:s}),"onUpdateSettings"),onMoveToFolder:B?()=>He({skillIds:[B.id],title:`Move "${B.name}"`,subtitle:"Choose a destination folder.",currentFolderId:B.folderId??null}):void 0,updateSettingsPending:$t.isPending,onDelete:Gn,deletePending:Ds.isPending,studioHref:Kn(S)}):h?(0,e.jsxs)("div",{className:"min-h-(--sz-calc-30)",children:[(0,e.jsx)("div",{className:"border-b border-border px-4 py-3",children:(0,e.jsxs)(pe,{to:dr,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground no-underline transition-colors hover:text-foreground",children:[(0,e.jsx)(an,{className:"h-4 w-4"}),"Back to store"]})}),De.isLoading||_t.isLoading?(0,e.jsx)(Be,{variant:"detail"}):R?(0,e.jsxs)("div",{className:"grid gap-0 xl:grid-cols-(--gtc-30)",children:[(0,e.jsxs)("aside",{className:"border-b border-border px-3 py-4 xl:border-b-0 xl:border-r",children:[(0,e.jsx)("div",{className:"mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Files"}),(0,e.jsx)(Pt,{nodes:Rn(R.files.map(s=>({path:s.path,kind:s.kind}))),skillId:R.id,selectedPath:J,expandedDirs:Fe[R.id]??new Set,onToggleDir:n(s=>ye(i=>{const d=new Set(i[R.id]??[]);return d.has(s)?d.delete(s):d.add(s),{...i,[R.id]:d}}),"onToggleDir"),onSelectPath:n(s=>U(s),"onSelectPath"),fileHref:n(()=>`/skills?catalog=${encodeURIComponent(h)}`,"fileHref")})]}),(0,e.jsx)("div",{className:"min-w-0",children:(0,e.jsx)(Ga,{skill:R,packageName:R.packageName??Is.get(R.key)?.packageName??null,packageVersion:R.packageVersion??Is.get(R.key)?.packageVersion??null,installedSkill:Is.get(R.key)??null,installedSkillId:Is.get(R.key)?.id??null,fileQuery:Wn,selectedPath:J,onInstall:n(()=>Xt(R),"onInstall"),onUpdate:n(()=>Xt(R),"onUpdate"),onOpenInstalled:n(s=>l(at(s)),"onOpenInstalled"),loadingPrimaryAction:ot.isPending})})]}):(0,e.jsx)(es,{icon:ge,message:"Catalog skill not found."})]}):(0,e.jsx)("div",{className:"min-h-(--sz-calc-30)",children:We.isLoading?(0,e.jsx)(Be,{variant:"detail"}):(0,e.jsx)(es,{icon:ge,message:"Skill not found."})})]})}n(El,"CompanySkills");export{El as CompanySkills};
|