1import{n as D,o as H,r as a,p as E,j as e,q as $,B as R,I as F,t as Q,x as v}from"./index-DJ1uWGdt.js";var _=({open:l,onOpenChange:o,onImport:c,busy:k=!1,error:d})=>{const[h,b]=a.useState(""),[p,m]=a.useState(""),[u,f]=a.useState(""),[i,y]=a.useState(""),[n,x]=a.useState(""),N=()=>{b(""),m(""),f(""),y(""),x("")},S=()=>{N(),o(!1)},w=async s=>{if(s.preventDefault(),!(!h.trim()||!p.trim()||!u.trim()||!i.trim()||!n.trim()||k))try{await c({name:h.trim(),description:p.trim(),repoURL:u.trim(),path:i.trim(),ref:n.trim()}),S()}catch{}},g=!!(h.trim()&&p.trim()&&u.trim()&&i.trim()&&n.trim())&&!k;return e.jsx(Q,{open:l,onOpenChange:s=>{s||S()},title:"Import from GitHub",description:"Import a skill from a SKILL.md file in a GitHub repository.",headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary",children:e.jsx(F,{name:"github",className:"size-5"})}),contentSized:!0,className:"md:max-w-2xl",children:e.jsx("form",{onSubmit:s=>void w(s),children:e.jsxs("div",{className:"space-y-5 px-5 py-5 md:px-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-name",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Name"}),e.jsx("input",{id:"skill-name",value:h,onChange:s=>{b(s.target.value)},placeholder:"release-notes",autoFocus:!0,required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-description",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Description"}),e.jsx("textarea",{id:"skill-description",value:p,onChange:s=>{m(s.target.value)},placeholder:"Generate release notes from merged pull requests",required:!0,rows:3,className:v("resize-y py-2.5")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-repo-url",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Repository URL"}),e.jsx("input",{id:"skill-repo-url",type:"url",value:u,onChange:s=>{f(s.target.value)},placeholder:"https://github.com/org/repo",required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-path",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Folder containing the SKILL.md"}),e.jsx("input",{id:"skill-path",value:i,onChange:s=>{y(s.target.value)},placeholder:"skills/release-notes",required:!0,className:v("h-11")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"skill-ref",className:"mb-2 block text-sm font-semibold text-text-primary",children:"Branch"}),e.jsx("input",{id:"skill-ref",value:n,onChange:s=>{x(s.target.value)},placeholder:"main",required:!0,className:v("h-11")})]}),e.jsxs("div",{className:"space-y-3",children:[d?e.jsx("p",{className:"text-failure-bg text-sm",children:d}):null,e.jsx(R,{type:"submit",disabled:!g,className:"w-full",children:"Import"})]})]})})})},K=_,q=(l,o,c)=>!l||o.toLowerCase().includes(l)||c.toLowerCase().includes(l),P=l=>"catalogId"in l,T=()=>{const{skillCatalog:l}
1=D(),o=H(),[c,k]=a.useState(""),[d,h]=a.useState([]),[b,p]=a.useState([]),[m,u]=a.useState(!0),[f,i]=a.useState(null),[y,n]=a.useState(null),[x,N]=a.useState(!1),[S,w]=a.useState(!1),g=a.useCallback(async()=>{if(l){u(!0),i(null);try{const[t,r]=await Promise.all([l.listSkills(),l.getSkillCatalog()]);h(t),p(r)}catch(t){i(E(t,"Failed to load skills"))}finally{u(!1)}}},[l]);a.useEffect(()=>{g()},[g]);const s=c.trim().toLowerCase(),C=a.useMemo(()=>d.filter(t=>q(s,t.name,t.description)),[d,s]),I=a.useMemo(()=>{const t=new Set(d.flatMap(r=>P(r)?[r.catalogId]:[]));return b.filter(r=>!t.has(r.id)&&q(s,r.name,r.description))},[b,d,s]),L=async(t,r=i)=>{N(!0),i(null);try{await t(),await g()}catch(j){throw r(E(j,"Request failed")),j}finally{N(!1)}};if(!l)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Skills catalog is not available."});const B=t=>{L(async()=>{await l.createSkill({catalogId:t.id,name:t.name,description:t.description,repoURL:t.repoURL,path:t.path,ref:t.ref})}).catch(()=>{})},G=t=>{const r=l.deleteSkill;r&&L(async()=>{await r({id:t.id})}).catch(()=>{})},M=async t=>{n(null),await L(async()=>{await l.createSkill(t)},n),setTimeout(()=>{o==null||o.showSuccess({title:`${t.name} imported`})},0)},z=({key:t,name:r,description:j,action:O})=>e.jsxs("article",{className:"flex min-h-16 items-center gap-3 border-b border-border p-3 last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(F,{name:"lightbulb",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:r}),j?e.jsx("p",{className:"mt-0.5 truncate text-sm text-text-secondary",children:j}):null]}),O]},t),U=C.length>0||I.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Skills"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Use built-in skills or import
1custom skills from GitHub."}),f?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:f}):null,e.jsxs("div",{className:"mt-4 flex min-h-0 flex-1 flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx($,{query:c,setQuery:k,placeholder:"Search skills"})}),e.jsxs(R,{variant:"secondary",type:"button",className:"shrink-0",disabled:x,onClick:()=>{n(null),w(!0)},children:[e.jsx(F,{name:"github",className:"size-4"}),"Import from GitHub"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[m?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loadingâ¦"}):null,!m&&C.length>0?e.jsxs("section",{"aria-labelledby":"enabled-skills-heading",children:[e.jsxs("h4",{id:"enabled-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Enabled · ",C.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:C.map(t=>z({key:t.id,name:t.name,description:t.description,action:l.deleteSkill?e.jsx(R,{variant:"outline",size:"sm",type:"button",disabled:x,"aria-label":`Remove ${t.name}`,onClick:()=>{G(t)},children:"Remove"}):null}))})]}):null,!m&&I.length>0?e.jsxs("section",{"aria-labelledby":"available-skills-heading",children:[e.jsxs("h4",{id:"available-skills-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",I.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:I.map(t=>z({key:t.id,name:t.name,description:t.description,action:e.jsx(R,{variant:"outline",size:"sm",type:"button",disabled:x,"aria-label":`Enable ${t.name}`,onClick:()=>{B(t)},children:"Enable"})}))})]}):null,!m&&!U?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:s?`No skills match â${c.trim()}â.`:"No skills yet."}):null]})]}),e.jsx(K,{open:S,onOpenChange:t=>{w(t),t||n(null)},onImport:M,busy:x,error:y})]})},J=T;export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.