@tt-a1i/hive 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.en.md +2 -1
  3. package/README.md +2 -1
  4. package/dist/src/cli/team.js +2 -2
  5. package/dist/src/server/agent-run-bootstrap.d.ts +6 -1
  6. package/dist/src/server/agent-run-bootstrap.js +5 -2
  7. package/dist/src/server/agent-run-starter.js +15 -1
  8. package/dist/src/server/agent-startup-instructions.js +1 -1
  9. package/dist/src/server/command-preset-defaults.js +12 -0
  10. package/dist/src/server/hive-team-guidance.js +4 -4
  11. package/dist/src/server/post-start-input-writer.js +2 -2
  12. package/dist/src/server/preset-launch-support.js +2 -1
  13. package/dist/src/server/session-capture.d.ts +6 -0
  14. package/dist/src/server/session-capture.js +32 -0
  15. package/dist/src/server/sqlite-schema-v22.d.ts +2 -0
  16. package/dist/src/server/sqlite-schema-v22.js +27 -0
  17. package/dist/src/server/sqlite-schema.d.ts +1 -1
  18. package/dist/src/server/sqlite-schema.js +6 -1
  19. package/dist/src/server/workflow-cli-policy.d.ts +1 -1
  20. package/dist/src/server/workflow-cli-policy.js +1 -1
  21. package/dist/src/server/workflow-runner.js +1 -1
  22. package/dist/src/shared/types.d.ts +2 -2
  23. package/package.json +1 -1
  24. package/web/dist/assets/{AddWorkerDialog-CGbaxu0T.js → AddWorkerDialog-BRUxpa3f.js} +2 -2
  25. package/web/dist/assets/{AddWorkspaceDialog-CNgExu6b.js → AddWorkspaceDialog-D56x5JCb.js} +1 -1
  26. package/web/dist/assets/{FirstRunWizard-DxGApUNc.js → FirstRunWizard-BFVaMIsE.js} +1 -1
  27. package/web/dist/assets/{MarketplaceDrawer-Bk6cpukn.js → MarketplaceDrawer-DeEZ35dN.js} +1 -1
  28. package/web/dist/assets/{WhatsNewDialog-CSGzk-2U.js → WhatsNewDialog-CHkZeINH.js} +1 -1
  29. package/web/dist/assets/{WorkerModal-i2F3n3nZ.js → WorkerModal-BBCuMLIa.js} +1 -1
  30. package/web/dist/assets/{WorkspaceTaskDrawer-C_Ta_K13.js → WorkspaceTaskDrawer-CpZHAcj1.js} +1 -1
  31. package/web/dist/assets/{WorkspaceTerminalPanels-VdDxtrQF.js → WorkspaceTerminalPanels-7If2mDyp.js} +1 -1
  32. package/web/dist/assets/{index-CAgGM6nb.js → index-CxNL0O-C.js} +5 -7
  33. package/web/dist/cli-icons/hermes.png +0 -0
  34. package/web/dist/index.html +1 -1
  35. package/web/dist/sw.js +1 -1
