PageSourceSearch

https://kalcend.ai/assets/SkillsPage-Bc3o8f3u.js

js kalcend.ai collected 2026-10-05 12:08:35 UTC 8,568 bytes, 1 lines download raw bytes

1import{ac as B,a as D,j as e,a4 as $,r as o,dT as M,dU as A,V as j,aj as L,ak as O,b9 as P,dV as K,dW as V}from"./index-BTfcerCQ.js";import{C as W}from"./ConfirmDialog-CvYYh6tm.js";import{u as J}from"./useOrgSkills-D3mmrvox.js";const X="'JetBrains Mono', ui-monospace, SFMono-Regular, monospace";function v(a){return a===null||!Number.isSafeInteger(a)||a<0?"Unavailable":a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:`${(a/1024/1024).toFixed(1)} MB`}function Y(a){const n=a?new Date(a).getTime():NaN;return Number.isFinite(n)?new Date(n).toLocaleDateString():"Unavailable"}function Z(){const a=B(),n=D(c=>c.claims?.orgId),y=J(n);return a?e.jsx(q,{library:y},a):null}function q({library:a,upload:n=K,remove:y=V}){const c=D(s=>s.claims),t=$(),[w,p]=o.useState(null),[l,g]=o.useState(null),[N,d]=o.useState(null),[i,k]=o.useState(null),[E,z]=o.useState(()=>new Set),C=o.useRef(null),{skills:R,loading:h,error:f,retry:u}=a,m=R.filter(s=>!E.has(s.id)),x=!h&&!f,b=l?M(l):null,S=s=>c?.orgAdmin===!0||!!c?.userId&&s.createdByUid===c.userId,U=s=>{const r=s.target.files?.[0];s.target.value="",!(!r||t.saving||!t.isCurrent())&&(g(r),t.setError(null),d(null))},T=async()=>{if(!l||b||!x||i||!t.begin())return;const s=l;p("upload"),d(null);try{const r=await n(s);if(!t.isCurrent())return;if(r.success!==!0||!r.skillId||!r.name)throw new Error(r.error||"The upload was not confirmed. Refresh the library before retrying.");g(null),d(`Uploaded ${r.name}. It is available to attach to teammates.`),u()}catch(r){t.setError(r instanceof Error?r.message:"Upload failed. Your selected file is retained.")}finally{t.isCurrent()&&p(null),t.finish()}},F=async()=>{const s=i&&m.find(r=>r.id===i.id);if(!x)throw new Error("Refresh the skill library before deleting this skill.");if(!s)throw new Error("This skill is no longer in the library. Cancel and refresh.");if(!S(s))throw new Error("Only the uploader or an organization admin can delete this skill.");if(!t.begin())throw new Error("Wait for the current action to finish.");p("delete"),d(null);try{const r=await y(s.id);if(!t.isCurrent())return;if(r.success!==!0)throw new Error(r.error||"The deletion was not confirmed. Refresh the library before retrying.");z(I=>new Set([...I,s.id])),d(`Deleted ${s.name} from the library.`),u()}catch(r){if(t.isCurrent())throw r}finally{t.isCurrent()&&p(null),t.finish()}};return e.jsxs("div",{className:"min-w-0 space-y-6",style:{fontFamily:"'Poppins', sans-serif"},children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 border-b border-white/[0.08] pb-6",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[e.jsx(A,{size:24,className:"mt-1 shrink-0 text-[#949494]"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold text-[#cfcfcf]",children:"Skills"}),e.jsx("p",{className:"mt-1 text-[#949494]",children:"Upload a SKILL.md or a zipped skill folder, then attach it to a teammate. Maximum upload size: 5 MB."})]})]}),e.jsxs("button",{type:"button",onClick:u,disabled:h||t.saving||!!i,className:"inline-flex min-h-10 shrink-0 items-center gap-2 px-3 py-2 text-sm text-[#cfcfcf] disabled:opacity-40",children:[e.jsx(j,{size:15}),"Refresh library"]}),e.jsxs("button",{type:"button",onClick:()=>C.current?.click(),disabled:t.saving||!!i,className:"inline-flex min-h-10 shrink-0 items-center gap-2 bg-white px-3.5 py-2 text-sm font-medium text-black disabled:opacity-40",children:[e.jsx(L,{size:15}),l?"Choose another file":"Upload skill"]}),e.jsx("input",{ref:C,type:"file","aria-label":"Skill archive",accept:".zip,.md,.markdown",className:"hidden",disabled:t.saving||!!i,onChange:U})]}),N&&e.jsx("p",{role:"status",className:"break-words text-sm text-emerald-400",children:N}),t.error&&e.jsxs("div",{role:"alert",className:"flex items-start gap-3 border border-red-400/20 p-4 text-sm text-red-400",children:[e.jsx("p",{className:"min-w-0 flex-1 break-words",children:t.error}),e.jsx("button",{type:"button","aria-label":"Dismiss upload error",onClick:()=>t.setError(null),className:"min-h-10 min-w-10 shrink-0",children:e.jsx(O,{size:16})})]}),l&&e.jsxs("section",{"aria-label":"Selected skill upload",className:"min-w-0 space-y-3 border border-white/[0.08] p-4",children:[e.jsxs("p",{className:"break-words text-sm text-[#cfcfcf]",children:["Selected file: ",l.name]}),e.jsxs("p",{className:"text-xs text-[#949494]",children:[v(l.size),". Files are validated before becoming available."]}),b&&e.jsx("p",{role:"alert",className:"text-sm text-red-400",children:b}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("button",{type:"button",disabled:t.saving||!!b||!x||!!i,onClick:()=>{T()},className:"inline-flex min-h-10 items-center gap-2 bg-white px-4 py-2 text-sm text-black disabled:opacity-40",children:[t.saving&&w==="upload"&&e.jsx(j,{size:14,className:"animate-spin"}),t.saving&&w==="upload"?"Uploading…":t.error?"Retry upload":"Upload selected file"]}),e.jsx("button",{type:"button",disabled:t.saving||!!i,onClick:()=>{g(null),t.setError(null)},className:"min-h-10 px-3 py-2 text-sm text-[#cfcfcf] disabled:opacity-40",children:"Cancel upload"})]})]}),h&&e.jsxs("p",{role:"status",className:"flex items-center gap-2 text-sm text-[#949494]",children:[e.jsx(j,{size:14,className:"animate-spin"}),m.length?"Refreshing skills…":"Loading skills…"]}),f&&e.jsxs("div",{role:"alert",className:"border border-red-400/20 p-4 text-sm text-red-400",children:[e.jsx("p",{className:"break-words",children:f}),e.jsx("button",{type:"button",disabled:t.saving,onClick:u,className:"min-h-10 underline",children:"Retry library"})]}),!h&&!f&&m.length===0&&e.jsxs("div",{className:"border-2 border-dashed border-white/[0.08] p-8 text-center",children:[e.jsx("h2",{className:"text-lg text-[#cfcfcf]",children:"No skills yet"}),e.jsx("p",{className:"mt-2 text-sm text-[#949494]",children:"Upload a skill or ask the builder to author one."})]}),m.length>0&&e.jsx("div",{role:"region","aria-label":"Skill library",tabIndex:0,className:"min-w-0 overflow-x-auto border border-white/[0.08] focus:outline-none focus:ring-2 focus:ring-white/20",children:e.jsxs("table",{className:"w-full min-w-[760px] table-fixed text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/[0.08] text-left text-[#949494]",children:[e.jsx("th",{scope:"col",className:"w-[180px] px-4 py-3 font-medium",children:"Skill"}),e.jsx("th",{scope:"col",className:"w-[240px] px-4 py-3 font-medium",children:"Description"}),e.jsx("th",{scope:"col",className:"w-[160px] px-4 py-3 font-medium",children:"Slug"}),e.jsx("th",{scope:"col",className:"w-[70px] px-4 py-3 font-medium",children:"Files"}),e.jsx("th",{scope:"col",className:"w-[90px] px-4 py-3 font-medium",children:"Size"}),e.jsx("th",{scope:"col",className:"w-[110px] px-4 py-3 font-medium",children:"Created"}),e.jsx("th",{scope:"col",className:"w-[90px] px-4 py-3 font-medium",children:"Actions"})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{className:"border-b border-white/[0.06] align-top last:border-b-0 hover:bg-white/[0.03]",children:[e.jsxs("th",{scope:"row",className:"break-words px-4 py-3 text-left font-medium text-[#cfcfcf]",children:[s.name,s.status!=="ready"&&e.jsx("span",{className:"mt-1 block text-xs text-red-400",children:s.status})]}),e.jsx("td",{className:"break-words px-4 py-3 text-[#949494]",children:s.description}),e.jsx("td",{className:"break-words px-4 py-3 text-[#949494]",style:{fontFamily:X},children:s.slug}),e.jsx("td",{className:"px-4 py-3 text-[#949494]",children:s.fileCount??"—"}),e.jsx("td",{className:"px-4 py-3 text-[#949494]",children:v(s.uncompressedBytes)}),e.jsx("td",{className:"px-4 py-3 text-[#949494]",children:Y(s.createdAt)}),e.jsx("td",{className:"px-4 py-3",children:S(s)?e.jsx("button",{type:"button","aria-label":`Delete skill ${s.name}`,disabled:!x||t.saving,onClick:r=>
1{t.isCurrent()&&x&&!t.saving&&!i&&(r.currentTarget.focus(),k(s),t.setError(null))},className:"inline-flex min-h-10 min-w-10 items-center justify-center text-[#949494] hover:text-red-400 disabled:opacity-40",children:e.jsx(P,{size:16})}):e.jsx("span",{className:"text-xs text-[#949494]",children:"Uploader or admin only"})})]},s.id))})]})}),e.jsx(W,{open:!!i,onClose:()=>{t.isCurrent()&&k(null)},onConfirm:F,title:"Delete skill",message:`Delete “${i?.name??""}”? Detach this skill from all teammates first. Its archive will be removed from the library.`,confirmText:"Delete",busyText:"Deleting…",cancelText:"Cancel",variant:"danger"},i?.id??"closed")]})}export{q as SkillsLibrary,Z 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.