@@ -1 +1 @@
1
- import{c as V,u as D,r as l,j as e,q as ce,e as B,k as Z,a as T,P as I,O as q,C as U,b as W,D as K,f as A,s as le,t as oe,v as ie,X as de,w as pe,x as xe,T as ue}from"./index-CAgGM6nb.js";import{d as Q}from"./path-join-7MR1s7b1.js";const me=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],he=V("arrow-up",me);const fe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],be=V("folder-search",fe);const ge=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",ge);const ke=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],ee=V("git-branch",ke),te=t=>{const r=t.trim();if(r.length<2)return r;const i=r[0],s=r[r.length-1];return(i==='"'||i==="'")&&i===s?r.slice(1,-1):r},se=({error:t,onChange:r,presets:i,value:s})=>{const{t:p}=D(),[x,c]=l.useState(!1),a=l.useRef(null),d=i.find(o=>o.id===s),n=s==="",k=d?[d.command,...d.args].join(" ").trim():p(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=d?.displayName??(n?p("workspace.preset.generic"):"Claude Code (CC)"),j=i.length===0&&!n;return l.useEffect(()=>{if(!x)return;const o=f=>{a.current?.contains(f.target)||c(!1)},m=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",m)}},[x]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:p("workspace.preset.label")}),e.jsxs("div",{ref:a,className:"cli-select group relative",children:[e.jsx(ce,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":x,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":s,disabled:j,onClick:()=>c(o=>!o),children:g}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),x&&i.length>0?e.jsxs("div",{role:"listbox","aria-label":p("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[i.map(o=>{const m=o.id===s,f=o.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${o.id}`,className:"cli-select__option",onClick:()=>{r(o.id),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[o.displayName,f?p("workspace.preset.notFoundSuffix"):""]})]},o.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{r(""),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:p("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),ve=({probe:t,pasteFallbackDefault:r=!1,commandPresetError:i,commandPresetId:s,commandPresets:p,onCancel:x,onCommandPresetChange:c,onCreate:a,onOpenServerBrowse:d})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,o]=l.useState(g),[m,f]=l.useState(""),[N,S]=l.useState(r),[C,P]=l.useState(!1),[_,h]=l.useState("");l.useEffect(()=>{o(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const w=te(m),u=N&&w.length>0?w:t?.path??"",y=_.trim(),E=p.find(v=>v.id===s),F=p.length===0&&!i,L=!s&&y.length===0,z=E?.available===!1&&y.length===0,H=L?n("workspace.preset.genericRequiresStartup"):z?n("workspace.preset.notInstalled",{name:E.displayName}):null,$=j.trim().length>0&&u.length>0&&!F&&!L&&!z,O=()=>{$&&a({commandPresetId:s||null,name:j.trim(),path:u,...y?{startupCommand:y}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&x(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(ee,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>o(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(se,{error:i??H,onChange:c,presets:p,value:s}),e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[C?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:x,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:O,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},je=({entries:t,error:r,loading:i,onNavigate:s,onSelect:p,selected:x})=>{const{t:c}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:i?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("common.loading")}):r?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:r}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("workspace.browse.empty")}):e.jsx("ul",{children:t.map(a=>{const d=x===a.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${a.name}`,onClick:()=>p(a.path),onDoubleClick:()=>s(a.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:d?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:a.is_git_repository?e.jsx(ee,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:a.name}),a.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:c("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${a.name}`,onClick:()=>s(a.path),"aria-label":c("workspace.browse.openAria",{name:a.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},a.path)})})})},we=({probe:t,suggestedName:r,onSuggestedNameChange:i})=>{const{t:s}=D(),p=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:s("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:s("workspace.git.short",{branch:t.current_branch??s("workspace.git.detached")})}):p?e.jsx("span",{className:"text-ter text-xs",children:s("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:s("workspace.field.name")}),e.jsx("input",{type:"text",value:r,onChange:x=>i(x.target.value),disabled:!p,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ye=t=>{const i=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),s=i[i.length-1];return s?`~ (${s})`:t},Ne=(t,r)=>{if(!r||!t)return[];const i=[{label:ye(r),path:r}];if(t===r)return i;const s=r.replace(/[\\/]+$/,""),p=t.startsWith(s)?t.slice(s.length).replace(/^[\\/]+/,""):"";if(!p)return i;const x=Q(s),c=p.split(/[\\/]/).filter(Boolean);let a=s;for(const d of c)a=`${a}${x}${d}`,i.push({label:d,path:a});return i},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Ce=t=>{const[r,i]=l.useState(J),[s,p]=l.useState(!1),[x,c]=l.useState(null),[a,d]=l.useState(null),n=l.useRef(0),k=l.useRef(0),g=l.useCallback(async o=>{const m=++n.current;p(!0);try{const f=await le(o);if(n.current!==m)return;i(f),f.ok&&c(f.current_path)}catch{}finally{n.current===m&&p(!1)}},[]);l.useEffect(()=>{if(!t){n.current++,k.current++,i(J),c(null),d(null);return}g("")},[t,g]),l.useEffect(()=>{if(!x){d(null);return}const o=++k.current;oe(x).then(m=>{k.current===o&&d(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[x]);const j=l.useCallback(o=>{c(o)},[]);return{browse:r,loading:s,navigate:g,probe:a,selectEntry:j,selected:x}},_e=({commandPresetError:t,commandPresetId:r,commandPresets:i,onClose:s,onCommandPresetChange:p,onCreate:x,open:c})=>{const{t:a}=D(),{browse:d,loading:n,navigate:k,probe:g,selectEntry:j,selected:o}=Ce(c),[m,f]=l.useState(""),[N,S]=l.useState(!1),[C,P]=l.useState(""),[_,h]=l.useState(!1),[w,u]=l.useState("");if(l.useEffect(()=>{c||(f(""),S(!1),P(""),h(!1),u(""))},[c]),l.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!c)return null;const y=Ne(d.current_path,d.root_path),E=Q(d.current_path||d.root_path),F=te(C),L=i.find(b=>b.id===r),z=w.trim(),H=i.length===0&&!t,$=!r&&z.length===0,O=L?.available===!1&&z.length===0,v=$?a("workspace.preset.genericRequiresStartup"):O?a("workspace.preset.notInstalled",{name:L.displayName}):null,ae=m.trim().length>0&&(g?.is_dir===!0||N&&F.length>0)&&!H&&!$&&!O,re=()=>{const b=N&&F.length>0?F:g?.path??"";b&&x({commandPresetId:r||null,name:m.trim(),path:b,...z?{startupCommand:z}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&s(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:a("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:d.root_path?a("workspace.browse.root",{path:d.root_path}):a("workspace.browse.rootLoading")})]}),e.jsx(ie,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":a("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(de,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":a("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>d.parent_path?k(d.parent_path):null,disabled:!d.parent_path,"aria-label":a("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(he,{size:12,"aria-hidden":!0})," ",a("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),y.map((b,Y)=>{const ne=Y===y.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:E}):null,ne?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(je,{entries:d.entries,error:d.ok?null:d.error,loading:n,onNavigate:k,onSelect:j,selected:o})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(we,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(se,{error:t??v,onChange:p,presets:i,value:r}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.startup"),e.jsx("input",{type:"text",value:w,onChange:b=>u(b.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:a("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:C,onChange:b=>P(b.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:s,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:re,disabled:!ae,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},R="claude",Se=t=>t.some(r=>r.id===R&&r.available)?R:t.find(r=>r.available)?.id??t[0]?.id??R,ze=({trigger:t,onClose:r,onCreate:i})=>{const{t:s}=D(),p=l.useRef(s);l.useEffect(()=>{p.current=s},[s]);const[x,c]=l.useState({kind:"idle"}),[a,d]=l.useState([]),[n,k]=l.useState(R),[g,j]=l.useState(null),o=l.useRef({error:null,id:R,presets:[]}),m=l.useRef(r);l.useEffect(()=>{m.current=r},[r]),l.useEffect(()=>{if(t===0)return;let h=!1;j(null);const w=pe().then(u=>{if(h)return;const y=u.some(E=>E.id===o.current.id&&E.available)?o.current.id:Se(u);o.current={error:null,id:y,presets:u},d(u),k(y)}).catch(()=>{if(h)return;const u=p.current("workspace.preset.loadFailed");o.current={error:u,id:R,presets:[]},d([]),k(R),j(u)});return c({kind:"picking"}),xe().then(async u=>{if(await w,!h){if(u.canceled){if(u.error){c({kind:"error",message:u.error});return}c({kind:"idle"}),m.current();return}if(!u.supported){c({kind:"confirm",probe:null,pasteDefault:!0});return}if(!u.probe?.ok||!u.probe.is_dir){c({kind:"error",message:u.error??p.current("workspace.error.outsideSandbox")});return}c({kind:"confirm",probe:u.probe,pasteDefault:!1})}}).catch(u=>{if(h)return;const y=u instanceof Error?u.message:p.current("workspace.error.pickerFailed");c({kind:"error",message:y})}),()=>{h=!0}},[t]);const f=()=>{c({kind:"idle"}),r()},N=h=>{Promise.resolve(i(h)).then(()=>c({kind:"idle"})).catch(w=>{const u=w instanceof Error?w.message:s("workspace.error.createFailed");c({kind:"error",title:s("workspace.error.createTitle"),message:u})})},S=h=>{o.current={...o.current,id:h},k(h)},C=a.length>0||g?a:o.current.presets,P=n===""?"":C.length>0&&!C.some(h=>h.id===n&&h.available)?o.current.id:n,_=g??o.current.error;if(x.kind==="idle")return null;if(x.kind==="picking"){const h=()=>c({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:w=>!w&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:s("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(be,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:s("workspace.picking.message")})]})]})]})})}return x.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ue,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:x.title??s("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:x.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:s("common.close")}),e.jsx("button",{type:"button",onClick:()=>c({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:s("workspace.error.pastePathInstead")})]})]})})]})}):x.kind==="browse"?e.jsx(_e,{commandPresetError:_,commandPresetId:P,commandPresets:C,onClose:f,onCommandPresetChange:S,onCreate:N,open:!0}):e.jsx(ve,{commandPresetError:_,commandPresetId:P,commandPresets:C,pasteFallbackDefault:x.pasteDefault,probe:x.probe,onCancel:f,onCommandPresetChange:S,onCreate:N,onOpenServerBrowse:()=>c({kind:"browse"})})};export{ze as AddWorkspaceDialog};
1
+ import{c as V,u as D,r as l,j as e,q as ce,e as B,k as Z,a as T,P as I,O as q,C as U,b as W,D as K,f as A,s as le,t as oe,v as ie,X as de,w as pe,x as xe,T as ue}from"./index-CxNL0O-C.js";import{d as Q}from"./path-join-7MR1s7b1.js";const me=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],he=V("arrow-up",me);const fe=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],be=V("folder-search",fe);const ge=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],X=V("folder",ge);const ke=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],ee=V("git-branch",ke),te=t=>{const r=t.trim();if(r.length<2)return r;const i=r[0],s=r[r.length-1];return(i==='"'||i==="'")&&i===s?r.slice(1,-1):r},se=({error:t,onChange:r,presets:i,value:s})=>{const{t:p}=D(),[x,c]=l.useState(!1),a=l.useRef(null),d=i.find(o=>o.id===s),n=s==="",k=d?[d.command,...d.args].join(" ").trim():p(n?"workspace.preset.genericPreview":"workspace.preset.loading"),g=d?.displayName??(n?p("workspace.preset.generic"):"Claude Code (CC)"),j=i.length===0&&!n;return l.useEffect(()=>{if(!x)return;const o=f=>{a.current?.contains(f.target)||c(!1)},m=f=>{f.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",m)}},[x]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:p("workspace.preset.label")}),e.jsxs("div",{ref:a,className:"cli-select group relative",children:[e.jsx(ce,{size:14,"aria-hidden":!0,className:"cli-select__leading"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":x,"aria-disabled":j||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":s,disabled:j,onClick:()=>c(o=>!o),children:g}),e.jsx(B,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),x&&i.length>0?e.jsxs("div",{role:"listbox","aria-label":p("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[i.map(o=>{const m=o.id===s,f=o.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${o.id}`,className:"cli-select__option",onClick:()=>{r(o.id),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsxs("span",{children:[o.displayName,f?p("workspace.preset.notFoundSuffix"):""]})]},o.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":n,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{r(""),c(!1)},children:[e.jsx(Z,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:n?1:0}}),e.jsx("span",{children:p("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:k,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:k})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},G=t=>t.split(/[\\/]/).filter(Boolean).pop()??"",M=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),ve=({probe:t,pasteFallbackDefault:r=!1,commandPresetError:i,commandPresetId:s,commandPresets:p,onCancel:x,onCommandPresetChange:c,onCreate:a,onOpenServerBrowse:d})=>{const{t:n}=D(),k=t?.path??"",g=t?.suggested_name??G(k),[j,o]=l.useState(g),[m,f]=l.useState(""),[N,S]=l.useState(r),[C,P]=l.useState(!1),[_,h]=l.useState("");l.useEffect(()=>{o(t?.suggested_name??G(t?.path??""))},[t?.path,t?.suggested_name]);const w=te(m),u=N&&w.length>0?w:t?.path??"",y=_.trim(),E=p.find(v=>v.id===s),F=p.length===0&&!i,L=!s&&y.length===0,z=E?.available===!1&&y.length===0,H=L?n("workspace.preset.genericRequiresStartup"):z?n("workspace.preset.notInstalled",{name:E.displayName}):null,$=j.trim().length>0&&u.length>0&&!F&&!L&&!z,O=()=>{$&&a({commandPresetId:s||null,name:j.trim(),path:u,...y?{startupCommand:y}:{}})};return e.jsx(T,{open:!0,onOpenChange:v=>!v&&x(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:n("workspace.confirm.title")}),e.jsx(K,{className:"text-xs text-ter",children:n("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.path")}),e.jsx("input",{readOnly:!0,value:t?.path??"",placeholder:n("workspace.field.pathEmptyPlaceholder"),className:"input input--readonly mono","data-testid":"confirm-workspace-path"})]}),t?.is_git_repository?e.jsxs("div",{className:"flex items-center gap-2 text-xs","data-testid":"confirm-workspace-git-badge",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 30%, transparent)"},children:[e.jsx(ee,{size:12,"aria-hidden":!0}),t.current_branch??n("workspace.git.detached")]}),e.jsx("span",{className:"text-ter",children:n("workspace.git.detected")})]}):t?.ok?e.jsx("span",{className:"text-xs text-ter",children:n("workspace.git.none")}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.name")}),e.jsx("input",{value:j,onChange:v=>o(v.target.value),placeholder:G(t?.path??"")||n("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(se,{error:i??H,onChange:c,presets:p,value:s}),e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-startup-toggle",children:[C?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.startup")]}),C?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.startup")}),e.jsx("input",{type:"text",value:_,onChange:v=>h(v.target.value),placeholder:n("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-xs text-ter",children:n("workspace.startup.hint")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(v=>!v),className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-paste-toggle",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:n("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:v=>f(v.target.value),placeholder:n("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"confirm-workspace-paste-path"})]}):null,e.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-1.5 self-start text-xs uppercase tracking-wider text-ter hover:text-sec","data-testid":"confirm-workspace-browse-toggle",children:[e.jsx(A,{size:12,"aria-hidden":!0}),n("workspace.advanced.browse")]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:x,className:"icon-btn",children:n("common.cancel")}),e.jsx("button",{type:"button",onClick:O,disabled:!$,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:n("workspace.confirm.create")})]})]})})]})})},je=({entries:t,error:r,loading:i,onNavigate:s,onSelect:p,selected:x})=>{const{t:c}=D();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:i?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("common.loading")}):r?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:r}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:c("workspace.browse.empty")}):e.jsx("ul",{children:t.map(a=>{const d=x===a.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${a.name}`,onClick:()=>p(a.path),onDoubleClick:()=>s(a.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:d?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:a.is_git_repository?e.jsx(ee,{size:14}):e.jsx(X,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:a.name}),a.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:c("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${a.name}`,onClick:()=>s(a.path),"aria-label":c("workspace.browse.openAria",{name:a.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},a.path)})})})},we=({probe:t,suggestedName:r,onSuggestedNameChange:i})=>{const{t:s}=D(),p=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:s("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:s("workspace.git.short",{branch:t.current_branch??s("workspace.git.detached")})}):p?e.jsx("span",{className:"text-ter text-xs",children:s("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:s("workspace.field.name")}),e.jsx("input",{type:"text",value:r,onChange:x=>i(x.target.value),disabled:!p,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},ye=t=>{const i=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),s=i[i.length-1];return s?`~ (${s})`:t},Ne=(t,r)=>{if(!r||!t)return[];const i=[{label:ye(r),path:r}];if(t===r)return i;const s=r.replace(/[\\/]+$/,""),p=t.startsWith(s)?t.slice(s.length).replace(/^[\\/]+/,""):"";if(!p)return i;const x=Q(s),c=p.split(/[\\/]/).filter(Boolean);let a=s;for(const d of c)a=`${a}${x}${d}`,i.push({label:d,path:a});return i},J={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Ce=t=>{const[r,i]=l.useState(J),[s,p]=l.useState(!1),[x,c]=l.useState(null),[a,d]=l.useState(null),n=l.useRef(0),k=l.useRef(0),g=l.useCallback(async o=>{const m=++n.current;p(!0);try{const f=await le(o);if(n.current!==m)return;i(f),f.ok&&c(f.current_path)}catch{}finally{n.current===m&&p(!1)}},[]);l.useEffect(()=>{if(!t){n.current++,k.current++,i(J),c(null),d(null);return}g("")},[t,g]),l.useEffect(()=>{if(!x){d(null);return}const o=++k.current;oe(x).then(m=>{k.current===o&&d(m)}).catch(m=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",m)})},[x]);const j=l.useCallback(o=>{c(o)},[]);return{browse:r,loading:s,navigate:g,probe:a,selectEntry:j,selected:x}},_e=({commandPresetError:t,commandPresetId:r,commandPresets:i,onClose:s,onCommandPresetChange:p,onCreate:x,open:c})=>{const{t:a}=D(),{browse:d,loading:n,navigate:k,probe:g,selectEntry:j,selected:o}=Ce(c),[m,f]=l.useState(""),[N,S]=l.useState(!1),[C,P]=l.useState(""),[_,h]=l.useState(!1),[w,u]=l.useState("");if(l.useEffect(()=>{c||(f(""),S(!1),P(""),h(!1),u(""))},[c]),l.useEffect(()=>{g?.suggested_name&&f(g.suggested_name)},[g?.suggested_name]),!c)return null;const y=Ne(d.current_path,d.root_path),E=Q(d.current_path||d.root_path),F=te(C),L=i.find(b=>b.id===r),z=w.trim(),H=i.length===0&&!t,$=!r&&z.length===0,O=L?.available===!1&&z.length===0,v=$?a("workspace.preset.genericRequiresStartup"):O?a("workspace.preset.notInstalled",{name:L.displayName}):null,ae=m.trim().length>0&&(g?.is_dir===!0||N&&F.length>0)&&!H&&!$&&!O,re=()=>{const b=N&&F.length>0?F:g?.path??"";b&&x({commandPresetId:r||null,name:m.trim(),path:b,...z?{startupCommand:z}:{}})};return e.jsx(T,{open:!0,onOpenChange:b=>!b&&s(),children:e.jsxs(I,{children:[e.jsx(q,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border",style:{height:"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(X,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:a("workspace.browse.title")}),e.jsx(K,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:d.root_path?a("workspace.browse.root",{path:d.root_path}):a("workspace.browse.rootLoading")})]}),e.jsx(ie,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":a("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(de,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":a("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>d.parent_path?k(d.parent_path):null,disabled:!d.parent_path,"aria-label":a("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(he,{size:12,"aria-hidden":!0})," ",a("workspace.browse.up")]}),e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),y.map((b,Y)=>{const ne=Y===y.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[Y>0?e.jsx("span",{className:"text-ter",children:E}):null,ne?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:b.label}):e.jsx("button",{type:"button",onClick:()=>k(b.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:b.label})]},b.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(je,{entries:d.entries,error:d.ok?null:d.error,loading:n,onNavigate:k,onSelect:j,selected:o})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4",style:{borderColor:"var(--border)"},children:[e.jsx(we,{onSuggestedNameChange:f,probe:g,suggestedName:m}),e.jsx(se,{error:t??v,onChange:p,presets:i,value:r}),e.jsxs("button",{type:"button",onClick:()=>h(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[_?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.startup")]}),_?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.startup"),e.jsx("input",{type:"text",value:w,onChange:b=>u(b.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter",children:a("workspace.startup.hintShort")})]}):null,e.jsxs("button",{type:"button",onClick:()=>S(b=>!b),className:"flex items-center gap-1.5 text-left text-xs uppercase tracking-wider text-ter hover:text-sec",children:[N?e.jsx(B,{size:12,"aria-hidden":!0}):e.jsx(A,{size:12,"aria-hidden":!0}),a("workspace.advanced.pastePath")]}),N?e.jsxs("label",{className:"flex flex-col gap-2 text-xs uppercase tracking-wider text-ter",children:[a("workspace.field.absolutePath"),e.jsx("input",{type:"text",value:C,onChange:b=>P(b.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono","data-testid":"fs-manual-path"})]}):null]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:s,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:re,disabled:!ae,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},R="claude",Se=t=>t.some(r=>r.id===R&&r.available)?R:t.find(r=>r.available)?.id??t[0]?.id??R,ze=({trigger:t,onClose:r,onCreate:i})=>{const{t:s}=D(),p=l.useRef(s);l.useEffect(()=>{p.current=s},[s]);const[x,c]=l.useState({kind:"idle"}),[a,d]=l.useState([]),[n,k]=l.useState(R),[g,j]=l.useState(null),o=l.useRef({error:null,id:R,presets:[]}),m=l.useRef(r);l.useEffect(()=>{m.current=r},[r]),l.useEffect(()=>{if(t===0)return;let h=!1;j(null);const w=pe().then(u=>{if(h)return;const y=u.some(E=>E.id===o.current.id&&E.available)?o.current.id:Se(u);o.current={error:null,id:y,presets:u},d(u),k(y)}).catch(()=>{if(h)return;const u=p.current("workspace.preset.loadFailed");o.current={error:u,id:R,presets:[]},d([]),k(R),j(u)});return c({kind:"picking"}),xe().then(async u=>{if(await w,!h){if(u.canceled){if(u.error){c({kind:"error",message:u.error});return}c({kind:"idle"}),m.current();return}if(!u.supported){c({kind:"confirm",probe:null,pasteDefault:!0});return}if(!u.probe?.ok||!u.probe.is_dir){c({kind:"error",message:u.error??p.current("workspace.error.outsideSandbox")});return}c({kind:"confirm",probe:u.probe,pasteDefault:!1})}}).catch(u=>{if(h)return;const y=u instanceof Error?u.message:p.current("workspace.error.pickerFailed");c({kind:"error",message:y})}),()=>{h=!0}},[t]);const f=()=>{c({kind:"idle"}),r()},N=h=>{Promise.resolve(i(h)).then(()=>c({kind:"idle"})).catch(w=>{const u=w instanceof Error?w.message:s("workspace.error.createFailed");c({kind:"error",title:s("workspace.error.createTitle"),message:u})})},S=h=>{o.current={...o.current,id:h},k(h)},C=a.length>0||g?a:o.current.presets,P=n===""?"":C.length>0&&!C.some(h=>h.id===n&&h.available)?o.current.id:n,_=g??o.current.error;if(x.kind==="idle")return null;if(x.kind==="picking"){const h=()=>c({kind:"idle"});return e.jsx(T,{open:!0,onOpenChange:w=>!w&&h(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(U,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(W,{className:"sr-only",children:s("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(be,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:s("workspace.picking.message")})]})]})]})})}return x.kind==="error"?e.jsx(T,{open:!0,onOpenChange:h=>!h&&f(),children:e.jsxs(I,{children:[e.jsx(q,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(U,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ue,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(W,{className:"text-lg font-semibold text-pri",children:x.title??s("workspace.error.pickerFailed")}),e.jsx(K,{className:"mt-1.5 break-words text-sm text-ter",children:x.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:f,className:"icon-btn",children:s("common.close")}),e.jsx("button",{type:"button",onClick:()=>c({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:s("workspace.error.pastePathInstead")})]})]})})]})}):x.kind==="browse"?e.jsx(_e,{commandPresetError:_,commandPresetId:P,commandPresets:C,onClose:f,onCommandPresetChange:S,onCreate:N,open:!0}):e.jsx(ve,{commandPresetError:_,commandPresetId:P,commandPresets:C,pasteFallbackDefault:x.pasteDefault,probe:x.probe,onCancel:f,onCommandPresetChange:S,onCreate:N,onOpenServerBrowse:()=>c({kind:"browse"})})};export{ze as AddWorkspaceDialog};
@@ -1 +1 @@
1
- import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-CAgGM6nb.js";const R=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],k=f("hexagon",R),w=({open:o,onClose:r,onAddWorkspace:x,onTryDemo:d})=>{const{t:s}=h(),[n,l]=j.useState(0),u=t=>{t||(l(0),r())},i=(t=!0)=>{l(0),r(t)},a=n===2;return e.jsx(b,{open:o,onOpenChange:u,children:e.jsxs(N,{children:[e.jsx(v,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(y,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[n===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(k,{size:32})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),n>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:m,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:m}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{x(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{d(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{w as FirstRunWizard};
1
+ import{c as f,u as h,r as j,j as e,a as b,P as N,O as v,C as y,D as g,b as c}from"./index-CxNL0O-C.js";const R=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],k=f("hexagon",R),w=({open:o,onClose:r,onAddWorkspace:x,onTryDemo:d})=>{const{t:s}=h(),[n,l]=j.useState(0),u=t=>{t||(l(0),r())},i=(t=!0)=>{l(0),r(t)},a=n===2;return e.jsx(b,{open:o,onOpenChange:u,children:e.jsxs(N,{children:[e.jsx(v,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(y,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[n===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(k,{size:32})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),n>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),n===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:m,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:m}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),n===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{x(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{d(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:n+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>l(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{w as FirstRunWizard};
@@ -1,4 +1,4 @@
1
- import{c as Pn,r as R,u as st,j as m,L as lr,M as or,a as cr,P as ur,O as pr,C as hr,b as fr,D as dr,v as mr,X as gr}from"./index-CAgGM6nb.js";import{S as kr}from"./AddWorkerDialog-CGbaxu0T.js";const xr=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],br=Pn("bookmark",xr);const Tr=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],wr=Pn("external-link",Tr),yr={academic:{en:"Academic",zh:"学术"},design:{en:"Design",zh:"设计"},engineering:{en:"Engineering",zh:"工程"},finance:{en:"Finance",zh:"金融"},"game-development":{en:"Game Development",zh:"游戏开发"},hr:{en:"HR",zh:"人力资源"},integrations:{en:"System Integrations",zh:"系统集成"},legal:{en:"Legal",zh:"法务"},marketing:{en:"Marketing",zh:"营销"},misc:{en:"Misc",zh:"其他"},"paid-media":{en:"Paid Ads",zh:"广告投放"},product:{en:"Product",zh:"产品"},"project-management":{en:"Project Management",zh:"项目管理"},sales:{en:"Sales",zh:"销售"},"spatial-computing":{en:"Spatial Computing",zh:"空间计算"},specialized:{en:"Industry Verticals",zh:"行业角色"},"supply-chain":{en:"Supply Chain",zh:"供应链"},support:{en:"Support",zh:"客户支持"},testing:{en:"Testing",zh:"测试"}},Ar=t=>t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Sr=(t,e)=>{const n=yr[t];return n?n[e]:Ar(t)},_r=["engineering","testing","product","design","project-management","integrations","specialized","marketing","paid-media","sales","finance","legal","hr","supply-chain","support","academic","game-development","spatial-computing","misc"],Er=(t,e)=>{if(e!=="zh")return t;const n=new Map(_r.map((s,r)=>[s,r]));return[...t].sort((s,r)=>{const i=n.get(s)??Number.POSITIVE_INFINITY,l=n.get(r)??Number.POSITIVE_INFINITY;return i!==l?i-l:s.localeCompare(r)})},Rr=t=>t?"color-mix(in oklab, var(--accent) 14%, var(--bg-2))":"var(--bg-2)",Nr=t=>t?"var(--accent)":"var(--border-bright)",Cr=({agent:t,selected:e,imported:n,onSelect:s})=>{const{t:r}=st(),i=R.useCallback(()=>s(t.path),[t.path,s]),l=t.vibe?.trim()?t.vibe:t.description,o=r("marketplace.importedBadge"),p=t.displayName??t.name,c=t.nameOverflows?p:void 0;return m.jsxs("button",{type:"button",onClick:i,"data-testid":"marketplace-agent-card","data-agent-path":t.path,"data-imported":n?"true":void 0,"data-selected":e?"true":void 0,className:"marketplace-card flex w-full cursor-pointer flex-col gap-1.5 rounded-md border px-3 py-2.5 text-left outline-none transition-[background,border-color,transform] duration-100 ease-out focus-visible:ring-2 focus-visible:ring-offset-0 active:translate-y-px",style:{background:Rr(e),borderColor:Nr(e),"--tw-ring-color":"color-mix(in oklab, var(--accent) 55%, transparent)"},children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.emoji?m.jsx("span",{className:"text-base leading-none",children:t.emoji}):null,m.jsx("span",{className:"truncate text-sm font-semibold text-pri",title:c,children:p})]}),n?m.jsx("span",{role:"img","aria-label":o,title:o,"data-testid":"marketplace-agent-imported",className:"flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider",style:{background:e?"var(--accent)":"color-mix(in oklab, var(--accent) 28%, transparent)",color:e?"#ffffff":"color-mix(in oklab, var(--accent) 60%, white)"},children:m.jsx(br,{size:10,"aria-hidden":!0})}):null]}),m.jsx("p",{className:"line-clamp-1 text-xs leading-snug text-sec",children:l})]})},Ir=R.memo(Cr);function fn(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,s=Array(e);n<e;n++)s[n]=t[n];return s}function Or(t){if(Array.isArray(t))return t}function Lr(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,r,i,l,o=[],p=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(p=(s=i.call(n)).done)&&(o.push(s.value),o.length!==e);p=!0);}catch(f){c=!0,r=f}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}function Dr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{c as Pn,r as R,u as st,j as m,L as lr,M as or,a as cr,P as ur,O as pr,C as hr,b as fr,D as dr,v as mr,X as gr}from"./index-CxNL0O-C.js";import{S as kr}from"./AddWorkerDialog-BRUxpa3f.js";const xr=[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],br=Pn("bookmark",xr);const Tr=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],wr=Pn("external-link",Tr),yr={academic:{en:"Academic",zh:"学术"},design:{en:"Design",zh:"设计"},engineering:{en:"Engineering",zh:"工程"},finance:{en:"Finance",zh:"金融"},"game-development":{en:"Game Development",zh:"游戏开发"},hr:{en:"HR",zh:"人力资源"},integrations:{en:"System Integrations",zh:"系统集成"},legal:{en:"Legal",zh:"法务"},marketing:{en:"Marketing",zh:"营销"},misc:{en:"Misc",zh:"其他"},"paid-media":{en:"Paid Ads",zh:"广告投放"},product:{en:"Product",zh:"产品"},"project-management":{en:"Project Management",zh:"项目管理"},sales:{en:"Sales",zh:"销售"},"spatial-computing":{en:"Spatial Computing",zh:"空间计算"},specialized:{en:"Industry Verticals",zh:"行业角色"},"supply-chain":{en:"Supply Chain",zh:"供应链"},support:{en:"Support",zh:"客户支持"},testing:{en:"Testing",zh:"测试"}},Ar=t=>t.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase()),Sr=(t,e)=>{const n=yr[t];return n?n[e]:Ar(t)},_r=["engineering","testing","product","design","project-management","integrations","specialized","marketing","paid-media","sales","finance","legal","hr","supply-chain","support","academic","game-development","spatial-computing","misc"],Er=(t,e)=>{if(e!=="zh")return t;const n=new Map(_r.map((s,r)=>[s,r]));return[...t].sort((s,r)=>{const i=n.get(s)??Number.POSITIVE_INFINITY,l=n.get(r)??Number.POSITIVE_INFINITY;return i!==l?i-l:s.localeCompare(r)})},Rr=t=>t?"color-mix(in oklab, var(--accent) 14%, var(--bg-2))":"var(--bg-2)",Nr=t=>t?"var(--accent)":"var(--border-bright)",Cr=({agent:t,selected:e,imported:n,onSelect:s})=>{const{t:r}=st(),i=R.useCallback(()=>s(t.path),[t.path,s]),l=t.vibe?.trim()?t.vibe:t.description,o=r("marketplace.importedBadge"),p=t.displayName??t.name,c=t.nameOverflows?p:void 0;return m.jsxs("button",{type:"button",onClick:i,"data-testid":"marketplace-agent-card","data-agent-path":t.path,"data-imported":n?"true":void 0,"data-selected":e?"true":void 0,className:"marketplace-card flex w-full cursor-pointer flex-col gap-1.5 rounded-md border px-3 py-2.5 text-left outline-none transition-[background,border-color,transform] duration-100 ease-out focus-visible:ring-2 focus-visible:ring-offset-0 active:translate-y-px",style:{background:Rr(e),borderColor:Nr(e),"--tw-ring-color":"color-mix(in oklab, var(--accent) 55%, transparent)"},children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.emoji?m.jsx("span",{className:"text-base leading-none",children:t.emoji}):null,m.jsx("span",{className:"truncate text-sm font-semibold text-pri",title:c,children:p})]}),n?m.jsx("span",{role:"img","aria-label":o,title:o,"data-testid":"marketplace-agent-imported",className:"flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider",style:{background:e?"var(--accent)":"color-mix(in oklab, var(--accent) 28%, transparent)",color:e?"#ffffff":"color-mix(in oklab, var(--accent) 60%, white)"},children:m.jsx(br,{size:10,"aria-hidden":!0})}):null]}),m.jsx("p",{className:"line-clamp-1 text-xs leading-snug text-sec",children:l})]})},Ir=R.memo(Cr);function fn(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,s=Array(e);n<e;n++)s[n]=t[n];return s}function Or(t){if(Array.isArray(t))return t}function Lr(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,r,i,l,o=[],p=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(p=(s=i.call(n)).done)&&(o.push(s.value),o.length!==e);p=!0);}catch(f){c=!0,r=f}finally{try{if(!p&&n.return!=null&&(l=n.return(),Object(l)!==l))return}finally{if(c)throw r}}return o}}function Dr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vr(t,e){return Or(t)||Lr(t,e)||Mr(t,e)||Dr()}function Mr(t,e){if(t){if(typeof t=="string")return fn(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fn(t,e):void 0}}const zn=Object.entries,dn=Object.setPrototypeOf,Pr=Object.isFrozen,zr=Object.getPrototypeOf,$r=Object.getOwnPropertyDescriptor;let G=Object.freeze,Y=Object.seal,Ce=Object.create,$n=typeof Reflect<"u"&&Reflect,Rt=$n.apply,Nt=$n.construct;G||(G=function(e){return e});Y||(Y=function(e){return e});Rt||(Rt=function(e,n){for(var s=arguments.length,r=new Array(s>2?s-2:0),i=2;i<s;i++)r[i-2]=arguments[i];return e.apply(n,r)});Nt||(Nt=function(e){for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return new e(...s)});const Se=D(Array.prototype.forEach),jr=D(Array.prototype.lastIndexOf),mn=D(Array.prototype.pop),_e=D(Array.prototype.push),Fr=D(Array.prototype.splice),H=Array.isArray,$e=D(String.prototype.toLowerCase),yt=D(String.prototype.toString),gn=D(String.prototype.match),Ee=D(String.prototype.replace),kn=D(String.prototype.indexOf),Br=D(String.prototype.trim),Ur=D(Number.prototype.toString),Hr=D(Boolean.prototype.toString),xn=typeof BigInt>"u"?null:D(BigInt.prototype.toString),bn=typeof Symbol>"u"?null:D(Symbol.prototype.toString),N=D(Object.prototype.hasOwnProperty),Pe=D(Object.prototype.toString),B=D(RegExp.prototype.test),Qe=Gr(TypeError);function D(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),r=1;r<n;r++)s[r-1]=arguments[r];return Rt(t,e,s)}}function Gr(t){return function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return Nt(t,n)}}function k(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$e;if(dn&&dn(t,null),!H(e))return t;let s=e.length;for(;s--;){let r=e[s];if(typeof r=="string"){const i=n(r);i!==r&&(Pr(e)||(e[s]=i),r=i)}t[r]=!0}return t}function Wr(t){for(let e=0;e<t.length;e++)N(t,e)||(t[e]=null);return t}function q(t){const e=Ce(null);for(const s of zn(t)){var n=vr(s,2);const r=n[0],i=n[1];N(t,r)&&(H(i)?e[r]=Wr(i):i&&typeof i=="object"&&i.constructor===Object?e[r]=q(i):e[r]=i)}return e}function qr(t){switch(typeof t){case"string":return t;case"number":return Ur(t);case"boolean":return Hr(t);case"bigint":return xn?xn(t):"0";case"symbol":return bn?bn(t):"Symbol()";case"undefined":return Pe(t);case"function":case"object":{if(t===null)return Pe(t);const e=t,n=he(e,"toString");if(typeof n=="function"){const s=n(e);return typeof s=="string"?s:Pe(s)}return Pe(t)}default:return Pe(t)}}function he(t,e){for(;t!==null;){const s=$r(t,e);if(s){if(s.get)return D(s.get);if(typeof s.value=="function")return D(s.value)}t=zr(t)}function n(){return null}return n}function Yr(t){try{return B(t,""),!0}catch{return!1}}const Tn=G(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),At=G(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),St=G(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Zr=G(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),_t=G(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Xr=G(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wn=G(["#text"]),yn=G(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Et=G(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),An=G(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ke=G(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Vr=Y(/{{[\w\W]*|^[\w\W]*}}/g),Qr=Y(/<%[\w\W]*|^[\w\W]*%>/g),Kr=Y(/\${[\w\W]*/g),Jr=Y(/^data-[\-\w.\u00B7-\uFFFF]+$/),es=Y(/^aria-[\-\w]+$/),Sn=Y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ts=Y(/^(?:\w+script|data):/i),ns=Y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rs=Y(/^html$/i),ss=Y(/^[a-z][.\w]*(-[.\w]+)+$/i),Re={element:1,text:3,progressingInstruction:7,comment:8,document:9},is=function(){return typeof window>"u"?null:window},as=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let s=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(s=n.getAttribute(r));const i="dompurify"+(s?"#"+s:"");try{return e.createPolicy(i,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},_n=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function jn(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:is();const e=g=>jn(g);if(e.version="3.4.5",e.removed=[],!t||!t.document||t.document.nodeType!==Re.document||!t.Element)return e.isSupported=!1,e;let n=t.document;const s=n,r=s.currentScript,i=t.DocumentFragment,l=t.HTMLTemplateElement,o=t.Node,p=t.Element,c=t.NodeFilter,f=t.NamedNodeMap,d=f===void 0?t.NamedNodeMap||t.MozNamedAttrMap:f,x=t.HTMLFormElement,_=t.DOMParser,y=t.trustedTypes,C=p.prototype,ge=he(C,"cloneNode"),ke=he(C,"remove"),S=he(C,"nextSibling"),xe=he(C,"childNodes"),ee=he(C,"parentNode"),re=o&&o.prototype?he(o.prototype,"nodeType"):null;if(typeof l=="function"){const g=n.createElement("template");g.content&&g.content.ownerDocument&&(n=g.content.ownerDocument)}let E,oe="";const ce=n,Oe=ce.implementation,Be=ce.createNodeIterator,lt=ce.createDocumentFragment,T=ce.getElementsByTagName,z=s.importNode;let M=_n();e.isSupported=typeof zn=="function"&&typeof ee=="function"&&Oe&&Oe.createHTMLDocument!==void 0;const be=Vr,Ue=Qr,He=Kr,Vn=Jr,Qn=es,Kn=ts,Bt=ns,Jn=ss;let Ut=Sn,$=null;const Ht=k({},[...Tn,...At,...St,..._t,...wn]);let F=null;const Gt=k({},[...yn,...Et,...An,...Ke]);let I=Object.seal(Ce(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Le=null,Ge=null;const se=Object.seal(Ce(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Wt=!0,ot=!0,qt=!1,Yt=!0,ie=!1,De=!0,ue=!1,ct=!1,ut=!1,Te=!1,We=!1,qe=!1,Zt=!0,Xt=!1;const Vt="user-content-";let pt=!0,ve=!1,we={},Q=null;const ht=k({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Qt=null;const Kt=k({},["audio","video","img","source","image","track"]);let ft=null;const Jt=k({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ye="http://www.w3.org/1998/Math/MathML",Ze="http://www.w3.org/2000/svg",K="http://www.w3.org/1999/xhtml";let ye=K,dt=!1,mt=null;const er=k({},[Ye,Ze,K],yt);let gt=k({},["mi","mo","mn","ms","mtext"]),kt=k({},["annotation-xml"]);const tr=k({},["title","style","font","a","script"]);let Me=null;const nr=["application/xhtml+xml","text/html"],rr="text/html";let P=null,Ae=null;const sr=n.createElement("form"),en=function(a){return a instanceof RegExp||a instanceof Function},xt=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ae&&Ae===a)return;(!a||typeof a!="object")&&(a={}),a=q(a),Me=nr.indexOf(a.PARSER_MEDIA_TYPE)===-1?rr:a.PARSER_MEDIA_TYPE,P=Me==="application/xhtml+xml"?yt:$e,$=N(a,"ALLOWED_TAGS")&&H(a.ALLOWED_TAGS)?k({},a.ALLOWED_TAGS,P):Ht,F=N(a,"ALLOWED_ATTR")&&H(a.ALLOWED_ATTR)?k({},a.ALLOWED_ATTR,P):Gt,mt=N(a,"ALLOWED_NAMESPACES")&&H(a.ALLOWED_NAMESPACES)?k({},a.ALLOWED_NAMESPACES,yt):er,ft=N(a,"ADD_URI_SAFE_ATTR")&&H(a.ADD_URI_SAFE_ATTR)?k(q(Jt),a.ADD_URI_SAFE_ATTR,P):Jt,Qt=N(a,"ADD_DATA_URI_TAGS")&&H(a.ADD_DATA_URI_TAGS)?k(q(Kt),a.ADD_DATA_URI_TAGS,P):Kt,Q=N(a,"FORBID_CONTENTS")&&H(a.FORBID_CONTENTS)?k({},a.FORBID_CONTENTS,P):ht,Le=N(a,"FORBID_TAGS")&&H(a.FORBID_TAGS)?k({},a.FORBID_TAGS,P):q({}),Ge=N(a,"FORBID_ATTR")&&H(a.FORBID_ATTR)?k({},a.FORBID_ATTR,P):q({}),we=N(a,"USE_PROFILES")?a.USE_PROFILES&&typeof a.USE_PROFILES=="object"?q(a.USE_PROFILES):a.USE_PROFILES:!1,Wt=a.ALLOW_ARIA_ATTR!==!1,ot=a.ALLOW_DATA_ATTR!==!1,qt=a.ALLOW_UNKNOWN_PROTOCOLS||!1,Yt=a.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ie=a.SAFE_FOR_TEMPLATES||!1,De=a.SAFE_FOR_XML!==!1,ue=a.WHOLE_DOCUMENT||!1,Te=a.RETURN_DOM||!1,We=a.RETURN_DOM_FRAGMENT||!1,qe=a.RETURN_TRUSTED_TYPE||!1,ut=a.FORCE_BODY||!1,Zt=a.SANITIZE_DOM!==!1,Xt=a.SANITIZE_NAMED_PROPS||!1,pt=a.KEEP_CONTENT!==!1,ve=a.IN_PLACE||!1,Ut=Yr(a.ALLOWED_URI_REGEXP)?a.ALLOWED_URI_REGEXP:Sn,ye=typeof a.NAMESPACE=="string"?a.NAMESPACE:K,gt=N(a,"MATHML_TEXT_INTEGRATION_POINTS")&&a.MATHML_TEXT_INTEGRATION_POINTS&&typeof a.MATHML_TEXT_INTEGRATION_POINTS=="object"?q(a.MATHML_TEXT_INTEGRATION_POINTS):k({},["mi","mo","mn","ms","mtext"]),kt=N(a,"HTML_INTEGRATION_POINTS")&&a.HTML_INTEGRATION_POINTS&&typeof a.HTML_INTEGRATION_POINTS=="object"?q(a.HTML_INTEGRATION_POINTS):k({},["annotation-xml"]);const u=N(a,"CUSTOM_ELEMENT_HANDLING")&&a.CUSTOM_ELEMENT_HANDLING&&typeof a.CUSTOM_ELEMENT_HANDLING=="object"?q(a.CUSTOM_ELEMENT_HANDLING):Ce(null);if(I=Ce(null),N(u,"tagNameCheck")&&en(u.tagNameCheck)&&(I.tagNameCheck=u.tagNameCheck),N(u,"attributeNameCheck")&&en(u.attributeNameCheck)&&(I.attributeNameCheck=u.attributeNameCheck),N(u,"allowCustomizedBuiltInElements")&&typeof u.allowCustomizedBuiltInElements=="boolean"&&(I.allowCustomizedBuiltInElements=u.allowCustomizedBuiltInElements),ie&&(ot=!1),We&&(Te=!0),we&&($=k({},wn),F=Ce(null),we.html===!0&&(k($,Tn),k(F,yn)),we.svg===!0&&(k($,At),k(F,Et),k(F,Ke)),we.svgFilters===!0&&(k($,St),k(F,Et),k(F,Ke)),we.mathMl===!0&&(k($,_t),k(F,An),k(F,Ke))),se.tagCheck=null,se.attributeCheck=null,N(a,"ADD_TAGS")&&(typeof a.ADD_TAGS=="function"?se.tagCheck=a.ADD_TAGS:H(a.ADD_TAGS)&&($===Ht&&($=q($)),k($,a.ADD_TAGS,P))),N(a,"ADD_ATTR")&&(typeof a.ADD_ATTR=="function"?se.attributeCheck=a.ADD_ATTR:H(a.ADD_ATTR)&&(F===Gt&&(F=q(F)),k(F,a.ADD_ATTR,P))),N(a,"ADD_URI_SAFE_ATTR")&&H(a.ADD_URI_SAFE_ATTR)&&k(ft,a.ADD_URI_SAFE_ATTR,P),N(a,"FORBID_CONTENTS")&&H(a.FORBID_CONTENTS)&&(Q===ht&&(Q=q(Q)),k(Q,a.FORBID_CONTENTS,P)),N(a,"ADD_FORBID_CONTENTS")&&H(a.ADD_FORBID_CONTENTS)&&(Q===ht&&(Q=q(Q)),k(Q,a.ADD_FORBID_CONTENTS,P)),pt&&($["#text"]=!0),ue&&k($,["html","head","body"]),$.table&&(k($,["tbody"]),delete Le.tbody),a.TRUSTED_TYPES_POLICY){if(typeof a.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof a.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=a.TRUSTED_TYPES_POLICY,oe=E.createHTML("")}else E===void 0&&(E=as(y,r)),E!==null&&typeof oe=="string"&&(oe=E.createHTML(""));G&&G(a),Ae=a},tn=k({},[...At,...St,...Zr]),nn=k({},[..._t,...Xr]),ir=function(a){let u=ee(a);(!u||!u.tagName)&&(u={namespaceURI:ye,tagName:"template"});const h=$e(a.tagName),b=$e(u.tagName);return mt[a.namespaceURI]?a.namespaceURI===Ze?u.namespaceURI===K?h==="svg":u.namespaceURI===Ye?h==="svg"&&(b==="annotation-xml"||gt[b]):!!tn[h]:a.namespaceURI===Ye?u.namespaceURI===K?h==="math":u.namespaceURI===Ze?h==="math"&&kt[b]:!!nn[h]:a.namespaceURI===K?u.namespaceURI===Ze&&!kt[b]||u.namespaceURI===Ye&&!gt[b]?!1:!nn[h]&&(tr[h]||!tn[h]):!!(Me==="application/xhtml+xml"&&mt[a.namespaceURI]):!1},Z=function(a){_e(e.removed,{element:a});try{ee(a).removeChild(a)}catch{ke(a)}},pe=function(a,u){try{_e(e.removed,{attribute:u.getAttributeNode(a),from:u})}catch{_e(e.removed,{attribute:null,from:u})}if(u.removeAttribute(a),a==="is")if(Te||We)try{Z(u)}catch{}else try{u.setAttribute(a,"")}catch{}},rn=function(a){let u=null,h=null;if(ut)a="<remove></remove>"+a;else{const L=gn(a,/^[\r\n\t ]+/);h=L&&L[0]}Me==="application/xhtml+xml"&&ye===K&&(a='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+a+"</body></html>");const b=E?E.createHTML(a):a;if(ye===K)try{u=new _().parseFromString(b,Me)}catch{}if(!u||!u.documentElement){u=Oe.createDocument(ye,"template",null);try{u.documentElement.innerHTML=dt?oe:b}catch{}}const O=u.body||u.documentElement;return a&&h&&O.insertBefore(n.createTextNode(h),O.childNodes[0]||null),ye===K?T.call(u,ue?"html":"body")[0]:ue?u.documentElement:O},sn=function(a){return Be.call(a.ownerDocument||a,a,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},an=function(a){a.normalize();const u=Be.call(a.ownerDocument||a,a,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let h=u.nextNode();for(;h;){let b=h.data;Se([be,Ue,He],O=>{b=Ee(b,O," ")}),h.data=b,h=u.nextNode()}},bt=function(a){return a instanceof x&&(typeof a.nodeName!="string"||typeof a.textContent!="string"||typeof a.removeChild!="function"||!(a.attributes instanceof d)||typeof a.removeAttribute!="function"||typeof a.setAttribute!="function"||typeof a.namespaceURI!="string"||typeof a.insertBefore!="function"||typeof a.hasChildNodes!="function")},Xe=function(a){if(!re||typeof a!="object"||a===null)return!1;try{return typeof re(a)=="number"}catch{return!1}};function te(g,a,u){Se(g,h=>{h.call(e,a,u,Ae)})}const ln=function(a){let u=null;if(te(M.beforeSanitizeElements,a,null),bt(a))return Z(a),!0;const h=P(a.nodeName);if(te(M.uponSanitizeElement,a,{tagName:h,allowedTags:$}),De&&a.hasChildNodes()&&!Xe(a.firstElementChild)&&B(/<[/\w!]/g,a.innerHTML)&&B(/<[/\w!]/g,a.textContent)||De&&a.namespaceURI===K&&h==="style"&&Xe(a.firstElementChild)||a.nodeType===Re.progressingInstruction||De&&a.nodeType===Re.comment&&B(/<[/\w]/g,a.data))return Z(a),!0;if(Le[h]||!(se.tagCheck instanceof Function&&se.tagCheck(h))&&!$[h]){if(!Le[h]&&cn(h)&&(I.tagNameCheck instanceof RegExp&&B(I.tagNameCheck,h)||I.tagNameCheck instanceof Function&&I.tagNameCheck(h)))return!1;if(pt&&!Q[h]){const b=ee(a)||a.parentNode,O=xe(a)||a.childNodes;if(O&&b){const L=O.length;for(let W=L-1;W>=0;--W){const ae=ge(O[W],!0);b.insertBefore(ae,S(a))}}}return Z(a),!0}return a instanceof p&&!ir(a)||(h==="noscript"||h==="noembed"||h==="noframes")&&B(/<\/no(script|embed|frames)/i,a.innerHTML)?(Z(a),!0):(ie&&a.nodeType===Re.text&&(u=a.textContent,Se([be,Ue,He],b=>{u=Ee(u,b," ")}),a.textContent!==u&&(_e(e.removed,{element:a.cloneNode()}),a.textContent=u)),te(M.afterSanitizeElements,a,null),!1)},on=function(a,u,h){if(Ge[u]||Zt&&(u==="id"||u==="name")&&(h in n||h in sr))return!1;const b=F[u]||se.attributeCheck instanceof Function&&se.attributeCheck(u,a);if(!(ot&&!Ge[u]&&B(Vn,u))){if(!(Wt&&B(Qn,u))){if(!b||Ge[u]){if(!(cn(a)&&(I.tagNameCheck instanceof RegExp&&B(I.tagNameCheck,a)||I.tagNameCheck instanceof Function&&I.tagNameCheck(a))&&(I.attributeNameCheck instanceof RegExp&&B(I.attributeNameCheck,u)||I.attributeNameCheck instanceof Function&&I.attributeNameCheck(u,a))||u==="is"&&I.allowCustomizedBuiltInElements&&(I.tagNameCheck instanceof RegExp&&B(I.tagNameCheck,h)||I.tagNameCheck instanceof Function&&I.tagNameCheck(h))))return!1}else if(!ft[u]){if(!B(Ut,Ee(h,Bt,""))){if(!((u==="src"||u==="xlink:href"||u==="href")&&a!=="script"&&kn(h,"data:")===0&&Qt[a])){if(!(qt&&!B(Kn,Ee(h,Bt,"")))){if(h)return!1}}}}}}return!0},ar=k({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),cn=function(a){return!ar[$e(a)]&&B(Jn,a)},un=function(a){te(M.beforeSanitizeAttributes,a,null);const u=a.attributes;if(!u||bt(a))return;const h={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:F,forceKeepAttr:void 0};let b=u.length;for(;b--;){const O=u[b],L=O.name,W=O.namespaceURI,ae=O.value,ne=P(L),wt=ae;let j=L==="value"?wt:Br(wt);if(h.attrName=ne,h.attrValue=j,h.keepAttr=!0,h.forceKeepAttr=void 0,te(M.uponSanitizeAttribute,a,h),j=h.attrValue,Xt&&(ne==="id"||ne==="name")&&kn(j,Vt)!==0&&(pe(L,a),j=Vt+j),De&&B(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,j)){pe(L,a);continue}if(ne==="attributename"&&gn(j,"href")){pe(L,a);continue}if(h.forceKeepAttr)continue;if(!h.keepAttr){pe(L,a);continue}if(!Yt&&B(/\/>/i,j)){pe(L,a);continue}ie&&Se([be,Ue,He],hn=>{j=Ee(j,hn," ")});const pn=P(a.nodeName);if(!on(pn,ne,j)){pe(L,a);continue}if(E&&typeof y=="object"&&typeof y.getAttributeType=="function"&&!W)switch(y.getAttributeType(pn,ne)){case"TrustedHTML":{j=E.createHTML(j);break}case"TrustedScriptURL":{j=E.createScriptURL(j);break}}if(j!==wt)try{W?a.setAttributeNS(W,L,j):a.setAttribute(L,j),bt(a)?Z(a):mn(e.removed)}catch{pe(L,a)}}te(M.afterSanitizeAttributes,a,null)},Tt=function(a){let u=null;const h=sn(a);for(te(M.beforeSanitizeShadowDOM,a,null);u=h.nextNode();)te(M.uponSanitizeShadowNode,u,null),ln(u),un(u),u.content instanceof i&&Tt(u.content);te(M.afterSanitizeShadowDOM,a,null)},Ve=function(a){if(a.nodeType===Re.element&&a.shadowRoot instanceof i){const b=a.shadowRoot;Ve(b),Tt(b)}const u=a.childNodes;if(!u)return;const h=[];Se(u,b=>{_e(h,b)});for(const b of h)Ve(b)};return e.sanitize=function(g){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u=null,h=null,b=null,O=null;if(dt=!g,dt&&(g="<!-->"),typeof g!="string"&&!Xe(g)&&(g=qr(g),typeof g!="string"))throw Qe("dirty is not a string, aborting");if(!e.isSupported)return g;if(ct||xt(a),e.removed=[],typeof g=="string"&&(ve=!1),ve){const ae=g.nodeName;if(typeof ae=="string"){const ne=P(ae);if(!$[ne]||Le[ne])throw Qe("root node is forbidden and cannot be sanitized in-place")}Ve(g)}else if(Xe(g))u=rn("<!---->"),h=u.ownerDocument.importNode(g,!0),h.nodeType===Re.element&&h.nodeName==="BODY"||h.nodeName==="HTML"?u=h:u.appendChild(h),Ve(h);else{if(!Te&&!ie&&!ue&&g.indexOf("<")===-1)return E&&qe?E.createHTML(g):g;if(u=rn(g),!u)return Te?null:qe?oe:""}u&&ut&&Z(u.firstChild);const L=sn(ve?g:u);for(;b=L.nextNode();)ln(b),un(b),b.content instanceof i&&Tt(b.content);if(ve)return ie&&an(g),g;if(Te){if(ie&&an(u),We)for(O=lt.call(u.ownerDocument);u.firstChild;)O.appendChild(u.firstChild);else O=u;return(F.shadowroot||F.shadowrootmode)&&(O=z.call(s,O,!0)),O}let W=ue?u.outerHTML:u.innerHTML;return ue&&$["!doctype"]&&u.ownerDocument&&u.ownerDocument.doctype&&u.ownerDocument.doctype.name&&B(rs,u.ownerDocument.doctype.name)&&(W="<!DOCTYPE "+u.ownerDocument.doctype.name+`>
3
3
  `+W),ie&&Se([be,Ue,He],ae=>{W=Ee(W,ae," ")}),E&&qe?E.createHTML(W):W},e.setConfig=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xt(g),ct=!0},e.clearConfig=function(){Ae=null,ct=!1},e.isValidAttribute=function(g,a,u){Ae||xt({});const h=P(g),b=P(a);return on(h,b,u)},e.addHook=function(g,a){typeof a=="function"&&_e(M[g],a)},e.removeHook=function(g,a){if(a!==void 0){const u=jr(M[g],a);return u===-1?void 0:Fr(M[g],u,1)[0]}return mn(M[g])},e.removeHooks=function(g){M[g]=[]},e.removeAllHooks=function(){M=_n()},e}var v=jn(),ls=v;v.sanitize.bind(v);v.isSupported;v.addHook.bind(v);v.removeHook.bind(v);v.removeHooks.bind(v);v.removeAllHooks.bind(v);v.setConfig.bind(v);v.clearConfig.bind(v);v.isValidAttribute.bind(v);v.version;v.removed;function Lt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var me=Lt();function Fn(t){me=t}var fe={exec:()=>null};function Ne(t){let e=[];return n=>{let s=Math.max(0,Math.min(3,n-1)),r=e[s];return r||(r=t(s),e[s]=r),r}}function w(t,e=""){let n=typeof t=="string"?t:t.source,s={replace:(r,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(U.caret,"$1"),n=n.replace(r,l),s},getRegex:()=>new RegExp(n,e)};return s}var os=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),U={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Ne(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Ne(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Ne(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Ne(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Ne(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Ne(t=>new RegExp(`^ {0,${t}}>`))},cs=/^(?:[ \t]*(?:\n|$))+/,us=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ps=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Fe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,hs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Dt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Bn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Un=w(Bn).replace(/bull/g,Dt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),fs=w(Bn).replace(/bull/g,Dt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),vt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ds=/^[^\n]+/,Mt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ms=w(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gs=w(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Dt).getRegex(),it="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Pt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ks=w("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Pt).replace("tag",it).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Hn=w(vt).replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex(),xs=w(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Hn).getRegex(),zt={blockquote:xs,code:us,def:ms,fences:ps,heading:hs,hr:Fe,html:ks,lheading:Un,list:gs,newline:cs,paragraph:Hn,table:fe,text:ds},En=w("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex(),bs={...zt,lheading:fs,table:En,paragraph:w(vt).replace("hr",Fe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",En).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",it).getRegex()},Ts={...zt,html:w(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Pt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:fe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:w(vt).replace("hr",Fe).replace("heading",` *#{1,6} *[^
4
4
  ]`).replace("lheading",Un).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ws=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ys=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gn=/^( {2,}|\\)\n(?!\s*$)/,As=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ie=/[\p{P}\p{S}]/u,at=/[\s\p{P}\p{S}]/u,$t=/[^\s\p{P}\p{S}]/u,Ss=w(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,at).getRegex(),Wn=/(?!~)[\p{P}\p{S}]/u,_s=/(?!~)[\s\p{P}\p{S}]/u,Es=/(?:[^\s\p{P}\p{S}]|~)/u,Rs=w(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",os?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),qn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ns=w(qn,"u").replace(/punct/g,Ie).getRegex(),Cs=w(qn,"u").replace(/punct/g,Wn).getRegex(),Yn="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Is=w(Yn,"gu").replace(/notPunctSpace/g,$t).replace(/punctSpace/g,at).replace(/punct/g,Ie).getRegex(),Os=w(Yn,"gu").replace(/notPunctSpace/g,Es).replace(/punctSpace/g,_s).replace(/punct/g,Wn).getRegex(),Ls=w("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,$t).replace(/punctSpace/g,at).replace(/punct/g,Ie).getRegex(),Ds=w(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ie).getRegex(),vs="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Ms=w(vs,"gu").replace(/notPunctSpace/g,$t).replace(/punctSpace/g,at).replace(/punct/g,Ie).getRegex(),Ps=w(/\\(punct)/,"gu").replace(/punct/g,Ie).getRegex(),zs=w(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),$s=w(Pt).replace("(?:-->|$)","-->").getRegex(),js=w("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",$s).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),tt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Fs=w(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",tt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Zn=w(/^!?\[(label)\]\[(ref)\]/).replace("label",tt).replace("ref",Mt).getRegex(),Xn=w(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mt).getRegex(),Bs=w("reflink|nolink(?!\\()","g").replace("reflink",Zn).replace("nolink",Xn).getRegex(),Rn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,jt={_backpedal:fe,anyPunctuation:Ps,autolink:zs,blockSkip:Rs,br:Gn,code:ys,del:fe,delLDelim:fe,delRDelim:fe,emStrongLDelim:Ns,emStrongRDelimAst:Is,emStrongRDelimUnd:Ls,escape:ws,link:Fs,nolink:Xn,punctuation:Ss,reflink:Zn,reflinkSearch:Bs,tag:js,text:As,url:fe},Us={...jt,link:w(/^!?\[(label)\]\((.*?)\)/).replace("label",tt).getRegex(),reflink:w(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tt).getRegex()},Ct={...jt,emStrongRDelimAst:Os,emStrongLDelim:Cs,delLDelim:Ds,delRDelim:Ms,url:w(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Rn).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:w(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Rn).getRegex()},Hs={...Ct,br:w(Gn).replace("{2,}","*").getRegex(),text:w(Ct.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Je={normal:zt,gfm:bs,pedantic:Ts},ze={normal:jt,gfm:Ct,breaks:Hs,pedantic:Us},Gs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Nn=t=>Gs[t];function J(t,e){if(e){if(U.escapeTest.test(t))return t.replace(U.escapeReplace,Nn)}else if(U.escapeTestNoEncode.test(t))return t.replace(U.escapeReplaceNoEncode,Nn);return t}function Cn(t){try{t=encodeURI(t).replace(U.percentDecode,"%")}catch{return null}return t}function In(t,e){let n=t.replace(U.findPipe,(i,l,o)=>{let p=!1,c=l;for(;--c>=0&&o[c]==="\\";)p=!p;return p?"|":" |"}),s=n.split(U.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(U.slashPipe,"|");return s}function le(t,e,n){let s=t.length;if(s===0)return"";let r=0;for(;r<s&&t.charAt(s-r-1)===e;)r++;return t.slice(0,s-r)}function On(t){let e=t.split(`
@@ -1 +1 @@
1
- import{u as x,j as e,a as d,P as m,O as p,C as h,S as j,b as v,D as f}from"./index-CAgGM6nb.js";const N=({open:n,entries:r,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:n,onOpenChange:c,children:e.jsxs(m,{children:[e.jsx(p,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(h,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"-mr-2 mt-4 flex flex-col gap-5 overflow-y-auto pr-2",children:r.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"mt-5 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{N as WhatsNewDialog};
1
+ import{u as x,j as e,a as d,P as m,O as p,C as h,S as j,b as v,D as f}from"./index-CxNL0O-C.js";const N=({open:n,entries:r,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:n,onOpenChange:c,children:e.jsxs(m,{children:[e.jsx(p,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(h,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"-mr-2 mt-4 flex flex-col gap-5 overflow-y-auto pr-2",children:r.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"mt-5 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{N as WhatsNewDialog};
@@ -1 +1 @@
1
- import{r as d,u as z,j as e,a as j,P as C,O as R,C as k,b as N,D as E,T as S,d as M,v as D,X as L,I as T,J as I,K as O}from"./index-CAgGM6nb.js";const A=t=>{switch(t){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(t)}}},w="hive.worker-modal.width",c=480,W=.5,x=t=>{const s=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(t,c),Math.max(c,s))},v=()=>typeof window>"u"?c:x(Math.round(window.innerWidth*W)),P=()=>{try{const t=localStorage.getItem(w);if(!t)return v();const s=Number.parseInt(t,10);return Number.isFinite(s)?x(s):v()}catch{return v()}},_=()=>{const[t,s]=d.useState(()=>P()),[u,i]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(w,String(Math.round(t)))}catch{}},[t]),d.useEffect(()=>{const a=()=>{s(r=>x(r))};return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const m=d.useCallback(a=>r=>{r.preventDefault();const h=r.clientX,l=t;i(!0);const b=document.body.style.cursor,n=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const p=f=>{const g=f.clientX-h,y=a==="left"?l-2*g:l+2*g;s(x(y))},o=()=>{i(!1),document.body.style.cursor=b,document.body.style.userSelect=n,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",o),document.removeEventListener("pointercancel",o)};document.addEventListener("pointermove",p),document.addEventListener("pointerup",o),document.addEventListener("pointercancel",o)},[t]);return{width:t,resizing:u,beginResize:m}},X=({onClose:t,onStart:s,runId:u,startError:i,starting:m,worker:a})=>{const{t:r}=z(),h=A(a.role),l=!!u,b=O(l),n=_(),p=o=>{o||t()};return e.jsx(j,{open:!0,onOpenChange:p,children:e.jsxs(C,{children:[e.jsx(R,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(k,{"data-testid":"worker-modal","aria-label":r("worker.detail",{name:a.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden",onEscapeKeyDown:o=>o.preventDefault(),style:{background:"var(--bg-1)",width:`${n.width}px`},children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":c,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":c,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("right")}),e.jsx(N,{className:"sr-only",children:a.name}),e.jsxs(E,{className:"sr-only",children:[h.label," agent — status ",b.label]}),i?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(S,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:i})]}):null,e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col p-3","data-testid":"worker-modal-terminal-slot",children:[e.jsx(M,{label:r("common.close"),children:e.jsx(D,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail",className:"float-action absolute top-4 right-4 z-10",children:e.jsx(L,{size:14,"aria-hidden":!0})})})}),e.jsx("div",{className:"flex min-h-0 flex-1 rounded-lg border",style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:l?e.jsx("div",{id:`worker-pty-${u}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(T,{commandPresetId:a.commandPresetId,workerRole:a.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:a.name}),e.jsxs("div",{className:"text-xs text-ter",children:[a.status==="stopped"?r("worker.terminalStopped"):r("worker.terminalNotStarted"),a.pendingTaskCount>0?r("worker.pendingResume",{count:a.pendingTaskCount}):r("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>s(a),disabled:m,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(I,{size:12,"aria-hidden":!0})," ",r(m?"common.starting":"common.start")]})]})})]})]})})]})})};export{X as WorkerModal};
1
+ import{r as d,u as z,j as e,a as j,P as C,O as R,C as k,b as N,D as E,T as S,d as M,v as D,X as L,I as T,J as I,K as O}from"./index-CxNL0O-C.js";const A=t=>{switch(t){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(t)}}},w="hive.worker-modal.width",c=480,W=.5,x=t=>{const s=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(t,c),Math.max(c,s))},v=()=>typeof window>"u"?c:x(Math.round(window.innerWidth*W)),P=()=>{try{const t=localStorage.getItem(w);if(!t)return v();const s=Number.parseInt(t,10);return Number.isFinite(s)?x(s):v()}catch{return v()}},_=()=>{const[t,s]=d.useState(()=>P()),[u,i]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(w,String(Math.round(t)))}catch{}},[t]),d.useEffect(()=>{const a=()=>{s(r=>x(r))};return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const m=d.useCallback(a=>r=>{r.preventDefault();const h=r.clientX,l=t;i(!0);const b=document.body.style.cursor,n=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const p=f=>{const g=f.clientX-h,y=a==="left"?l-2*g:l+2*g;s(x(y))},o=()=>{i(!1),document.body.style.cursor=b,document.body.style.userSelect=n,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",o),document.removeEventListener("pointercancel",o)};document.addEventListener("pointermove",p),document.addEventListener("pointerup",o),document.addEventListener("pointercancel",o)},[t]);return{width:t,resizing:u,beginResize:m}},X=({onClose:t,onStart:s,runId:u,startError:i,starting:m,worker:a})=>{const{t:r}=z(),h=A(a.role),l=!!u,b=O(l),n=_(),p=o=>{o||t()};return e.jsx(j,{open:!0,onOpenChange:p,children:e.jsxs(C,{children:[e.jsx(R,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(k,{"data-testid":"worker-modal","aria-label":r("worker.detail",{name:a.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden",onEscapeKeyDown:o=>o.preventDefault(),style:{background:"var(--bg-1)",width:`${n.width}px`},children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":c,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":c,"aria-valuenow":Math.round(n.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":n.resizing||void 0,onPointerDown:n.beginResize("right")}),e.jsx(N,{className:"sr-only",children:a.name}),e.jsxs(E,{className:"sr-only",children:[h.label," agent — status ",b.label]}),i?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(S,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:i})]}):null,e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col p-3","data-testid":"worker-modal-terminal-slot",children:[e.jsx(M,{label:r("common.close"),children:e.jsx(D,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail",className:"float-action absolute top-4 right-4 z-10",children:e.jsx(L,{size:14,"aria-hidden":!0})})})}),e.jsx("div",{className:"flex min-h-0 flex-1 rounded-lg border",style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:l?e.jsx("div",{id:`worker-pty-${u}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(T,{commandPresetId:a.commandPresetId,workerRole:a.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:a.name}),e.jsxs("div",{className:"text-xs text-ter",children:[a.status==="stopped"?r("worker.terminalStopped"):r("worker.terminalNotStarted"),a.pendingTaskCount>0?r("worker.pendingResume",{count:a.pendingTaskCount}):r("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>s(a),disabled:m,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(I,{size:12,"aria-hidden":!0})," ",r(m?"common.starting":"common.start")]})]})})]})]})})]})})};export{X as WorkerModal};
@@ -1 +1 @@
1
- import{c as z,j as e,u as O,T as oe,R as ie,r as k,p as re,a as ce,P as de,O as ue,C as pe,b as he,D as xe,d as S,X as ke,E as me,e as te,f as se,g as X,h as fe,i as ge,k as je,l as be,m as we,n as ye,o as D}from"./index-CAgGM6nb.js";import{j as ve}from"./path-join-7MR1s7b1.js";const Ne=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],K=z("at-sign",Ne);const Te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_e=z("circle",Te);const Ce=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],Y=z("corner-down-right",Ce);const $e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Se=z("file-code",$e);const ze=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ae=z("file-text",ze);const Ee=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],De=z("save",Ee),U=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let o=0;for(;o<t.length;){const i=t.slice(o),r=i.match(/^\*\*([^*]+?)\*\*/);if(r?.[1]){c(),n.push(e.jsx("strong",{children:U(r[1])},a++)),o+=r[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),o+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:U(u[1])},a++)),o+=u[0].length;continue}l+=t[o],o+=1}return c(),n},Ae=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:o})=>{const{t:i}=O(),r=s=>{s.preventDefault(),o()};return e.jsxs("form",{onSubmit:r,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(oe,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(ie,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx(De,{size:14}),i("tasks.raw.save")]})})]})},B=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],ne=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return B[n%B.length]??B[0]},Me=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],Z=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),J=new Set(["报告","report","文件","file","path","日志","log","产物"]),Re=/^(.*?)\s*\(([^()]+)\)\s*$/,Le=/\s*[·,,;;]\s*/,Pe=/^([^::]+)[::]\s*(.+)$/,Ke=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Oe=t=>t.includes("/")||/^[A-Za-z]:\\/.test(t)||(t.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Ie=t=>{const n=t.match(Re);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Le).filter(Boolean),o=[];for(const i of c){const r=i.match(Pe);if(!r){o.push({kind:"note",value:i.trim()});continue}const s=(r[1]??"").trim(),u=(r[2]??"").trim(),h=s.toLowerCase();Z.has(h)||Z.has(s)?o.push({kind:"owner",value:u}):G.has(h)||G.has(s)?o.push({kind:"status",value:u,tone:Ke(u)}):J.has(h)||J.has(s)||Oe(u)?o.push({kind:"path",label:s,value:u}):o.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:o}},Q=3,He=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":ne(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ae,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},F=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,o]=k.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},r=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>o(s.target.value),onKeyDown:r,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},q=({task:t,handlers:n,depth:l})=>{const{t:a}=O(),c=t.checked?fe:_e,{title:o,meta:i}=Ie(t.text),[r,s]=k.useState(!1),[u,h]=k.useState(!1),[b,A]=k.useState(!1),[_,C]=k.useState(!1),g=k.useRef(null);k.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const{onToggle:f,onUpdateText:x,onDelete:y,onAppendSubtask:M,onCopyLine:I,onSelectOwner:v,writeDisabled:j=!1}=n,R=!!x&&!j,$=!!y&&!j,N=!!M&&!j,L=!!I,E=!r&&!u&&(R||$||N||L),w=t.children.length,T=ge(t),P=l+1>=Q,H=w>0,V=b?a("tasks.aria.expandSubtasks",{count:w}):a("tasks.aria.collapseSubtasks",{count:w}),p=v?{onSelectOwner:v}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Q?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:t.checked,disabled:j,onChange:()=>{j||f(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:r?e.jsx(F,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:d=>{s(!1),x?.(t.line,d)},onCancel:()=>s(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${t.checked?"text-ter line-through":"text-pri"}`,children:U(o)}),H?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:d=>{d.stopPropagation(),A(m=>!m)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!b,"aria-label":V,children:b?e.jsx(se,{size:12,"aria-hidden":!0}):e.jsx(te,{size:12,"aria-hidden":!0})}):null,T?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:T.done,total:T.total}),children:[T.done,"/",T.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(d=>e.jsx(He,{item:d,handlers:p},`${t.line}-meta-${d.kind}-${"label"in d?d.label:""}-${d.value}`)),t.mentions.map(d=>{const m=d.replace(/^@/,""),W={"--owner-tone":ne(m)};return v?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${m}`,"data-owner":m,onClick:le=>{le.stopPropagation(),v(m)},style:W,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${m}`,"data-owner":m,style:W,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`)})]}):null]})}),E?e.jsxs("div",{className:"task-row__actions",children:[L?e.jsx(S,{label:a(_?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{I?.(t.line),C(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1),g.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(_?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:_?e.jsx(je,{size:12}):e.jsx(be,{size:12})})}):null,R?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{A(!1),h(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(Y,{size:12})})}):null,$?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger",onClick:()=>y?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),w>0&&!b||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[b?null:t.children.map(d=>e.jsx(q,{depth:l+1,handlers:n,task:d},d.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(Y,{size:12})}),e.jsx(F,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:d=>{h(!1),M?.(t.line,d)},onCancel:()=>h(!1)})]})}):null]}):null]})},ee=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=O(),[c,o]=k.useState(!1),[i,r]=k.useState(""),s=()=>{const h=i.trim();if(!h){o(!1);return}t(h),r("")},u=h=>{h.key==="Enter"?(h.preventDefault(),s()):h.key==="Escape"&&(h.preventDefault(),r(""),o(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(X,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:h=>r(h.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>o(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(X,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ve=t=>{let n=0,l=0;const a=[],c=[],o=r=>{n+=1,r.checked&&(l+=1);for(const s of r.children)o(s)};for(const r of t)r.checked?c.push(r):a.push(r),o(r);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Be=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i,onToggleTaskLine:r,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:h,onDeleteTask:b,open:A,workspacePath:_,knownWorkerNames:C,onSelectOwner:g,connectionStale:f=!1})=>{const{t:x}=O(),[y,M]=k.useState(!1),v={onToggle:r,onCopyLine:p=>{const d=t.split(/\r?\n/)[p];typeof d=="string"&&navigator.clipboard?.writeText(d).catch(m=>{console.error("[hive] swallowed:tasks.copyLine",m)})},...h&&!f?{onUpdateText:h}:{},...b&&!f?{onDelete:b}:{},...u&&!f?{onAppendSubtask:u}:{},...g?{onSelectOwner:g}:{},...f?{writeDisabled:!0}:{}},j=k.useMemo(()=>re(t,C?{knownWorkerNames:C}:{}),[t,C]),{completedTasks:R,completionPercent:$,doneRoots:N,openRoots:L,totalTasks:E}=k.useMemo(()=>Ve(j),[j]),[w,T]=k.useState(N.length<=3),P=_?ve(_,".hive","tasks.md"):".hive/tasks.md",H=p=>{if(p.key!=="Escape")return;const d=p.target?.tagName;d==="INPUT"||d==="TEXTAREA"||(p.preventDefault(),l())},V=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${f?" task-dialog--stale":""}`;return e.jsx(ce,{open:A,onOpenChange:p=>!p&&l(),children:e.jsxs(de,{children:[e.jsx(ue,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(pe,{"aria-label":x("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":f||void 0,onEscapeKeyDown:p=>p.preventDefault(),onKeyDown:H,className:V,style:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(780px, calc(100vh - 48px))",width:"min(1040px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx(he,{className:"font-semibold text-pri leading-tight",children:x("tasks.title.todo")}),e.jsx(xe,{className:"mono truncate text-xs text-ter",title:P,children:P})]}),E>0?e.jsxs("span",{className:"text-xs text-ter tabular-nums","data-testid":"task-graph-summary",children:[e.jsxs("span",{"data-testid":"task-progress-text",children:[R," / ",E]})," ","· ",$,"%"]}):null,e.jsx(S,{label:x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>M(p=>!p),"data-testid":"task-raw-toggle",className:"icon-btn","aria-label":x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Se,{size:14})})}),e.jsx(S,{label:x("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":x("tasks.action.closeTodo"),className:"icon-btn",children:e.jsx(ke,{size:14})})})]}),!y&&E>0?e.jsx("div",{"aria-label":x("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":$,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${$}%`}})}):null,e.jsx("div",{className:"flex-1 scroll-y px-3 py-3 text-sm",children:y?e.jsx(Ae,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i}):j.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ae,{size:20}),title:x("tasks.empty.title"),description:x("tasks.empty.description"),...s?{action:e.jsx(ee,{variant:"primary",disabled:f,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line)),s?e.jsx("li",{children:e.jsx(ee,{disabled:f,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>T(p=>!p),"aria-expanded":w,"data-testid":"task-completed-toggle",className:"task-completed-toggle",children:[w?e.jsx(te,{size:12,"aria-hidden":!0}):e.jsx(se,{size:12,"aria-hidden":!0}),e.jsx("span",{children:x("tasks.completed.toggle",{count:N.length})})]}),w?e.jsx("ul",{className:"task-list","data-testid":"task-completed-list",children:N.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line))}):null]}):null]})})]})})]})})},We=({tasksFile:t,workspacePath:n,open:l,onClose:a,workers:c,onSelectOwner:o,connectionStale:i})=>{const r=k.useMemo(()=>c?.length?c.map(s=>s.name):void 0,[c]);return e.jsx(Be,{content:t.content,hasConflict:t.hasConflict,onClose:a,onContentChange:t.onChange,onKeepLocal:t.onKeepLocal,onReload:t.onReload,onSave:t.onSave,onToggleTaskLine:s=>{t.toggleTaskAtLine(s).catch(D("tasks.toggleTaskAtLine"))},onAppendTask:s=>{t.appendTask(s).catch(D("tasks.appendTask"))},onAppendSubtask:(s,u)=>{t.appendSubtask(s,u).catch(D("tasks.appendSubtask"))},onUpdateTaskText:(s,u)=>{t.updateTaskText(s,u).catch(D("tasks.updateTaskText"))},onDeleteTask:s=>{t.deleteTask(s).catch(D("tasks.deleteTask"))},open:l,workspacePath:n,...r?{knownWorkerNames:r}:{},...o?{onSelectOwner:o}:{},...i!==void 0?{connectionStale:i}:{}})};export{We as WorkspaceTaskDrawer};
1
+ import{c as z,j as e,u as O,T as oe,R as ie,r as k,p as re,a as ce,P as de,O as ue,C as pe,b as he,D as xe,d as S,X as ke,E as me,e as te,f as se,g as X,h as fe,i as ge,k as je,l as be,m as we,n as ye,o as D}from"./index-CxNL0O-C.js";import{j as ve}from"./path-join-7MR1s7b1.js";const Ne=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],K=z("at-sign",Ne);const Te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_e=z("circle",Te);const Ce=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],Y=z("corner-down-right",Ce);const $e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Se=z("file-code",$e);const ze=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ae=z("file-text",ze);const Ee=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],De=z("save",Ee),U=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let o=0;for(;o<t.length;){const i=t.slice(o),r=i.match(/^\*\*([^*]+?)\*\*/);if(r?.[1]){c(),n.push(e.jsx("strong",{children:U(r[1])},a++)),o+=r[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),o+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:U(u[1])},a++)),o+=u[0].length;continue}l+=t[o],o+=1}return c(),n},Ae=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:o})=>{const{t:i}=O(),r=s=>{s.preventDefault(),o()};return e.jsxs("form",{onSubmit:r,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(oe,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(ie,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx(De,{size:14}),i("tasks.raw.save")]})})]})},B=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],ne=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return B[n%B.length]??B[0]},Me=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],Z=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),J=new Set(["报告","report","文件","file","path","日志","log","产物"]),Re=/^(.*?)\s*\(([^()]+)\)\s*$/,Le=/\s*[·,,;;]\s*/,Pe=/^([^::]+)[::]\s*(.+)$/,Ke=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Oe=t=>t.includes("/")||/^[A-Za-z]:\\/.test(t)||(t.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Ie=t=>{const n=t.match(Re);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Le).filter(Boolean),o=[];for(const i of c){const r=i.match(Pe);if(!r){o.push({kind:"note",value:i.trim()});continue}const s=(r[1]??"").trim(),u=(r[2]??"").trim(),h=s.toLowerCase();Z.has(h)||Z.has(s)?o.push({kind:"owner",value:u}):G.has(h)||G.has(s)?o.push({kind:"status",value:u,tone:Ke(u)}):J.has(h)||J.has(s)||Oe(u)?o.push({kind:"path",label:s,value:u}):o.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:o}},Q=3,He=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":ne(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(K,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ae,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},F=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,o]=k.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},r=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>o(s.target.value),onKeyDown:r,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},q=({task:t,handlers:n,depth:l})=>{const{t:a}=O(),c=t.checked?fe:_e,{title:o,meta:i}=Ie(t.text),[r,s]=k.useState(!1),[u,h]=k.useState(!1),[b,A]=k.useState(!1),[_,C]=k.useState(!1),g=k.useRef(null);k.useEffect(()=>()=>{g.current&&clearTimeout(g.current)},[]);const{onToggle:f,onUpdateText:x,onDelete:y,onAppendSubtask:M,onCopyLine:I,onSelectOwner:v,writeDisabled:j=!1}=n,R=!!x&&!j,$=!!y&&!j,N=!!M&&!j,L=!!I,E=!r&&!u&&(R||$||N||L),w=t.children.length,T=ge(t),P=l+1>=Q,H=w>0,V=b?a("tasks.aria.expandSubtasks",{count:w}):a("tasks.aria.collapseSubtasks",{count:w}),p=v?{onSelectOwner:v}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Q?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:t.checked,disabled:j,onChange:()=>{j||f(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:r?e.jsx(F,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:d=>{s(!1),x?.(t.line,d)},onCancel:()=>s(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${t.checked?"text-ter line-through":"text-pri"}`,children:U(o)}),H?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:d=>{d.stopPropagation(),A(m=>!m)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!b,"aria-label":V,children:b?e.jsx(se,{size:12,"aria-hidden":!0}):e.jsx(te,{size:12,"aria-hidden":!0})}):null,T?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:T.done,total:T.total}),children:[T.done,"/",T.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(d=>e.jsx(He,{item:d,handlers:p},`${t.line}-meta-${d.kind}-${"label"in d?d.label:""}-${d.value}`)),t.mentions.map(d=>{const m=d.replace(/^@/,""),W={"--owner-tone":ne(m)};return v?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${m}`,"data-owner":m,onClick:le=>{le.stopPropagation(),v(m)},style:W,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${m}`,"data-owner":m,style:W,children:[e.jsx(K,{size:10,"aria-hidden":!0}),m]},`${t.line}-mention-${d}`)})]}):null]})}),E?e.jsxs("div",{className:"task-row__actions",children:[L?e.jsx(S,{label:a(_?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{I?.(t.line),C(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1),g.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(_?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:_?e.jsx(je,{size:12}):e.jsx(be,{size:12})})}):null,R?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(we,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action",onClick:()=>{A(!1),h(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(Y,{size:12})})}):null,$?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger",onClick:()=>y?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),w>0&&!b||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[b?null:t.children.map(d=>e.jsx(q,{depth:l+1,handlers:n,task:d},d.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(Y,{size:12})}),e.jsx(F,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:d=>{h(!1),M?.(t.line,d)},onCancel:()=>h(!1)})]})}):null]}):null]})},ee=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=O(),[c,o]=k.useState(!1),[i,r]=k.useState(""),s=()=>{const h=i.trim();if(!h){o(!1);return}t(h),r("")},u=h=>{h.key==="Enter"?(h.preventDefault(),s()):h.key==="Escape"&&(h.preventDefault(),r(""),o(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(X,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:h=>r(h.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>o(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(X,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Ve=t=>{let n=0,l=0;const a=[],c=[],o=r=>{n+=1,r.checked&&(l+=1);for(const s of r.children)o(s)};for(const r of t)r.checked?c.push(r):a.push(r),o(r);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},Be=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i,onToggleTaskLine:r,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:h,onDeleteTask:b,open:A,workspacePath:_,knownWorkerNames:C,onSelectOwner:g,connectionStale:f=!1})=>{const{t:x}=O(),[y,M]=k.useState(!1),v={onToggle:r,onCopyLine:p=>{const d=t.split(/\r?\n/)[p];typeof d=="string"&&navigator.clipboard?.writeText(d).catch(m=>{console.error("[hive] swallowed:tasks.copyLine",m)})},...h&&!f?{onUpdateText:h}:{},...b&&!f?{onDelete:b}:{},...u&&!f?{onAppendSubtask:u}:{},...g?{onSelectOwner:g}:{},...f?{writeDisabled:!0}:{}},j=k.useMemo(()=>re(t,C?{knownWorkerNames:C}:{}),[t,C]),{completedTasks:R,completionPercent:$,doneRoots:N,openRoots:L,totalTasks:E}=k.useMemo(()=>Ve(j),[j]),[w,T]=k.useState(N.length<=3),P=_?ve(_,".hive","tasks.md"):".hive/tasks.md",H=p=>{if(p.key!=="Escape")return;const d=p.target?.tagName;d==="INPUT"||d==="TEXTAREA"||(p.preventDefault(),l())},V=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${f?" task-dialog--stale":""}`;return e.jsx(ce,{open:A,onOpenChange:p=>!p&&l(),children:e.jsxs(de,{children:[e.jsx(ue,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(pe,{"aria-label":x("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":f||void 0,onEscapeKeyDown:p=>p.preventDefault(),onKeyDown:H,className:V,style:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(780px, calc(100vh - 48px))",width:"min(1040px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[e.jsx(he,{className:"font-semibold text-pri leading-tight",children:x("tasks.title.todo")}),e.jsx(xe,{className:"mono truncate text-xs text-ter",title:P,children:P})]}),E>0?e.jsxs("span",{className:"text-xs text-ter tabular-nums","data-testid":"task-graph-summary",children:[e.jsxs("span",{"data-testid":"task-progress-text",children:[R," / ",E]})," ","· ",$,"%"]}):null,e.jsx(S,{label:x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>M(p=>!p),"data-testid":"task-raw-toggle",className:"icon-btn","aria-label":x(y?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Se,{size:14})})}),e.jsx(S,{label:x("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":x("tasks.action.closeTodo"),className:"icon-btn",children:e.jsx(ke,{size:14})})})]}),!y&&E>0?e.jsx("div",{"aria-label":x("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":$,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${$}%`}})}):null,e.jsx("div",{className:"flex-1 scroll-y px-3 py-3 text-sm",children:y?e.jsx(Ae,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:o,onSave:i}):j.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ae,{size:20}),title:x("tasks.empty.title"),description:x("tasks.empty.description"),...s?{action:e.jsx(ee,{variant:"primary",disabled:f,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[L.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line)),s?e.jsx("li",{children:e.jsx(ee,{disabled:f,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{type:"button",onClick:()=>T(p=>!p),"aria-expanded":w,"data-testid":"task-completed-toggle",className:"task-completed-toggle",children:[w?e.jsx(te,{size:12,"aria-hidden":!0}):e.jsx(se,{size:12,"aria-hidden":!0}),e.jsx("span",{children:x("tasks.completed.toggle",{count:N.length})})]}),w?e.jsx("ul",{className:"task-list","data-testid":"task-completed-list",children:N.map(p=>e.jsx(q,{depth:0,handlers:v,task:p},p.line))}):null]}):null]})})]})})]})})},We=({tasksFile:t,workspacePath:n,open:l,onClose:a,workers:c,onSelectOwner:o,connectionStale:i})=>{const r=k.useMemo(()=>c?.length?c.map(s=>s.name):void 0,[c]);return e.jsx(Be,{content:t.content,hasConflict:t.hasConflict,onClose:a,onContentChange:t.onChange,onKeepLocal:t.onKeepLocal,onReload:t.onReload,onSave:t.onSave,onToggleTaskLine:s=>{t.toggleTaskAtLine(s).catch(D("tasks.toggleTaskAtLine"))},onAppendTask:s=>{t.appendTask(s).catch(D("tasks.appendTask"))},onAppendSubtask:(s,u)=>{t.appendSubtask(s,u).catch(D("tasks.appendSubtask"))},onUpdateTaskText:(s,u)=>{t.updateTaskText(s,u).catch(D("tasks.updateTaskText"))},onDeleteTask:s=>{t.deleteTask(s).catch(D("tasks.deleteTask"))},open:l,workspacePath:n,...r?{knownWorkerNames:r}:{},...o?{onSelectOwner:o}:{},...i!==void 0?{connectionStale:i}:{}})};export{We as WorkspaceTaskDrawer};
@@ -1 +1 @@
1
- import{r as E,_ as R,y as X,j as k,u as F,z as Z}from"./index-CAgGM6nb.js";const z="hive:terminal-visible-resize",Q=e=>new CustomEvent(z,{detail:{runId:e}}),ee=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),_={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},te=(e,n={})=>{const t=n.isMac??ee();if(e.key==="Enter"&&e.shiftKey)return e.type==="keypress"?{kind:"send",bytes:_.shiftEnter}:{kind:"block"};if(!t&&e.type==="keydown"&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&(e.key==="c"||e.key==="C")&&n.hasSelection)return{kind:"copy"};if(!t||e.type!=="keydown")return{kind:"passthrough"};const o=e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey,r=e.altKey&&!e.metaKey&&!e.ctrlKey;if(o)switch(e.key){case"Backspace":return{kind:"send",bytes:_.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:_.lineStart};case"ArrowRight":return{kind:"send",bytes:_.lineEnd};case"k":case"K":return{kind:"clear"}}if(r)switch(e.key){case"Backspace":return{kind:"send",bytes:_.killWordBack};case"ArrowLeft":return{kind:"send",bytes:_.wordBack};case"ArrowRight":return{kind:"send",bytes:_.wordForward}}return{kind:"passthrough"}},H=(e,n={})=>{const t=new URL(e,window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:";for(const[o,r]of Object.entries(n))r!==void 0&&t.searchParams.set(o,String(r));return t.toString()},ne=({initialSize:e,onError:n,onExit:t,onOutput:o,onRestore:r,runId:c})=>{const s=crypto.randomUUID(),a={...e,clientId:s},d=new WebSocket(H(`/ws/terminal/${c}/io`,a)),l=new WebSocket(H(`/ws/terminal/${c}/control`,a));let g=!1;const f=[];let h=null;const b=()=>{!h||l.readyState!==l.OPEN||(l.send(JSON.stringify({type:"resize",...h})),h=null)};return d.onmessage=p=>{const w=typeof p.data=="string"?p.data:"",m=v=>{l.readyState===l.OPEN&&l.send(JSON.stringify({type:"output_ack",bytes:v}))};if(!g){f.push({chunk:w,acknowledge:m});return}o(w,m)},l.onopen=()=>{b()},l.onmessage=p=>{const w=JSON.parse(String(p.data));if(w.type==="exit"&&t(w.code),w.type==="error"&&n(w.message),w.type==="restore"){r(w.snapshot),g=!0,l.readyState===l.OPEN&&l.send(JSON.stringify({type:"restore_complete"}));for(const m of f.splice(0))o(m.chunk,m.acknowledge)}},{dispose(){d.close(),l.close()},resize(p,w,m,v){h={cols:p,rows:w},m!==void 0&&(h.pixelWidth=m),v!==void 0&&(h.pixelHeight=v),b()},sendBinaryInput(p){if(d.readyState!==d.OPEN)return;const w=new Uint8Array(p.length);for(let m=0;m<p.length;m++)w[m]=p.charCodeAt(m)&255;d.send(w)},sendInput(p){d.readyState===d.OPEN&&d.send(p)}}},re=16,oe=.3,se=(e,n)=>{const t=n==="up"?"A":"B";return e?`\x1BO${t}`:`\x1B[${t}`},ie=(e,n,t)=>n==="opencode"?t==="up"?"\x1B[5~":"\x1B[6~":se(e.modes?.applicationCursorKeysMode,t),ae=(e,n="default")=>{let t=0;return o=>{if(e.buffer?.active?.type!=="alternate")return t=0,{handled:!1,input:null};if(n!=="opencode"&&e.modes?.mouseTrackingMode&&e.modes.mouseTrackingMode!=="none")return t=0,{handled:!1,input:null};if(o.deltaY===0||o.shiftKey)return{handled:!1,input:null};let r=o.deltaY;return o.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=re,Math.abs(o.deltaY)<50&&(r*=oe),t+=r,r=Math.trunc(t),t%=1):t=0,r===0?{handled:!0,input:null}:{handled:!0,input:ie(e,n,r<0?"up":"down")}}},ce=({element:e,profile:n="default",sendInput:t,terminal:o})=>{const r=ae(o,n),c=a=>{const{handled:d,input:l}=r(a);return d?(a.preventDefault(),a.stopPropagation(),l&&t(l),!1):!0};if(typeof o.attachCustomWheelEventHandler=="function")return o.attachCustomWheelEventHandler(c),()=>{};const s=a=>{c(a)||a.stopImmediatePropagation()};return e.addEventListener("wheel",s,{capture:!0,passive:!1}),()=>e.removeEventListener("wheel",s,{capture:!0})},le=new RegExp("\x1B\\[M([\\s\\S])([\\s\\S])([\\s\\S])","g"),de=(e,n,t,o)=>{const r=n.charCodeAt(0)-32,c=t.charCodeAt(0)-32,s=o.charCodeAt(0)-32;if(r<0||c<1||s<1)return e;const d=(r&3)===3&&(r&32)===0&&(r&64)===0?"m":"M";return`\x1B[<${r};${c};${s}${d}`},ue=(e,n)=>{if(n!=="opencode")return{binary:!0,chunk:e};const t=e.replace(le,de);return{binary:t===e,chunk:t}},fe=(e,n="default")=>{const t=E.useRef(null),[o,r]=E.useState(null),[c,s]=E.useState("connecting");return E.useEffect(()=>{if(!t.current)return;let a=!1,d,l,g,f,h,b,p,w,m,v,S=null,P,L;const O={current:!1};return Promise.all([R(()=>import("./xterm-B-qIQCd3.js"),[]),R(()=>import("./addon-fit-DX4qG4td.js"),[]),R(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),R(()=>import("./addon-clipboard-wHJhZAA4.js"),[])]).then(([$,j,U,Y])=>{if(a||!t.current)return;const W=typeof window<"u"?getComputedStyle(document.documentElement):null,q=W?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",J=W?.getPropertyValue("--text-primary").trim()||"#ebebeb",u=new $.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:q,foreground:J}}),M=new j.FitAddon;if(u.loadAddon(M),u.loadAddon(new U.Unicode11Addon),u.unicode.activeVersion="11",u.loadAddon(new Y.ClipboardAddon),u.open(t.current),M.fit(),b=u,p=M,v=ce({element:t.current,profile:n,sendInput:i=>h?.sendInput(i),terminal:u}),S=t.current.querySelector(".xterm-helper-textarea"),S){const i=S;P=()=>{O.current=!0},L=y=>{const T=y.data;T&&h?.sendInput(T),i.value="",setTimeout(()=>{O.current=!1},0)},S.addEventListener("compositionstart",P,{capture:!0}),S.addEventListener("compositionend",L,{capture:!0})}typeof u.attachCustomKeyEventHandler=="function"&&u.attachCustomKeyEventHandler(i=>{const y=te(i,{hasSelection:u.hasSelection()});switch(y.kind){case"send":return i.preventDefault(),h?.sendInput(y.bytes),!1;case"clear":return i.preventDefault(),u.clear(),!1;case"copy":{i.preventDefault();const T=u.getSelection();return T&&navigator.clipboard?.writeText(T).catch(()=>{}),u.clearSelection(),!1}case"block":return!1;case"passthrough":return!0}});const G=()=>{const i=t.current;return i?.isConnected?!i.closest('[data-terminal-host-parked="true"]'):!1},N=()=>{if(!t.current)return{};const i=t.current.clientWidth,y=t.current.clientHeight,T={};return y>0&&(T.pixelHeight=y),i>0&&(T.pixelWidth=i),T},I=()=>{if(!t.current||!G())return;p?.fit();const{pixelHeight:i,pixelWidth:y}=N();h?.resize(b?.cols??80,b?.rows??24,y,i)},K=()=>{m&&window.clearTimeout(m),m=window.setTimeout(()=>{m=void 0,I()},50)};R(()=>import("./addon-web-links-DIbG5aQx.js"),[]).then(i=>{a||b!==u||u.loadAddon(new i.WebLinksAddon)}).catch(()=>{}),R(()=>import("./addon-webgl-DCtw1yLn.js"),[]).then(i=>{if(!(a||b!==u))try{const y=new i.WebglAddon;y.onContextLoss(()=>y.dispose()),u.loadAddon(y),K()}catch{}}).catch(()=>{}),h=ne({initialSize:{cols:u.cols,rows:u.rows,...N()},onError(i){r(i)},onExit(){s("stopped")},onOutput(i,y){u.write(i,()=>y(new TextEncoder().encode(i).byteLength))},onRestore(i){u.write(i)},runId:e}),f=u.onData(i=>{O.current||h?.sendInput(i)}),typeof u.onBinary=="function"&&(g=u.onBinary(i=>{const y=ue(i,n);y.binary?h?.sendBinaryInput(y.chunk):h?.sendInput(y.chunk)})),s("running"),I(),typeof ResizeObserver<"u"&&t.current&&(w=new ResizeObserver(K),w.observe(t.current)),d=i=>{i.detail?.runId===e&&I()},l=()=>I(),window.addEventListener(z,d),window.addEventListener("resize",l)}),()=>{a=!0,d&&window.removeEventListener(z,d),l&&window.removeEventListener("resize",l),w?.disconnect(),m&&window.clearTimeout(m),v?.(),S&&P&&S.removeEventListener("compositionstart",P,{capture:!0}),S&&L&&S.removeEventListener("compositionend",L,{capture:!0}),g?.dispose(),f?.dispose(),h?.dispose(),b?.dispose(),p?.dispose()}},[e,n]),{containerRef:t,error:o,status:c}},pe={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},D="hive-terminal-parking-lot",me=500,he=e=>[`worker-pty-${e}`,`orch-pty-${e}`,`shell-pty-${e}`],ye=e=>{const n=Array.from(document.querySelectorAll("[data-pty-slot]")).filter(t=>t.id===e);return n[n.length-1]??null},we=()=>{let e=document.getElementById(D);return e||(e=document.createElement("div"),e.id=D,e.hidden=!0,e.style.display="none",(document.body??document.documentElement).appendChild(e)),e},B=()=>{const e=document.getElementById(D);e&&e.childElementCount===0&&e.remove()},C=new Set;let x,A;const V=()=>{for(const e of C)e()},Ee=()=>{x?.disconnect(),x=void 0,A!==void 0&&(window.clearInterval(A),A=void 0)},ge=()=>{if(x||A!==void 0)return;const e=document.body??document.documentElement;if(typeof MutationObserver<"u"&&e){x=new MutationObserver(V),x.observe(e,{attributeFilter:["data-pty-slot","id"],attributes:!0,childList:!0,subtree:!0});return}A=window.setInterval(V,100)},be=e=>(C.add(e),ge(),()=>{C.delete(e),C.size===0&&Ee()}),Se=[50,150,300],Te=e=>{const n=[],t=[],o=()=>window.dispatchEvent(Q(e)),r=(c,s)=>{const a=window.setTimeout(()=>{const d=t.indexOf(a);d>=0&&t.splice(d,1),s()},c);t.push(a)};if(typeof window.requestAnimationFrame=="function"){const c=window.requestAnimationFrame(()=>{o();const s=window.requestAnimationFrame(o);n.push(s)});n.push(c)}else r(0,o);for(const c of Se)r(c,o);return()=>{for(const c of n)window.cancelAnimationFrame?.(c);for(const c of t)window.clearTimeout(c);n.length=0,t.length=0}},ve=e=>{const[n,t]=E.useState(null);return E.useEffect(()=>{const o=he(e),r=()=>{for(const s of o){const a=ye(s);if(a)return a}return null},c=()=>{const s=r();t(a=>a===s?a:s)};return c(),be(c)},[e]),n},_e=(e,n)=>{const[t,o]=E.useState(!1),[r,c]=E.useState(null),s=E.useRef(void 0),a=E.useRef(null),d=E.useRef(void 0),l=E.useCallback(()=>{s.current!==void 0&&(window.clearTimeout(s.current),s.current=void 0)},[]),g=E.useCallback(()=>{d.current?.(),d.current=void 0},[]);return E.useLayoutEffect(()=>{const f=document.createElement("div");return f.dataset.terminalHostRunId=e,f.dataset.terminalHostParked="false",f.className="h-full min-h-0 w-full min-w-0",a.current=f,c(f),()=>{l(),g(),f.remove(),a.current=null,B()}},[l,g,e]),E.useLayoutEffect(()=>{if(n){l(),o(!0);return}if(!(!t||s.current!==void 0))return s.current=window.setTimeout(()=>{s.current=void 0,o(!1)},me),l},[t,l,n]),E.useLayoutEffect(()=>{const f=a.current;if(!f)return;if(!t){g(),f.remove(),f.dataset.terminalHostParked="false",B();return}const h=n??we();if(f.parentElement===h)return;const b=f.parentElement!==null,p=document.activeElement;n||g(),!n&&p instanceof HTMLElement&&f.contains(p)&&p.blur(),f.dataset.terminalHostParked=n?"false":"true",h.appendChild(f),B(),n&&b&&(g(),d.current=Te(e))},[t,g,e,n]),t?r:null},ke=({inputProfile:e="default",runId:n,title:t})=>{const o=ve(n),r=_e(n,o);return r?X.createPortal(k.jsx(Re,{inputProfile:e,runId:n,title:t}),r):null},Re=({inputProfile:e,runId:n,title:t})=>{const{t:o}=F(),{containerRef:r,error:c,status:s}=fe(n,e),a=pe[s];return k.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[k.jsx("p",{className:"sr-only",children:a?o(a):s}),c?k.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:c}):null,k.jsx("div",{"data-testid":`terminal-${n}`,ref:r,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},Ae=({hidden:e=!1,optimisticRuns:n=[],terminalRuns:t,workspaceId:o})=>{const{t:r}=F(),c=Z(t,n,o);return k.jsx("section",{hidden:e,"aria-hidden":e||void 0,"aria-label":r("terminalPanels.aria"),children:c.map(s=>k.jsx(ke,{inputProfile:s.terminal_input_profile??"default",runId:s.run_id,title:`${s.agent_name} (${s.status})`},s.run_id))})};export{Ae as WorkspaceTerminalPanels};
1
+ import{r as E,_ as R,y as X,j as k,u as F,z as Z}from"./index-CxNL0O-C.js";const z="hive:terminal-visible-resize",Q=e=>new CustomEvent(z,{detail:{runId:e}}),ee=()=>typeof navigator>"u"?!1:/Mac|iPhone|iPad/.test(navigator.platform),_={killToLineStart:"",lineStart:"",lineEnd:"",killWordBack:"\x1B",wordBack:"\x1Bb",wordForward:"\x1Bf",shiftEnter:"\x1B[13;2u"},te=(e,n={})=>{const t=n.isMac??ee();if(e.key==="Enter"&&e.shiftKey)return e.type==="keypress"?{kind:"send",bytes:_.shiftEnter}:{kind:"block"};if(!t&&e.type==="keydown"&&e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&(e.key==="c"||e.key==="C")&&n.hasSelection)return{kind:"copy"};if(!t||e.type!=="keydown")return{kind:"passthrough"};const o=e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey,r=e.altKey&&!e.metaKey&&!e.ctrlKey;if(o)switch(e.key){case"Backspace":return{kind:"send",bytes:_.killToLineStart};case"ArrowLeft":return{kind:"send",bytes:_.lineStart};case"ArrowRight":return{kind:"send",bytes:_.lineEnd};case"k":case"K":return{kind:"clear"}}if(r)switch(e.key){case"Backspace":return{kind:"send",bytes:_.killWordBack};case"ArrowLeft":return{kind:"send",bytes:_.wordBack};case"ArrowRight":return{kind:"send",bytes:_.wordForward}}return{kind:"passthrough"}},H=(e,n={})=>{const t=new URL(e,window.location.href);t.protocol=t.protocol==="https:"?"wss:":"ws:";for(const[o,r]of Object.entries(n))r!==void 0&&t.searchParams.set(o,String(r));return t.toString()},ne=({initialSize:e,onError:n,onExit:t,onOutput:o,onRestore:r,runId:c})=>{const s=crypto.randomUUID(),a={...e,clientId:s},d=new WebSocket(H(`/ws/terminal/${c}/io`,a)),l=new WebSocket(H(`/ws/terminal/${c}/control`,a));let g=!1;const f=[];let h=null;const b=()=>{!h||l.readyState!==l.OPEN||(l.send(JSON.stringify({type:"resize",...h})),h=null)};return d.onmessage=p=>{const w=typeof p.data=="string"?p.data:"",m=v=>{l.readyState===l.OPEN&&l.send(JSON.stringify({type:"output_ack",bytes:v}))};if(!g){f.push({chunk:w,acknowledge:m});return}o(w,m)},l.onopen=()=>{b()},l.onmessage=p=>{const w=JSON.parse(String(p.data));if(w.type==="exit"&&t(w.code),w.type==="error"&&n(w.message),w.type==="restore"){r(w.snapshot),g=!0,l.readyState===l.OPEN&&l.send(JSON.stringify({type:"restore_complete"}));for(const m of f.splice(0))o(m.chunk,m.acknowledge)}},{dispose(){d.close(),l.close()},resize(p,w,m,v){h={cols:p,rows:w},m!==void 0&&(h.pixelWidth=m),v!==void 0&&(h.pixelHeight=v),b()},sendBinaryInput(p){if(d.readyState!==d.OPEN)return;const w=new Uint8Array(p.length);for(let m=0;m<p.length;m++)w[m]=p.charCodeAt(m)&255;d.send(w)},sendInput(p){d.readyState===d.OPEN&&d.send(p)}}},re=16,oe=.3,se=(e,n)=>{const t=n==="up"?"A":"B";return e?`\x1BO${t}`:`\x1B[${t}`},ie=(e,n,t)=>n==="opencode"?t==="up"?"\x1B[5~":"\x1B[6~":se(e.modes?.applicationCursorKeysMode,t),ae=(e,n="default")=>{let t=0;return o=>{if(e.buffer?.active?.type!=="alternate")return t=0,{handled:!1,input:null};if(n!=="opencode"&&e.modes?.mouseTrackingMode&&e.modes.mouseTrackingMode!=="none")return t=0,{handled:!1,input:null};if(o.deltaY===0||o.shiftKey)return{handled:!1,input:null};let r=o.deltaY;return o.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=re,Math.abs(o.deltaY)<50&&(r*=oe),t+=r,r=Math.trunc(t),t%=1):t=0,r===0?{handled:!0,input:null}:{handled:!0,input:ie(e,n,r<0?"up":"down")}}},ce=({element:e,profile:n="default",sendInput:t,terminal:o})=>{const r=ae(o,n),c=a=>{const{handled:d,input:l}=r(a);return d?(a.preventDefault(),a.stopPropagation(),l&&t(l),!1):!0};if(typeof o.attachCustomWheelEventHandler=="function")return o.attachCustomWheelEventHandler(c),()=>{};const s=a=>{c(a)||a.stopImmediatePropagation()};return e.addEventListener("wheel",s,{capture:!0,passive:!1}),()=>e.removeEventListener("wheel",s,{capture:!0})},le=new RegExp("\x1B\\[M([\\s\\S])([\\s\\S])([\\s\\S])","g"),de=(e,n,t,o)=>{const r=n.charCodeAt(0)-32,c=t.charCodeAt(0)-32,s=o.charCodeAt(0)-32;if(r<0||c<1||s<1)return e;const d=(r&3)===3&&(r&32)===0&&(r&64)===0?"m":"M";return`\x1B[<${r};${c};${s}${d}`},ue=(e,n)=>{if(n!=="opencode")return{binary:!0,chunk:e};const t=e.replace(le,de);return{binary:t===e,chunk:t}},fe=(e,n="default")=>{const t=E.useRef(null),[o,r]=E.useState(null),[c,s]=E.useState("connecting");return E.useEffect(()=>{if(!t.current)return;let a=!1,d,l,g,f,h,b,p,w,m,v,S=null,P,L;const O={current:!1};return Promise.all([R(()=>import("./xterm-B-qIQCd3.js"),[]),R(()=>import("./addon-fit-DX4qG4td.js"),[]),R(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]),R(()=>import("./addon-clipboard-wHJhZAA4.js"),[])]).then(([$,j,U,Y])=>{if(a||!t.current)return;const W=typeof window<"u"?getComputedStyle(document.documentElement):null,q=W?.getPropertyValue("--bg-crust").trim()||"#0e0e0e",J=W?.getPropertyValue("--text-primary").trim()||"#ebebeb",u=new $.Terminal({allowProposedApi:!0,convertEol:!1,fontFamily:"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:13,letterSpacing:0,lineHeight:1,scrollback:1e4,theme:{background:q,foreground:J}}),M=new j.FitAddon;if(u.loadAddon(M),u.loadAddon(new U.Unicode11Addon),u.unicode.activeVersion="11",u.loadAddon(new Y.ClipboardAddon),u.open(t.current),M.fit(),b=u,p=M,v=ce({element:t.current,profile:n,sendInput:i=>h?.sendInput(i),terminal:u}),S=t.current.querySelector(".xterm-helper-textarea"),S){const i=S;P=()=>{O.current=!0},L=y=>{const T=y.data;T&&h?.sendInput(T),i.value="",setTimeout(()=>{O.current=!1},0)},S.addEventListener("compositionstart",P,{capture:!0}),S.addEventListener("compositionend",L,{capture:!0})}typeof u.attachCustomKeyEventHandler=="function"&&u.attachCustomKeyEventHandler(i=>{const y=te(i,{hasSelection:u.hasSelection()});switch(y.kind){case"send":return i.preventDefault(),h?.sendInput(y.bytes),!1;case"clear":return i.preventDefault(),u.clear(),!1;case"copy":{i.preventDefault();const T=u.getSelection();return T&&navigator.clipboard?.writeText(T).catch(()=>{}),u.clearSelection(),!1}case"block":return!1;case"passthrough":return!0}});const G=()=>{const i=t.current;return i?.isConnected?!i.closest('[data-terminal-host-parked="true"]'):!1},N=()=>{if(!t.current)return{};const i=t.current.clientWidth,y=t.current.clientHeight,T={};return y>0&&(T.pixelHeight=y),i>0&&(T.pixelWidth=i),T},I=()=>{if(!t.current||!G())return;p?.fit();const{pixelHeight:i,pixelWidth:y}=N();h?.resize(b?.cols??80,b?.rows??24,y,i)},K=()=>{m&&window.clearTimeout(m),m=window.setTimeout(()=>{m=void 0,I()},50)};R(()=>import("./addon-web-links-DIbG5aQx.js"),[]).then(i=>{a||b!==u||u.loadAddon(new i.WebLinksAddon)}).catch(()=>{}),R(()=>import("./addon-webgl-DCtw1yLn.js"),[]).then(i=>{if(!(a||b!==u))try{const y=new i.WebglAddon;y.onContextLoss(()=>y.dispose()),u.loadAddon(y),K()}catch{}}).catch(()=>{}),h=ne({initialSize:{cols:u.cols,rows:u.rows,...N()},onError(i){r(i)},onExit(){s("stopped")},onOutput(i,y){u.write(i,()=>y(new TextEncoder().encode(i).byteLength))},onRestore(i){u.write(i)},runId:e}),f=u.onData(i=>{O.current||h?.sendInput(i)}),typeof u.onBinary=="function"&&(g=u.onBinary(i=>{const y=ue(i,n);y.binary?h?.sendBinaryInput(y.chunk):h?.sendInput(y.chunk)})),s("running"),I(),typeof ResizeObserver<"u"&&t.current&&(w=new ResizeObserver(K),w.observe(t.current)),d=i=>{i.detail?.runId===e&&I()},l=()=>I(),window.addEventListener(z,d),window.addEventListener("resize",l)}),()=>{a=!0,d&&window.removeEventListener(z,d),l&&window.removeEventListener("resize",l),w?.disconnect(),m&&window.clearTimeout(m),v?.(),S&&P&&S.removeEventListener("compositionstart",P,{capture:!0}),S&&L&&S.removeEventListener("compositionend",L,{capture:!0}),g?.dispose(),f?.dispose(),h?.dispose(),b?.dispose(),p?.dispose()}},[e,n]),{containerRef:t,error:o,status:c}},pe={connecting:"terminal.statusConnecting",running:"terminal.statusRunning",stopped:"common.stopped"},D="hive-terminal-parking-lot",me=500,he=e=>[`worker-pty-${e}`,`orch-pty-${e}`,`shell-pty-${e}`],ye=e=>{const n=Array.from(document.querySelectorAll("[data-pty-slot]")).filter(t=>t.id===e);return n[n.length-1]??null},we=()=>{let e=document.getElementById(D);return e||(e=document.createElement("div"),e.id=D,e.hidden=!0,e.style.display="none",(document.body??document.documentElement).appendChild(e)),e},B=()=>{const e=document.getElementById(D);e&&e.childElementCount===0&&e.remove()},C=new Set;let x,A;const V=()=>{for(const e of C)e()},Ee=()=>{x?.disconnect(),x=void 0,A!==void 0&&(window.clearInterval(A),A=void 0)},ge=()=>{if(x||A!==void 0)return;const e=document.body??document.documentElement;if(typeof MutationObserver<"u"&&e){x=new MutationObserver(V),x.observe(e,{attributeFilter:["data-pty-slot","id"],attributes:!0,childList:!0,subtree:!0});return}A=window.setInterval(V,100)},be=e=>(C.add(e),ge(),()=>{C.delete(e),C.size===0&&Ee()}),Se=[50,150,300],Te=e=>{const n=[],t=[],o=()=>window.dispatchEvent(Q(e)),r=(c,s)=>{const a=window.setTimeout(()=>{const d=t.indexOf(a);d>=0&&t.splice(d,1),s()},c);t.push(a)};if(typeof window.requestAnimationFrame=="function"){const c=window.requestAnimationFrame(()=>{o();const s=window.requestAnimationFrame(o);n.push(s)});n.push(c)}else r(0,o);for(const c of Se)r(c,o);return()=>{for(const c of n)window.cancelAnimationFrame?.(c);for(const c of t)window.clearTimeout(c);n.length=0,t.length=0}},ve=e=>{const[n,t]=E.useState(null);return E.useEffect(()=>{const o=he(e),r=()=>{for(const s of o){const a=ye(s);if(a)return a}return null},c=()=>{const s=r();t(a=>a===s?a:s)};return c(),be(c)},[e]),n},_e=(e,n)=>{const[t,o]=E.useState(!1),[r,c]=E.useState(null),s=E.useRef(void 0),a=E.useRef(null),d=E.useRef(void 0),l=E.useCallback(()=>{s.current!==void 0&&(window.clearTimeout(s.current),s.current=void 0)},[]),g=E.useCallback(()=>{d.current?.(),d.current=void 0},[]);return E.useLayoutEffect(()=>{const f=document.createElement("div");return f.dataset.terminalHostRunId=e,f.dataset.terminalHostParked="false",f.className="h-full min-h-0 w-full min-w-0",a.current=f,c(f),()=>{l(),g(),f.remove(),a.current=null,B()}},[l,g,e]),E.useLayoutEffect(()=>{if(n){l(),o(!0);return}if(!(!t||s.current!==void 0))return s.current=window.setTimeout(()=>{s.current=void 0,o(!1)},me),l},[t,l,n]),E.useLayoutEffect(()=>{const f=a.current;if(!f)return;if(!t){g(),f.remove(),f.dataset.terminalHostParked="false",B();return}const h=n??we();if(f.parentElement===h)return;const b=f.parentElement!==null,p=document.activeElement;n||g(),!n&&p instanceof HTMLElement&&f.contains(p)&&p.blur(),f.dataset.terminalHostParked=n?"false":"true",h.appendChild(f),B(),n&&b&&(g(),d.current=Te(e))},[t,g,e,n]),t?r:null},ke=({inputProfile:e="default",runId:n,title:t})=>{const o=ve(n),r=_e(n,o);return r?X.createPortal(k.jsx(Re,{inputProfile:e,runId:n,title:t}),r):null},Re=({inputProfile:e,runId:n,title:t})=>{const{t:o}=F(),{containerRef:r,error:c,status:s}=fe(n,e),a=pe[s];return k.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden",children:[k.jsx("p",{className:"sr-only",children:a?o(a):s}),c?k.jsx("p",{role:"alert",className:"mono shrink-0 break-words px-3 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 12%, transparent)",borderBottom:"1px solid color-mix(in oklab, var(--status-red) 30%, transparent)",color:"var(--status-red)"},children:c}):null,k.jsx("div",{"data-testid":`terminal-${n}`,ref:r,className:"bg-crust h-full min-h-0 w-full min-w-0 flex-1 overflow-hidden"})]})},Ae=({hidden:e=!1,optimisticRuns:n=[],terminalRuns:t,workspaceId:o})=>{const{t:r}=F(),c=Z(t,n,o);return k.jsx("section",{hidden:e,"aria-hidden":e||void 0,"aria-label":r("terminalPanels.aria"),children:c.map(s=>k.jsx(ke,{inputProfile:s.terminal_input_profile??"default",runId:s.run_id,title:`${s.agent_name} (${s.status})`},s.run_id))})};export{Ae as WorkspaceTerminalPanels};