@coralai/sps-cli 0.58.35 → 0.58.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/console/routes/chat.d.ts.map +1 -1
- package/dist/console/routes/chat.js +25 -7
- package/dist/console/routes/chat.js.map +1 -1
- package/dist/console-assets/assets/{index-CBx2UTEQ.js → index-Qgd7qfvW.js} +1 -1
- package/dist/console-assets/index.html +1 -1
- package/dist/core/agents/AcpBackend.d.ts.map +1 -1
- package/dist/core/agents/AcpBackend.js +3 -2
- package/dist/core/agents/AcpBackend.js.map +1 -1
- package/dist/core/claudeJsonl.d.ts +10 -0
- package/dist/core/claudeJsonl.d.ts.map +1 -1
- package/dist/core/claudeJsonl.js +35 -0
- package/dist/core/claudeJsonl.js.map +1 -1
- package/dist/core/processInspect.d.ts.map +1 -1
- package/dist/core/processInspect.js +12 -6
- package/dist/core/processInspect.js.map +1 -1
- package/dist/manager/worker-manager-impl.d.ts.map +1 -1
- package/dist/manager/worker-manager-impl.js +1 -0
- package/dist/manager/worker-manager-impl.js.map +1 -1
- package/package.json +1 -1
|
@@ -611,7 +611,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
|
|
|
611
611
|
`,n)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=jf(t),i=lo(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=jf(t),i=lo(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function c2(e){const t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new l2||null,prettyErrors:t}}function Dz(e,t={}){const{lineCounter:n,prettyErrors:i}=c2(t),a=new lx(n==null?void 0:n.addNewLine),l=new sx(t),o=Array.from(l.compose(a.parse(e)));if(i&&n)for(const d of o)d.errors.forEach(yh(e,n)),d.warnings.forEach(yh(e,n));return o.length>0?o:Object.assign([],{empty:!0},l.streamInfo())}function u2(e,t={}){const{lineCounter:n,prettyErrors:i}=c2(t),a=new lx(n==null?void 0:n.addNewLine),l=new sx(t);let o=null;for(const d of l.compose(a.parse(e),!0,e.length))if(!o)o=d;else if(o.options.logLevel!=="silent"){o.errors.push(new Zs(d.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(o.errors.forEach(yh(e,n)),o.warnings.forEach(yh(e,n))),o}function Oz(e,t,n){let i;typeof t=="function"?i=t:n===void 0&&t&&typeof t=="object"&&(n=t);const a=u2(e,n);if(!a)return null;if(a.warnings.forEach(l=>C_(a.options.logLevel,l)),a.errors.length>0){if(a.options.logLevel!=="silent")throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:i},n))}function Rz(e,t,n){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:n===void 0&&t&&(n=t),typeof n=="string"&&(n=n.length),typeof n=="number"){const a=Math.round(n);n=a<1?void 0:a>8?{indent:8}:{indent:a}}if(e===void 0){const{keepUndefined:a}=n??t??{};if(!a)return}return wl(e)&&!i?e.toString(n):new rc(e,i,n).toString(n)}const Sk=Object.freeze(Object.defineProperty({__proto__:null,Alias:Kh,CST:Az,Composer:sx,Document:rc,Lexer:s2,LineCounter:l2,Pair:Vn,Parser:lx,Scalar:st,Schema:V_,YAMLError:rx,YAMLMap:Ni,YAMLParseError:Zs,YAMLSeq:ws,YAMLWarning:Q_,isAlias:Ss,isCollection:on,isDocument:wl,isMap:ec,isNode:cn,isPair:en,isScalar:Kt,isSeq:tc,parse:Oz,parseAllDocuments:Dz,parseDocument:u2,stringify:Rz,visit:kl,visitAsync:Hh},Symbol.toStringTag,{value:"Module"}));function Lz({projectName:e,file:t,onClose:n,onSaved:i}){const a=Be(),l=Gt(),{alert:o}=un(),{data:d,isLoading:f,isError:h,error:g,refetch:m}=Ye({queryKey:["pipeline-file",e,t],queryFn:()=>aI(e,t)}),[y,b]=j.useState("structured"),[k,v]=j.useState(null),[N,E]=j.useState(null);j.useEffect(()=>{d&&k===null&&(v(d.content),E(d.etag),d.parseError&&b("yaml"))},[d,k]),j.useEffect(()=>{const R=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n]);const C=Ct({mutationFn:()=>{if(k===null||N===null)throw new Error("no draft");return sI(e,t,k,N)},onSuccess:R=>{E(R.etag),l.invalidateQueries({queryKey:["pipeline-file",e,t]}),l.invalidateQueries({queryKey:["project-pipelines",e]}),i()},onError:R=>{const O=R.status;o({title:a(O===409?"pipelineEditor.error.conflict.title":O===422?"pipelineEditor.error.yaml.title":"pipelineEditor.error.save.title"),body:R instanceof Error?R.message:String(R)})}}),S=k!==null&&d&&k!==d.content,{parsed:_,parseError:M}=j.useMemo(()=>{if(k===null)return{parsed:null,parseError:null};try{return{parsed:Sk.parse(k)??{},parseError:null}}catch(R){return{parsed:null,parseError:R instanceof Error?R.message:String(R)}}},[k]),T=R=>{try{const O=Sk.stringify(R,{lineWidth:0});v(O)}catch(O){o({title:a("pipelineEditor.error.serialize.title"),body:O instanceof Error?O.message:String(O)})}};return c.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-start justify-center p-6 bg-black/30 overflow-auto",children:c.jsxs("div",{className:"nb-card mt-8 w-full max-w-4xl flex flex-col",style:{maxHeight:"calc(100vh - 64px)"},children:[c.jsxs("header",{className:"flex items-start justify-between gap-3 mb-3 flex-shrink-0",children:[c.jsxs("div",{children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold flex items-center gap-2",children:[c.jsx(uk,{size:20,strokeWidth:2.5}),c.jsx("code",{className:"font-[family-name:var(--font-mono)] text-lg",children:t}),(d==null?void 0:d.isActive)&&c.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)",padding:"2px 8px"},children:a("pipelineEditor.activeBadge")})]}),c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] mt-1",children:[e,"/pipelines/",t,N&&` · etag ${N}`]})]}),c.jsx("button",{className:"nb-btn nb-btn-mint p-2",onClick:n,type:"button","aria-label":a("pipelineEditor.close"),children:c.jsx(bn,{size:14,strokeWidth:3})})]}),f&&c.jsx("p",{className:"text-[var(--color-text-muted)]",children:a("common.loading")}),h&&c.jsx("p",{className:"text-[var(--color-crashed)]",children:a("pipelineEditor.error.load",{detail:g instanceof Error?g.message:String(g)})}),d&&k!==null&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-3 mb-3 flex-shrink-0 flex-wrap",children:[c.jsxs("div",{className:"flex gap-1 p-1 bg-[var(--color-bg)] border-[2px] border-[var(--color-text)] rounded-full shadow-[2px_2px_0_var(--color-text)]",children:[c.jsxs("button",{type:"button",onClick:()=>b("structured"),"aria-pressed":y==="structured",disabled:!!M,className:["px-3 py-1 rounded-full text-xs font-bold flex items-center gap-1.5",y==="structured"?"bg-[var(--color-primary)] text-[var(--color-text)] shadow-[1px_1px_0_var(--color-text)]":"text-[var(--color-text-muted)]",M?"opacity-50 cursor-not-allowed":""].join(" "),title:M??void 0,children:[c.jsx(Fh,{size:11,strokeWidth:2.5}),a("pipelineEditor.mode.structured")]}),c.jsxs("button",{type:"button",onClick:()=>b("yaml"),"aria-pressed":y==="yaml",className:["px-3 py-1 rounded-full text-xs font-bold flex items-center gap-1.5",y==="yaml"?"bg-[var(--color-primary)] text-[var(--color-text)] shadow-[1px_1px_0_var(--color-text)]":"text-[var(--color-text-muted)]"].join(" "),children:[c.jsx(uk,{size:11,strokeWidth:2.5}),a("pipelineEditor.mode.yaml")]})]}),M&&c.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--color-crashed)] font-bold",children:[c.jsx(ku,{size:12,strokeWidth:2.5}),a("pipelineEditor.parseError.prefix",{detail:M})]}),(d==null?void 0:d.isActive)&&c.jsx("span",{className:"text-xs text-[var(--color-stuck)] font-bold ml-auto",children:a("pipelineEditor.activeWarning")})]}),c.jsxs("div",{className:"flex-1 overflow-auto",children:[y==="structured"&&_&&c.jsx(Iz,{parsed:_,onChange:T}),y==="yaml"&&c.jsx("textarea",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",style:{minHeight:400,resize:"vertical"},value:k,onChange:R=>v(R.target.value),spellCheck:!1,"aria-label":a("pipelineEditor.yamlAria")})]}),c.jsxs("div",{className:"flex items-center justify-between mt-3 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:S?c.jsx("span",{className:"text-[var(--color-stuck)] font-bold",children:a("pipelineEditor.status.unsaved")}):C.isSuccess?c.jsxs("span",{className:"text-[var(--color-running)] font-bold flex items-center gap-1",children:[c.jsx(Eu,{size:12,strokeWidth:2.5})," ",a("pipelineEditor.status.saved")]}):a("pipelineEditor.status.noChanges")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},onClick:()=>{v(null),m()},disabled:C.isPending,type:"button",children:a("pipelineEditor.reload")}),c.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 14px"},onClick:()=>C.mutate(),disabled:!S||C.isPending,type:"button","aria-label":a("pipelineEditor.saveAria"),children:[C.isPending?c.jsx(Xe,{size:13,strokeWidth:3,className:"animate-spin"}):c.jsx(Rr,{size:13,strokeWidth:3}),a("pipelineEditor.save")]})]})]})]})]})})}function Iz({parsed:e,onChange:t}){const n=Be(),i=e.stages??[],a=h=>{t({...e,stages:h})},l=()=>{a([...i,{name:`stage-${i.length+1}`,on_complete:"move_card Done"}])},o=h=>{a(i.filter((g,m)=>m!==h))},d=(h,g)=>{const m=[...i],y=h+g;y<0||y>=m.length||([m[h],m[y]]=[m[y],m[h]],a(m))},f=(h,g)=>{a(i.map((m,y)=>y===h?{...m,...g}:m))};return c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsxs("div",{className:"flex bg-surface-input items-center gap-3 p-3 border-2 border-[var(--color-text)] rounded-lg",children:[c.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[c.jsx("span",{className:"font-bold",children:"mode:"}),c.jsxs("select",{className:"nb-input",style:{padding:"4px 10px",fontSize:12},value:e.mode??"project",onChange:h=>t({...e,mode:h.target.value}),children:[c.jsx("option",{value:"project",children:"project"}),c.jsx("option",{value:"steps",children:"steps"})]})]}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:n("pipelineEditor.modeHint")})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider",children:n("pipelineEditor.stages.heading",{count:i.length})}),c.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",style:{padding:"4px 12px",fontSize:12},onClick:l,"aria-label":n("pipelineEditor.stages.add"),children:[c.jsx(pi,{size:11,strokeWidth:3})," ",n("pipelineEditor.stages.add")]})]}),i.length===0?c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] italic p-4 border-2 border-dashed border-[var(--color-text)] rounded-lg text-center",children:n("pipelineEditor.stages.empty")}):c.jsx("div",{className:"flex flex-col gap-3",children:i.map((h,g)=>c.jsx(zz,{stage:h,index:g,total:i.length,onChange:m=>f(g,m),onRemove:()=>o(g),onMoveUp:()=>d(g,-1),onMoveDown:()=>d(g,1)},g))})]})]})}function zz({stage:e,index:t,total:n,onChange:i,onRemove:a,onMoveUp:l,onMoveDown:o}){const d=Be(),f=e.on_fail??{};return c.jsxs("div",{className:"nb-card bg-[var(--color-bg-cream)] p-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("h4",{className:"font-[family-name:var(--font-heading)] font-bold text-sm",children:["Stage #",t+1,e.name&&c.jsx("code",{className:"ml-2 text-xs font-[family-name:var(--font-mono)] bg-[var(--color-bg)] border-2 border-[var(--color-text)] px-2 py-0.5 rounded",children:e.name})]}),c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"3px 8px"},onClick:l,disabled:t===0,"aria-label":d("pipelineEditor.stage.moveUp"),children:c.jsx(FR,{size:12,strokeWidth:3})}),c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"3px 8px"},onClick:o,disabled:t===n-1,"aria-label":d("pipelineEditor.stage.moveDown"),children:c.jsx(Vu,{size:12,strokeWidth:3})}),c.jsx("button",{type:"button",className:"nb-btn nb-btn-danger",style:{padding:"3px 8px"},onClick:a,"aria-label":d("pipelineEditor.stage.remove"),children:c.jsx(fr,{size:12,strokeWidth:3})})]})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[c.jsx(es,{label:"name",hint:d("pipelineEditor.stage.name.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.name??"",onChange:h=>i({name:h.target.value}),placeholder:"develop"})}),c.jsx(es,{label:"profile",hint:d("pipelineEditor.stage.profile.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.profile??"",onChange:h=>i({profile:h.target.value||void 0}),placeholder:"fullstack"})}),c.jsx(es,{label:"card_state",hint:d("pipelineEditor.stage.cardState.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.card_state??"",onChange:h=>i({card_state:h.target.value||void 0}),placeholder:"Inprogress"})}),c.jsx(es,{label:"timeout",hint:d("pipelineEditor.stage.timeout.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.timeout??"",onChange:h=>i({timeout:h.target.value||void 0}),placeholder:"2h"})}),c.jsx(es,{label:"trigger",hint:d("pipelineEditor.stage.trigger.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.trigger??"",onChange:h=>i({trigger:h.target.value||void 0}),placeholder:"card_enters 'Todo'"})}),c.jsx(es,{label:"on_complete",hint:d("pipelineEditor.stage.onComplete.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:e.on_complete??"",onChange:h=>i({on_complete:h.target.value}),placeholder:"move_card Done"})})]}),c.jsxs("div",{className:"mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)]",children:[c.jsx("h5",{className:"text-xs font-bold uppercase tracking-wider mb-2 text-[var(--color-text-muted)]",children:"on_fail"}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[c.jsx(es,{label:"action",hint:d("pipelineEditor.stage.onFail.action.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:f.action??"",onChange:h=>i({on_fail:{...f,action:h.target.value||void 0}}),placeholder:"label NEEDS-FIX"})}),c.jsx(es,{label:"comment",hint:d("pipelineEditor.stage.onFail.comment.hint"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:f.comment??"",onChange:h=>i({on_fail:{...f,comment:h.target.value||void 0}}),placeholder:"Worker failed. Check logs."})})]}),c.jsxs("label",{className:"flex items-center gap-2 mt-3 text-sm cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:f.halt??!0,onChange:h=>i({on_fail:{...f,halt:h.target.checked}})}),c.jsx("span",{className:"font-bold",children:"halt"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:d("pipelineEditor.stage.halt.note")})]})]})]})}function es({label:e,hint:t,children:n}){return c.jsxs("label",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"text-xs font-bold font-[family-name:var(--font-mono)]",children:e}),n,t&&c.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)]",children:t})]})}function Pz({onCancel:e,onCreate:t,hasActive:n,hasSample:i,isPending:a}){const l=Be(),[o,d]=j.useState(""),[f,h]=j.useState("blank");j.useEffect(()=>{const N=E=>{E.key==="Escape"&&e()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[e]);const g=o.trim(),m=g.endsWith(".yaml")?g:g?`${g}.yaml`:"",y=m&&/^[a-zA-Z0-9_.-]+\.yaml$/.test(m),b=()=>{!y||a||t(m,f)},v=l("newPipelineDialog.field.filename.help",{filename:"__FN__"}).split("__FN__");return c.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:c.jsxs("div",{className:"nb-card max-w-md w-full",children:[c.jsxs("header",{className:"flex items-start justify-between mb-4",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold",children:l("newPipelineDialog.title")}),c.jsx("button",{className:"nb-btn nb-btn-mint p-2",onClick:e,type:"button","aria-label":l("common.close"),children:c.jsx(bn,{size:14,strokeWidth:3})})]}),c.jsxs("form",{onSubmit:N=>{N.preventDefault(),b()},className:"flex flex-col gap-4",children:[c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-sm font-bold",children:l("newPipelineDialog.field.filename.label")}),c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",placeholder:l("newPipelineDialog.field.filename.placeholder"),value:o,onChange:N=>d(N.target.value),autoFocus:!0}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)]",children:[v[0],c.jsx("code",{className:"font-[family-name:var(--font-mono)]",children:m||"xxx.yaml"}),v[1]]})]}),c.jsxs("fieldset",{className:"flex flex-col gap-2",children:[c.jsx("legend",{className:"text-sm font-bold mb-1",children:l("newPipelineDialog.section.template")}),c.jsx(Bg,{value:"blank",current:f,label:l("newPipelineDialog.template.blank.label"),desc:l("newPipelineDialog.template.blank.desc"),onSelect:h}),c.jsx(Bg,{value:"sample",current:f,label:l("newPipelineDialog.template.sample.label"),desc:l("newPipelineDialog.template.sample.desc"),onSelect:h,disabled:!i,disabledReason:l("newPipelineDialog.template.sample.unavailable")}),c.jsx(Bg,{value:"active",current:f,label:l("newPipelineDialog.template.active.label"),desc:l("newPipelineDialog.template.active.desc"),onSelect:h,disabled:!n,disabledReason:l("newPipelineDialog.template.active.unavailable")})]}),c.jsxs("div",{className:"flex gap-3 justify-end pt-2",children:[c.jsx("button",{className:"nb-btn",onClick:e,type:"button",disabled:a,children:l("common.cancel")}),c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"submit",disabled:!y||a,"aria-label":l("newPipelineDialog.create.aria"),children:[a?c.jsx(Xe,{size:13,strokeWidth:3,className:"animate-spin"}):c.jsx(pi,{size:13,strokeWidth:3}),l("common.create")]})]})]})]})})}function Bg({value:e,current:t,label:n,desc:i,onSelect:a,disabled:l,disabledReason:o}){const d=t===e;return c.jsxs("label",{className:["flex items-start gap-2 p-2 rounded-lg border-2 cursor-pointer",l?"border-[var(--color-border-light)] opacity-50 cursor-not-allowed":d?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)]":"border-[var(--color-border-light)] hover:bg-[var(--color-bg-cream)] hover:border-[var(--color-text)]"].join(" "),children:[c.jsx("input",{type:"radio",name:"pipeline-template",value:e,checked:d,disabled:l,onChange:()=>a(e),className:"mt-1 flex-shrink-0"}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"text-sm font-bold",children:n}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)]",children:l?o:i})]})]})}function Bz(e){return ft(`/api/rules/${encodeURIComponent(e)}`)}function ox(e){const t=e?`?project=${encodeURIComponent(e)}`:"";return ft(`/api/skills${t}`)}function $z(e){return ft(`/api/skills/${encodeURIComponent(e)}`)}function Uz(e,t){return ft(`/api/skills/${encodeURIComponent(e)}/references/${encodeURIComponent(t)}`)}async function Fz(e,t){const n=await fetch(e,{method:"POST",headers:void 0,body:void 0});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json().catch(()=>({}))}function qz(){return Fz("/api/skills/sync")}function Hz(e){return ft(`/api/skills/policy/${encodeURIComponent(e)}`)}function Kz(e,t){return Hb(`/api/skills/policy/${encodeURIComponent(e)}`,t)}function Gz(){return ft("/api/skills/updates")}function Vz(e,t,n){return Lr("/api/skills/import",{name:e,files:t,overwrite:n})}function Yz(e){return ft(`/api/skills/${encodeURIComponent(e)}/export`)}function Qz(e,t){return Lr("/api/skills/create",{name:e,intent:t})}function d2(){return c.jsx("div",{className:"nb-card",children:c.jsxs("p",{className:"text-[var(--color-text-muted)] flex items-center gap-2",children:[c.jsx(Xe,{size:14,className:"animate-spin"})," …"]})})}function f2({msg:e}){return c.jsx("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:c.jsx("p",{children:e})})}function Wz({name:e}){var b,k;const t=Be(),n=Gt(),{alert:i}=un(),a=Ye({queryKey:["skill-policy",e],queryFn:()=>Hz(e),enabled:!!e}),l=(b=a.data)==null?void 0:b.data,[o,d]=j.useState(null),[f,h]=j.useState(null);j.useEffect(()=>{var v;l&&o===null&&d((v=l.policy.allow)!=null&&v.length?new Set(l.policy.allow):new Set(l.skills.map(N=>N.name)))},[l,o]);const g=Ct({mutationFn:v=>Kz(e,v),onSuccess:v=>{h(v),d(null),n.invalidateQueries({queryKey:["skill-policy",e]})},onError:v=>void i({title:t("projectDetail.skills.saveError"),body:v instanceof Error?v.message:String(v)})});if(a.isLoading||l&&o===null)return c.jsx(d2,{});if(a.isError)return c.jsx(f2,{msg:a.error instanceof Error?a.error.message:String(a.error)});if(!l||!o)return null;if(l.skills.length===0)return c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:t("projectDetail.skills.empty")})});const m=l.eligible!==null,y=v=>d(N=>{const E=new Set(N);return E.has(v)?E.delete(v):E.add(v),E});return c.jsxs("div",{className:"nb-card flex flex-col gap-4 h-full min-h-0",children:[c.jsxs("div",{className:"shrink-0",children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold flex items-center gap-2",children:[c.jsx(e_,{size:18,strokeWidth:2.5}),t("projectDetail.skills.title")]}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:t("projectDetail.skills.desc")}),c.jsx("p",{className:"text-sm mt-1 font-medium",children:m?t("projectDetail.skills.hasPolicy",{count:String(((k=l.eligible)==null?void 0:k.length)??0)}):t("projectDetail.skills.noPolicy")})]}),c.jsxs("div",{className:"flex gap-2 shrink-0",children:[c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"4px 10px",fontSize:12},onClick:()=>d(new Set(l.skills.map(v=>v.name))),children:t("projectDetail.skills.selectAll")}),c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"4px 10px",fontSize:12},onClick:()=>d(new Set),children:t("projectDetail.skills.selectNone")})]}),c.jsx("div",{className:"flex bg-surface-input flex-col gap-1 flex-1 min-h-0 overflow-auto border-2 border-[var(--color-text)] rounded p-2",children:l.skills.map(v=>c.jsxs("label",{className:"flex items-start gap-2 px-2 py-1 rounded hover:bg-[var(--color-bg-cream)] cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:o.has(v.name),onChange:()=>y(v.name),className:"mt-1"}),c.jsxs("span",{className:"flex-1",children:[c.jsx("code",{className:"font-[family-name:var(--font-mono)] text-sm font-bold",children:v.name}),c.jsx("span",{className:"ml-2 text-[10px] uppercase text-[var(--color-text-muted)]",children:v.category}),v.description&&c.jsx("span",{className:"block text-xs text-[var(--color-text-muted)]",children:v.description})]})]},v.name))}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap shrink-0",children:[c.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",disabled:g.isPending,onClick:()=>g.mutate({allow:[...o]}),children:[g.isPending?c.jsx(Xe,{size:14,className:"animate-spin"}):c.jsx(Rr,{size:14,strokeWidth:3}),t("projectDetail.skills.save")]}),c.jsxs("button",{type:"button",className:"nb-btn",disabled:g.isPending,onClick:()=>g.mutate({}),children:[c.jsx(Bb,{size:14,strokeWidth:3}),t("projectDetail.skills.clear")]}),c.jsxs("span",{className:"text-sm text-[var(--color-text-muted)]",children:[o.size,"/",l.skills.length]})]}),f&&c.jsxs("div",{className:"text-sm border-2 border-[var(--color-text)] rounded p-2 bg-[var(--color-bg-cream)]",children:[c.jsx("p",{children:t("projectDetail.skills.applied",{linked:String(f.applied.linked),pruned:String(f.applied.pruned)})}),f.unknown.length>0&&c.jsx("p",{className:"text-[var(--color-text-muted)]",children:t("projectDetail.skills.unknown",{names:f.unknown.join(", ")})})]})]})}function Xz({name:e}){var a;const t=Be(),n=Ye({queryKey:["rules",e],queryFn:()=>Bz(e),enabled:!!e});if(n.isLoading)return c.jsx(d2,{});if(n.isError)return c.jsx(f2,{msg:n.error instanceof Error?n.error.message:String(n.error)});const i=((a=n.data)==null?void 0:a.data)??[];return c.jsxs("div",{className:"flex flex-col gap-4 min-h-full",children:[c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:t("projectDetail.rules.readonly")}),i.map(l=>c.jsxs("div",{className:"nb-card",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx("code",{className:"font-[family-name:var(--font-mono)] text-sm font-bold border-2 border-[var(--color-text)] px-2 py-0.5 rounded",children:l.name}),!l.exists&&c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:t("projectDetail.rules.missing")})]}),l.exists&&c.jsx("pre",{className:"overflow-auto max-h-[28rem] text-xs font-[family-name:var(--font-mono)] whitespace-pre-wrap break-words bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-3",children:l.content})]},l.name))]})}const ip=e=>`/api/projects/${encodeURIComponent(e)}/graph`;function Zz(e){return ft(`${ip(e)}/status`)}function Jz(e){return ft(`${ip(e)}/data`)}function e4(e){return Lr(`${ip(e)}/build`)}function t4(e){return Lr(`${ip(e)}/sync`)}const n4={typescript:"#1D4E89",tsx:"#2563EB",javascript:"#B8860B",json:"#6B7280",yaml:"#C2410C"},Cf=e=>n4[e]??"#2D6A4F";function Nk(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}const i4=e=>Math.max(8,Math.min(22,8+e*2.5));function r4(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function a4(e){if(!e)return"—";const t=new Date(e);if(Number.isNaN(t.getTime()))return"—";const n=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function s4({name:e,status:t}){var y,b,k,v;const n=Be(),i=Ye({queryKey:["graph-data",e],queryFn:()=>Jz(e)}),[a,l]=j.useState(""),o=j.useRef(null),d=j.useRef(null),f=j.useRef(null),h=j.useRef(null),g=[...new Set((((b=(y=i.data)==null?void 0:y.data)==null?void 0:b.nodes)??[]).map(N=>N.language))];if(j.useEffect(()=>{h.current&&(h.current.search=a.trim().toLowerCase())},[a]),j.useEffect(()=>{var De;const N=(De=i.data)==null?void 0:De.data,E=d.current,C=o.current;if(!N||!N.nodes.length||!E||!C)return;const S=E.getContext("2d");if(!S)return;const _={};for(const ce of N.links)_[ce.source]=(_[ce.source]??0)+1,_[ce.target]=(_[ce.target]??0)+1;const M=N.nodes.length,T=window.devicePixelRatio||1,R=C.getBoundingClientRect(),O=R.width||800,$=R.height||500,I=Math.min(O,$)*.35+M*1.5,q=N.nodes.map((ce,Ce)=>{const te=2*Math.PI*Ce/Math.max(M,1),pe=_[ce.id]??0;return{id:ce.id,language:ce.language,symbols:ce.symbols,deg:pe,name:ce.id.split("/").pop()||ce.id,x:Math.cos(te)*I+Math.sin(Ce*12.9898)*43758.5453%1*40,y:Math.sin(te)*I+Math.sin(Ce*78.233)*12345.678%1*40,vx:0,vy:0,r:i4(pe)}}),F={};for(const ce of q)F[ce.id]=ce;const Y=N.links.map(ce=>({source:ce.source,target:ce.target,weight:ce.weight})),D={nodes:q,edges:Y,map:F,panX:O/2,panY:$/2,zoom:1,drag:null,mouseX:0,mouseY:0,raf:null,tick:0,quiet:0,sel:null,search:a.trim().toLowerCase(),fitted:!1};h.current=D;const K=()=>{const ce=C.getBoundingClientRect();E.width=ce.width*T,E.height=ce.height*T,E.style.width=ce.width+"px",E.style.height=ce.height+"px",S.setTransform(T,0,0,T,0,0)};K();const P=new ResizeObserver(K);P.observe(C);const H=()=>{let ce=1/0,Ce=1/0,te=-1/0,pe=-1/0;for(const be of q)ce=Math.min(ce,be.x-be.r),Ce=Math.min(Ce,be.y-be.r),te=Math.max(te,be.x+be.r),pe=Math.max(pe,be.y+be.r);const Fe=E.width/T,ze=E.height/T,ae=Math.min(Fe/Math.max(te-ce,1),ze/Math.max(pe-Ce,1),1.4)*.88;D.zoom=ae,D.panX=Fe/2-(ce+te)/2*ae,D.panY=ze/2-(Ce+pe)/2*ae},Q=()=>{const ce=q.length;D.tick++;const Ce=.9-Math.min(.4,D.tick/1500),te=ce>1e3?3e3:ce>100?2e3:ce>50?1200:800,pe=ce>100?.002:.005,Fe=ce>1e3?.012:ce>100?.005:.01,ze=ce>1e3?6:ce>200?12:24;for(let ye=0;ye<ce;ye++){const he=q[ye];let Ee=-he.x*Fe,Ne=-he.y*Fe;for(let Ke=0;Ke<ce;Ke++){if(ye===Ke)continue;const ne=q[Ke],de=he.x-ne.x,Le=he.y-ne.y,Ze=de*de+Le*Le||1,rt=Math.sqrt(Ze),At=te/Ze;Ee+=de/rt*At,Ne+=Le/rt*At}if(he!==D.drag){let Ke=(he.vx+Ee)*Ce,ne=(he.vy+Ne)*Ce;Ke=Math.max(-ze,Math.min(ze,Ke)),ne=Math.max(-ze,Math.min(ze,ne)),he.vx=Ke,he.vy=ne}}for(const ye of Y){const he=F[ye.source],Ee=F[ye.target];if(!he||!Ee)continue;const Ne=Ee.x-he.x,Ke=Ee.y-he.y,ne=Math.sqrt(Ne*Ne+Ke*Ke)||1,de=(ne-100)*pe,Le=Ne/ne*de,Ze=Ke/ne*de;he!==D.drag&&(he.vx+=Le,he.vy+=Ze),Ee!==D.drag&&(Ee.vx-=Le,Ee.vy-=Ze)}let ae=0;for(const ye of q)ye!==D.drag&&(ye.x+=ye.vx,ye.y+=ye.vy,ae+=ye.vx*ye.vx+ye.vy*ye.vy);(ce?Math.sqrt(ae/ce):0)<.05&&D.tick>60&&!D.drag?D.quiet++:D.quiet=0,!D.fitted&&(D.quiet>8||D.tick>400)&&(D.fitted=!0,H())},G=()=>{const ce=E.width/T,Ce=E.height/T;S.clearRect(0,0,ce,Ce),S.strokeStyle="rgba(45,55,72,0.05)",S.lineWidth=.5;for(let be=0;be<ce;be+=24)S.beginPath(),S.moveTo(be,0),S.lineTo(be,Ce),S.stroke();for(let be=0;be<Ce;be+=24)S.beginPath(),S.moveTo(0,be),S.lineTo(ce,be),S.stroke();S.save(),S.translate(D.panX,D.panY),S.scale(D.zoom,D.zoom);const te=D.search,pe=q.length>40;let Fe=null;if(!D.drag){const be=E.getBoundingClientRect(),ye=(D.mouseX-be.left-D.panX)/D.zoom,he=(D.mouseY-be.top-D.panY)/D.zoom;for(let Ee=q.length-1;Ee>=0;Ee--){const Ne=q[Ee],Ke=Ne.x-ye,ne=Ne.y-he;if(Ke*Ke+ne*ne<Ne.r*Ne.r+25){Fe=Ne.id;break}}}const ze=D.sel||Fe;for(const be of Y){const ye=F[be.source],he=F[be.target];if(!ye||!he)continue;const Ee=te&&!(ye.name.toLowerCase().includes(te)||he.name.toLowerCase().includes(te)),Ne=ze&&(be.source===ze||be.target===ze),Ke=he.x-ye.x,ne=he.y-ye.y,de=Math.sqrt(Ke*Ke+ne*ne)||1,Le=pe?12:18,Ze=(ye.x+he.x)/2+-ne/de*Le,rt=(ye.y+he.y)/2+Ke/de*Le,[At,$n,dn]=Nk(Cf(ye.language));let Mt;if(Ee?Mt=.05:ze&&Ne?Mt=.6:ze&&!Ne?Mt=.05:Mt=pe?.14:.24,S.beginPath(),S.moveTo(ye.x,ye.y),S.quadraticCurveTo(Ze,rt,he.x,he.y),S.strokeStyle=`rgba(${At},${$n},${dn},${Mt})`,S.lineWidth=Ne?2+be.weight*.4:1+be.weight*.25,S.stroke(),!pe||Ne){const Qt=Math.atan2(he.y-rt,he.x-Ze),yt=5+S.lineWidth;S.beginPath(),S.moveTo(he.x-he.r*Math.cos(Qt),he.y-he.r*Math.sin(Qt)),S.lineTo(he.x-(he.r+yt)*Math.cos(Qt-.3),he.y-(he.r+yt)*Math.sin(Qt-.3)),S.lineTo(he.x-(he.r+yt)*Math.cos(Qt+.3),he.y-(he.r+yt)*Math.sin(Qt+.3)),S.closePath(),S.fillStyle=`rgba(${At},${$n},${dn},${Ee?.05:Ne?.55:.18})`,S.fill()}}const ae=pe?1.5:.5;for(const be of q){const ye=Cf(be.language),he=D.sel===be.id,Ee=Fe===be.id,Ne=!te||be.name.toLowerCase().includes(te),Ke=ze&&be.id!==ze&&!Y.some(At=>At.source===ze&&At.target===be.id||At.target===ze&&At.source===be.id),ne=Ne?Ke?.2:1:.12;S.save(),S.globalAlpha=ne,Ne&&!Ke&&(he||Ee||!te)&&(S.shadowColor=ye,S.shadowBlur=he?20:Ee?16:pe?4:8);const[de,Le,Ze]=Nk(ye),rt=S.createRadialGradient(be.x-be.r*.3,be.y-be.r*.3,0,be.x,be.y,be.r*1.2);if(rt.addColorStop(0,`rgba(${Math.min(255,de+60)},${Math.min(255,Le+60)},${Math.min(255,Ze+60)},0.95)`),rt.addColorStop(1,ye),S.beginPath(),S.arc(be.x,be.y,be.r,0,Math.PI*2),S.fillStyle=rt,S.fill(),S.shadowBlur=0,S.lineWidth=he?2.5:1,S.strokeStyle=he?"#111827":"rgba(255,255,255,0.7)",S.stroke(),S.restore(),Ne&&!Ke&&(he||Ee||D.zoom>ae)){const At=1/D.zoom;S.save(),S.globalAlpha=ne,S.fillStyle="rgba(45,55,72,0.92)",S.font=`${(10*At).toFixed(1)}px 'DM Sans', sans-serif`,S.textAlign="center",S.fillText(be.name,be.x,be.y+be.r+11*At),S.restore()}}S.restore()},L=()=>{if(Q(),G(),D.quiet>40&&!D.drag){D.raf=null;return}D.raf=requestAnimationFrame(L)},z=()=>{D.raf==null&&(D.quiet=0,D.raf=requestAnimationFrame(L))};D.raf=requestAnimationFrame(L);let V=!1,B=0,le=0;const ve=ce=>{const Ce=E.getBoundingClientRect();return{x:(ce.clientX-Ce.left-D.panX)/D.zoom,y:(ce.clientY-Ce.top-D.panY)/D.zoom}},ke=(ce,Ce)=>{for(let te=q.length-1;te>=0;te--){const pe=q[te];if(!pe)continue;const Fe=pe.x-ce,ze=pe.y-Ce;if(Fe*Fe+ze*ze<pe.r*pe.r+25)return pe}return null},Se=ce=>{const Ce=ve(ce),te=ke(Ce.x,Ce.y);te?D.drag=te:V=!0,B=ce.clientX,le=ce.clientY,z()},J=ce=>{const Ce=ce.clientX-B,te=ce.clientY-le;D.drag?(D.drag.x+=Ce/D.zoom,D.drag.y+=te/D.zoom,D.drag.vx=0,D.drag.vy=0,z()):V&&(D.panX+=Ce,D.panY+=te,z()),B=ce.clientX,le=ce.clientY,D.mouseX=ce.clientX,D.mouseY=ce.clientY;const pe=f.current,Fe=ve(ce),ze=!D.drag&&!V?ke(Fe.x,Fe.y):null;if(pe)if(ze){const ae=Y.filter(ye=>ye.source===ze.id||ye.target===ze.id).length;pe.innerHTML=`<div style="font-weight:700;word-break:break-all">${ze.id}</div><div style="margin-top:4px;color:#64748b;font-family:var(--font-mono,monospace)"><span style="color:${Cf(ze.language)}">●</span> ${ze.language} · ${ze.symbols} symbols · ${ae} links</div>`;const be=E.getBoundingClientRect();pe.style.left=ce.clientX-be.left+14+"px",pe.style.top=ce.clientY-be.top+14+"px",pe.style.display="block",E.style.cursor="pointer"}else pe.style.display="none",E.style.cursor=D.drag||V?"grabbing":"grab";z()},ue=ce=>{D.drag&&!V?Math.abs(ce.clientX-B)>3||(D.sel=D.sel===D.drag.id?null:D.drag.id):V&&Math.abs(ce.clientX-B)<3&&Math.abs(ce.clientY-le)<3&&(D.sel=null),D.drag=null,V=!1,z()},Te=ce=>{ce.preventDefault();const Ce=E.getBoundingClientRect(),te=ce.clientX-Ce.left,pe=ce.clientY-Ce.top,Fe=ce.deltaY>0?.9:1.1,ze=Math.max(.1,Math.min(5,D.zoom*Fe));D.panX=te-(te-D.panX)/D.zoom*ze,D.panY=pe-(pe-D.panY)/D.zoom*ze,D.zoom=ze,z()},Re=()=>{f.current&&(f.current.style.display="none")};return E.addEventListener("mousedown",Se),window.addEventListener("mousemove",J),window.addEventListener("mouseup",ue),E.addEventListener("wheel",Te,{passive:!1}),E.addEventListener("mouseleave",Re),()=>{D.raf!=null&&cancelAnimationFrame(D.raf),P.disconnect(),E.removeEventListener("mousedown",Se),window.removeEventListener("mousemove",J),window.removeEventListener("mouseup",ue),E.removeEventListener("wheel",Te),E.removeEventListener("mouseleave",Re),h.current=null}},[i.data]),i.isLoading)return c.jsxs("div",{className:"nb-card flex items-center gap-2 text-sm text-[var(--color-text-muted)]",children:[c.jsx(Xe,{size:14,className:"animate-spin"})," ",n("graph.viz.loading")]});if(!((v=(k=i.data)==null?void 0:k.data)!=null&&v.nodes.length))return c.jsx("div",{className:"nb-card text-sm text-[var(--color-text-muted)]",children:n("graph.viz.empty")});const m=[{label:n("graph.stat.files"),value:t.files.toLocaleString()},{label:n("graph.stat.nodes"),value:t.nodes.toLocaleString()},{label:n("graph.stat.edges"),value:t.edges.toLocaleString()},{label:n("graph.stat.db"),value:r4(t.dbSizeBytes)},{label:n("graph.stat.lastBuilt"),value:a4(t.lastIndexedAt)}];return c.jsxs("div",{ref:o,className:"relative w-full flex-1 min-h-[420px] nb-card p-0 overflow-hidden",style:{background:"var(--color-bg-cream)"},children:[c.jsx("canvas",{ref:d,className:"block absolute inset-0",style:{cursor:"grab"}}),c.jsx("div",{ref:f,className:"absolute z-40 pointer-events-none nb-card bg-[var(--color-bg)] px-3 py-2 text-xs max-w-xs",style:{display:"none"}}),c.jsxs("div",{className:"absolute top-3 right-3 w-52 flex flex-col gap-2 pointer-events-none",children:[c.jsxs("div",{className:"relative pointer-events-auto",children:[c.jsx(fl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),c.jsx("input",{className:"nb-input pl-9 w-full text-sm",placeholder:n("graph.viz.search"),value:a,onChange:N=>l(N.target.value),"aria-label":n("graph.viz.search")})]}),c.jsxs("div",{className:"nb-card p-3 flex flex-col gap-1.5 pointer-events-auto bg-[var(--color-bg)]",children:[m.map(N=>c.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs",children:[c.jsx("span",{className:"text-[var(--color-text-subtle)] shrink-0",children:N.label}),c.jsx("span",{className:"font-bold font-[family-name:var(--font-mono)] text-right",children:N.value})]},N.label)),c.jsx("div",{className:"mt-1 pt-1.5 border-t-[1.5px] border-dashed border-[var(--color-border-light)] flex flex-wrap gap-x-2 gap-y-1",children:g.map(N=>c.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-[family-name:var(--font-mono)]",children:[c.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full border-[1.5px] border-[var(--color-text)]",style:{background:Cf(N)}}),N]},N))})]}),c.jsx("p",{className:"text-[10px] text-[var(--color-text-subtle)] text-right leading-tight pointer-events-none",children:n("graph.viz.hint")})]})]})}function l4({name:e}){var m,y;const t=Be(),n=Gt(),i=Ye({queryKey:["graph-status",e],queryFn:()=>Zz(e)}),a=()=>{n.invalidateQueries({queryKey:["graph-status",e]}),n.invalidateQueries({queryKey:["graph-data",e]})},l=Ct({mutationFn:()=>e4(e),onSuccess:a}),o=Ct({mutationFn:()=>t4(e),onSuccess:a}),d=((m=i.data)==null?void 0:m.data)??null,f=l.isPending,h=o.isPending,g=f||h;return c.jsxs("div",{className:"flex flex-col gap-3 max-w-full flex-1 min-h-0",children:[c.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.jsx(WN,{size:20,strokeWidth:2.5,className:"shrink-0"}),c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold shrink-0",children:t("graph.title")}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)] truncate hidden sm:inline",children:t("graph.desc")})]}),c.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[d&&c.jsxs("button",{className:"nb-btn shrink-0",onClick:()=>o.mutate(),disabled:g,type:"button",title:t("graph.sync.desc"),children:[h?c.jsx(Xe,{size:14,strokeWidth:2.5,className:"animate-spin"}):c.jsx(mL,{size:14,strokeWidth:2.5}),t(h?"graph.syncing":"graph.sync")]}),c.jsxs("button",{className:"nb-btn nb-btn-mint shrink-0",onClick:()=>l.mutate(),disabled:g,type:"button",children:[f?c.jsx(Xe,{size:14,strokeWidth:2.5,className:"animate-spin"}):d?c.jsx(ya,{size:14,strokeWidth:2.5}):c.jsx(xL,{size:14,strokeWidth:2.5}),t(f?"graph.building":d?"graph.rebuild":"graph.build")]})]})]}),(l.isError||o.isError)&&c.jsxs("div",{className:"nb-card bg-[var(--color-crashed-bg)] text-sm shrink-0",children:[t("graph.buildFailed"),": ",((y=l.error||o.error)==null?void 0:y.message)??""]}),i.isLoading?c.jsxs("div",{className:"nb-card flex items-center gap-2 text-sm text-[var(--color-text-muted)]",children:[c.jsx(Xe,{size:14,className:"animate-spin"})," ",t("graph.viz.loading")]}):d?c.jsx(s4,{name:e,status:d}):c.jsx("div",{className:"nb-card text-sm text-[var(--color-text-muted)]",children:t("graph.empty")})]})}const _k=["overview","config","pipelines","skills","rules","graph","logs"];function o4({name:e,embedded:t}={}){var v;const n=Be(),{name:i=""}=Db(),a=e??i,l=ks(),[o]=UN(),[d,f]=Gb("projectDetail.tab","overview"),h=_k.includes(d)?d:"overview",[g,m]=j.useState(!1),y=o.get("tab"),b=o.get("worker")??void 0;j.useEffect(()=>{if(y==="danger"){m(!0);return}y&&_k.includes(y)&&f(y)},[y]);const k=Ye({queryKey:["project",a],queryFn:()=>Z3(a),enabled:!!a});return c.jsxs("div",{className:"flex flex-col gap-4 w-full flex-1 min-h-0",children:[c.jsxs("header",{className:"flex items-center gap-3 shrink-0",children:[!t&&c.jsxs("button",{type:"button",onClick:()=>l("/projects"),className:"nb-btn",style:{padding:"6px 12px"},"aria-label":n("newProject.back.aria"),children:[c.jsx(qN,{size:14,strokeWidth:3}),n("newProject.back")]}),c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-3xl font-bold flex-1 truncate",children:a})]}),c.jsxs("nav",{className:"flex items-center gap-2 flex-wrap shrink-0",children:[c.jsx(ts,{current:h,value:"overview",onSelect:f,icon:aL,children:n("projectDetail.tab.overview")}),c.jsx(ts,{current:h,value:"config",onSelect:f,icon:JN,children:n("projectDetail.tab.config")}),c.jsx(ts,{current:h,value:"pipelines",onSelect:f,icon:Fb,children:n("projectDetail.tab.pipelines")}),c.jsx(ts,{current:h,value:"skills",onSelect:f,icon:e_,children:n("projectDetail.tab.skills")}),c.jsx(ts,{current:h,value:"rules",onSelect:f,icon:RR,children:n("projectDetail.tab.rules")}),c.jsx(ts,{current:h,value:"graph",onSelect:f,icon:WN,children:n("projectDetail.tab.graph")}),c.jsx(ts,{current:h,value:"logs",onSelect:f,icon:$b,children:n("projectDetail.tab.logs")}),c.jsx(ts,{current:h,value:"danger",onSelect:()=>m(!0),icon:fr,children:n("projectDetail.tab.danger")}),c.jsx(vs,{to:`/board?project=${encodeURIComponent(a)}`,className:"nb-btn nb-btn-mint ml-auto",children:n("projectDetail.openBoard")})]}),c.jsxs("div",{className:["flex-1 min-h-0 pr-1 flex flex-col",h==="logs"?"overflow-hidden":"overflow-y-auto"].join(" "),children:[h==="overview"&&c.jsx(c4,{name:a,data:k.data,loading:k.isLoading}),h==="config"&&c.jsx(u4,{name:a}),h==="pipelines"&&c.jsx(d4,{name:a}),h==="skills"&&c.jsx(Wz,{name:a}),h==="rules"&&c.jsx(Xz,{name:a}),h==="graph"&&c.jsx(l4,{name:a}),h==="logs"&&c.jsx(vI,{project:a,initialWorker:h==="logs"?b:void 0})]}),g&&c.jsx(f4,{name:a,repoDir:((v=k.data)==null?void 0:v.repoDir)??null,onClose:()=>m(!1)})]})}function ts({current:e,value:t,onSelect:n,icon:i,children:a}){const l=e===t;return c.jsxs("button",{type:"button",onClick:()=>n(t),"aria-current":l?"page":void 0,className:["nb-btn",l?"nb-btn-primary":""].join(" "),style:{padding:"6px 14px",fontSize:13},children:[c.jsx(i,{size:13,strokeWidth:2.5}),a]})}function c4({name:e,data:t,loading:n}){const i=Be();return n?c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:i("common.loading")})}):t?c.jsx("div",{className:"nb-card",children:c.jsxs("dl",{className:"grid grid-cols-[160px_1fr] gap-y-3 text-sm",children:[c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.repoDir")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.repoDir??"—"}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.pmBackend")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.pmBackend}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.agent")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.agentProvider}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.cards")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:i("projectDetail.overview.cards.value",{total:t.cards.total,inprogress:t.cards.inprogress,done:t.cards.done})}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.workers")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:i("projectDetail.overview.workers.value",{total:t.workers.total,active:t.workers.active})}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.pipeline")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.pipelineStatus}),c.jsx("dt",{className:"font-bold",children:i("projectDetail.overview.lastActivity")}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.lastActivityAt?new Date(t.lastActivityAt).toLocaleString():"—"})]})}):c.jsx("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:c.jsx("p",{children:i("projectDetail.overview.notFound",{name:e})})})}function u4({name:e}){const t=Be(),n=Gt(),{alert:i}=un(),{data:a,isLoading:l,isError:o,error:d,refetch:f}=Ye({queryKey:["project-conf",e],queryFn:()=>eI(e)}),[h,g]=j.useState(null),[m,y]=j.useState(null);j.useEffect(()=>{a&&h===null&&(g(a.content),y(a.etag))},[a,h]);const b=h!==null&&a!==void 0&&h!==a.content,k=Ct({mutationFn:()=>{if(h===null||m===null)throw new Error("no draft");return tI(e,h,m)},onSuccess:v=>{y(v.etag),n.invalidateQueries({queryKey:["project-conf",e]}),n.invalidateQueries({queryKey:["project",e]})},onError:v=>{const N=v.status;i({title:t(N===409?"projectDetail.config.error.conflict.title":"projectDetail.config.error.save.title"),body:N===409?t("projectDetail.config.error.conflict.body"):v instanceof Error?v.message:String(v)})}});return l?c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:t("common.loading")})}):o?c.jsx("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:c.jsx("p",{children:t("projectDetail.config.error.load",{detail:d instanceof Error?d.message:String(d)})})}):c.jsxs("div",{className:"nb-card",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsxs("div",{children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold",children:c.jsxs("code",{className:"font-[family-name:var(--font-mono)] text-sm border-2 border-[var(--color-text)] px-2 py-0.5 rounded",children:["~/.coral/projects/",e,"/conf"]})}),m&&c.jsxs("p",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] mt-1",children:["etag: ",m]})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",className:"nb-btn",style:{padding:"6px 12px"},onClick:()=>{g(null),f()},disabled:k.isPending,"aria-label":t("projectDetail.config.reload"),children:[c.jsx(ya,{size:13,strokeWidth:2.5}),t("projectDetail.config.reload")]}),c.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",style:{padding:"6px 12px"},onClick:()=>k.mutate(),disabled:!b||k.isPending,"aria-label":t("projectDetail.config.saveAria"),children:[k.isPending?c.jsx(Xe,{size:13,strokeWidth:3,className:"animate-spin"}):k.isSuccess&&!b?c.jsx(PR,{size:13,strokeWidth:3}):c.jsx(Rr,{size:13,strokeWidth:3}),t("projectDetail.config.save")]})]})]}),c.jsx("textarea",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",style:{minHeight:480,resize:"vertical"},value:h??"",onChange:v=>g(v.target.value),spellCheck:!1,"aria-label":t("projectDetail.config.editorAria")}),b&&c.jsx("p",{className:"text-xs text-[var(--color-stuck)] mt-2 font-bold",children:t("projectDetail.config.confDirty")})]})}function d4({name:e}){const t=Be(),n=Gt(),{confirm:i,alert:a}=un(),{data:l,isLoading:o}=Ye({queryKey:["project-pipelines",e],queryFn:()=>iI(e)}),[d,f]=j.useState(null),[h,g]=j.useState(!1),m=Ct({mutationFn:v=>rI(e,v),onSuccess:()=>n.invalidateQueries({queryKey:["project-pipelines",e]}),onError:v=>{a({title:t("projectDetail.pipelines.switch.error"),body:v instanceof Error?v.message:String(v)})}}),y=Ct({mutationFn:v=>oI(e,v),onSuccess:()=>n.invalidateQueries({queryKey:["project-pipelines",e]}),onError:v=>{a({title:t("projectDetail.pipelines.delete.error"),body:v instanceof Error?v.message:String(v)})}}),b=Ct({mutationFn:v=>lI(e,v.name,v.template),onSuccess:v=>{n.invalidateQueries({queryKey:["project-pipelines",e]}),g(!1),f(v.name)},onError:v=>{a({title:t("projectDetail.pipelines.create.error"),body:v instanceof Error?v.message:String(v)})}});if(o)return c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:t("common.loading")})});const k=[];l!=null&&l.active&&k.push({name:l.active,isActive:!0});for(const v of(l==null?void 0:l.available)??[])k.push({name:v.name,isActive:!1});return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"nb-card",children:[c.jsxs("div",{className:"flex items-center justify-between mb-3",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-lg font-bold",children:t("projectDetail.pipelines.title")}),c.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",style:{padding:"6px 12px",fontSize:12},onClick:()=>g(!0),disabled:b.isPending,"aria-label":t("projectDetail.pipelines.add"),children:[c.jsx(pi,{size:12,strokeWidth:3}),t("projectDetail.pipelines.add")]})]}),k.length===0?c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] italic p-4 border-2 border-dashed border-[var(--color-text)] rounded-lg text-center",children:t("projectDetail.pipelines.empty")}):c.jsx("ul",{className:"flex flex-col gap-2",children:k.map(v=>c.jsxs("li",{className:"flex bg-surface-input items-center gap-3 p-3 bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg",children:[c.jsx(Fb,{size:16,strokeWidth:2.5}),c.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold flex-1",children:v.name}),v.isActive&&c.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)"},children:t("projectDetail.pipelines.activeBadge")}),c.jsxs("div",{className:"flex gap-1",children:[c.jsxs("button",{type:"button",className:"nb-btn",style:{padding:"4px 10px",fontSize:11},onClick:()=>f(v.name),"aria-label":t("projectDetail.pipelines.editAria",{name:v.name}),children:[c.jsx(qh,{size:11,strokeWidth:2.5}),t("projectDetail.pipelines.edit")]}),!v.isActive&&c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:"nb-btn nb-btn-primary",style:{padding:"4px 10px",fontSize:11},onClick:async()=>{await i({title:t("projectDetail.pipelines.switch.confirm.title",{name:v.name}),body:t("projectDetail.pipelines.switch.confirm.body",{name:v.name}),confirm:t("projectDetail.pipelines.switch.confirm.button")})&&m.mutate(v.name)},disabled:m.isPending,"aria-label":t("projectDetail.pipelines.switchAria",{name:v.name}),children:t("projectDetail.pipelines.switch")}),c.jsx("button",{type:"button",className:"nb-btn nb-btn-danger",style:{padding:"4px 10px",fontSize:11},onClick:async()=>{await i({title:t("projectDetail.pipelines.delete.confirm.title",{name:v.name}),body:t("projectDetail.pipelines.delete.confirm.body"),confirm:t("common.delete"),danger:!0})&&y.mutate(v.name)},disabled:y.isPending,"aria-label":t("projectDetail.pipelines.deleteAria",{name:v.name}),children:c.jsx(fr,{size:11,strokeWidth:2.5})})]})]})]},v.name))})]}),d&&c.jsx(Lz,{projectName:e,file:d,onClose:()=>f(null),onSaved:()=>{n.invalidateQueries({queryKey:["project-pipelines",e]})}}),h&&c.jsx(Pz,{hasActive:!!(l!=null&&l.active),hasSample:!0,isPending:b.isPending,onCancel:()=>g(!1),onCreate:(v,N)=>b.mutate({name:v,template:N})})]})}function f4({name:e,repoDir:t,onClose:n}){const i=Be(),a=ks(),l=Gt(),{alert:o}=un(),[d,f]=j.useState(""),[h,g]=j.useState(!0),m=Ct({mutationFn:()=>nI(e,{includeClaudeDir:h}),onSuccess:N=>{l.invalidateQueries({queryKey:["projects"]});const E=N.claudeRemoved.filter(C=>C.ok).map(C=>C.path);n(),o({title:i("projectDetail.danger.deleted.title"),body:E.length>0?i("projectDetail.danger.deleted.bodyWithList",{paths:E.join(`
|
|
612
612
|
`)}):i("projectDetail.danger.deleted.body")}).then(()=>a("/projects"))},onError:N=>{o({title:i("projectDetail.danger.error"),body:N instanceof Error?N.message:String(N)})}});j.useEffect(()=>{const N=E=>{E.key==="Escape"&&n()};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[n]);const b=i("projectDetail.danger.body",{path:"__PATH__"}).split("__PATH__"),v=i("projectDetail.danger.confirmPrompt",{name:"__NAME__"}).split("__NAME__");return c.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"danger-dialog-title",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4 overflow-hidden",children:c.jsxs("div",{className:"nb-card w-full max-w-xl max-h-[calc(100vh-2rem)] overflow-y-auto bg-[var(--color-crashed-bg)]",children:[c.jsxs("header",{className:"flex items-center justify-between gap-3 mb-3",children:[c.jsx("h2",{id:"danger-dialog-title",className:"font-[family-name:var(--font-heading)] text-lg font-bold text-[var(--color-crashed)]",children:i("projectDetail.danger.title")}),c.jsx("button",{type:"button",className:"nb-btn nb-btn-mint p-2",onClick:n,"aria-label":i("common.close"),disabled:m.isPending,children:c.jsx(bn,{size:14,strokeWidth:3})})]}),c.jsxs("p",{className:"text-sm mb-4",children:[b[0],c.jsxs("code",{className:"font-[family-name:var(--font-mono)] bg-[var(--color-bg)] border-2 border-[var(--color-text)] px-1.5 py-0.5 rounded",children:["~/.coral/projects/",e,"/"]}),b[1]]}),t&&c.jsxs("label",{className:"flex items-start gap-2 mb-4 p-3 bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded-lg cursor-pointer",children:[c.jsx("input",{type:"checkbox",checked:h,onChange:N=>g(N.target.checked),className:"mt-0.5",disabled:m.isPending}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("div",{className:"text-sm font-bold",children:i("projectDetail.danger.includeClaude.label")}),c.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] break-all",children:[t,"/.claude/"]}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-1",children:i("projectDetail.danger.includeClaude.note")})]})]}),c.jsx("div",{className:"mb-4",children:c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsxs("span",{className:"text-sm font-bold",children:[v[0],c.jsx("code",{className:"font-[family-name:var(--font-mono)] text-xs",children:e}),v[1]]}),c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",value:d,onChange:N=>f(N.target.value),placeholder:e,disabled:m.isPending})]})}),c.jsxs("div",{className:"flex gap-2 justify-end pt-3 border-t-2 border-dashed border-[var(--color-text)]",children:[c.jsx("button",{type:"button",className:"nb-btn",onClick:n,disabled:m.isPending,children:i("common.cancel")}),c.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",disabled:d!==e||m.isPending,onClick:()=>m.mutate(),"aria-label":i("projectDetail.danger.deleteAria"),children:[m.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(fr,{size:14,strokeWidth:3}),i("projectDetail.danger.deleteButton")]})]})]})})}function cx(){return ft("/api/providers")}function h2(e){const t=[];for(const n of e)for(const i of n.models)t.push({providerId:n.id,model:i,label:`${i} · ${n.name}`});return t}async function h4(e,t){const n=await fetch("/api/providers",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:e,entry:t})});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}async function p4(e,t){const n=await fetch(`/api/providers/${e}/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}function p2(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return ft(`/api/fs/browse${t}`)}async function m4(e,t){const n=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:t})});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}return await n.json()}const m2=50*1024*1024;async function g4(e,t){if(t.size>m2)throw new Error(`文件超过 50 MB 上限(当前 ${(t.size/1024/1024).toFixed(2)} MB)`);const n=new FormData;n.append("sessionId",e),n.append("file",t,t.name);const i=await fetch("/api/fs/upload",{method:"POST",body:n});if(!i.ok){const a=await i.text();throw new Error(`${i.status}: ${a}`)}return await i.json()}function Qy(e,t){return`/api/fs/file?${new URLSearchParams({path:t,sessionId:e}).toString()}`}function ux({initialPath:e,onCancel:t,onSelect:n,title:i,mode:a="directory"}){var C,S,_;const l=Be(),{prompt:o,alert:d}=un(),f=i??l("dirPicker.title.default"),[h,g]=j.useState(e??null),[m,y]=j.useState(null),b=Ye({queryKey:["fs-browse",h],queryFn:()=>p2(h??void 0),staleTime:0,gcTime:0}),k=((C=b.data)==null?void 0:C.path)??h??"",v=((S=b.data)==null?void 0:S.parent)??null,N=((_=b.data)==null?void 0:_.home)??null,E=async()=>{var T;if(!k)return;const M=(T=await o({title:l("dirPicker.newDir"),body:l("dirPicker.newDir.prompt"),placeholder:l("dirPicker.newDir.placeholder"),confirm:l("dirPicker.newDir.create")}))==null?void 0:T.trim();if(M)try{const R=await m4(k,M);g(R.path)}catch(R){d({title:l("dirPicker.newDir.error.title"),body:R instanceof Error?R.message:String(R)})}};return j.useEffect(()=>{const M=T=>{T.key==="Escape"&&(T.preventDefault(),t())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]),c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.5)] p-4",role:"presentation",children:c.jsxs("div",{className:"nb-card bg-[var(--color-bg)] max-w-lg w-full p-5 flex flex-col",style:{maxHeight:"70vh"},role:"dialog","aria-modal":"true","aria-label":f,children:[c.jsxs("header",{className:"flex items-center justify-between mb-3 shrink-0",children:[c.jsx("div",{className:"flex items-center gap-2 min-w-0",children:c.jsx("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base truncate",children:f})}),c.jsx("button",{type:"button",className:"p-1 hover:bg-[var(--color-bg-cream)] rounded",onClick:t,"aria-label":l("dirPicker.close.aria"),children:c.jsx(bn,{size:14,strokeWidth:3})})]}),c.jsxs("div",{className:"flex items-center gap-2 mb-3 shrink-0",children:[c.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>v&&g(v),disabled:!v||b.isLoading,"aria-label":l("dirPicker.up.aria"),title:l("dirPicker.up.title"),children:c.jsx(HN,{size:12,strokeWidth:3})}),c.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>N&&g(N),disabled:!N||b.isLoading,"aria-label":l("dirPicker.home.aria"),title:l("dirPicker.home.title"),children:c.jsx(EL,{size:12,strokeWidth:3})}),c.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>void E(),disabled:!k||b.isLoading||b.isError,"aria-label":l("dirPicker.newDir.aria"),title:l("dirPicker.newDir.aria"),children:c.jsx(oL,{size:12,strokeWidth:3})}),c.jsx("div",{className:"flex-1 min-w-0 nb-input font-[family-name:var(--font-mono)] text-xs px-2 py-1.5 truncate",title:k,dir:"rtl",children:k||"..."})]}),c.jsx("div",{className:"scroll-frame flex-1 border-2 border-[var(--color-text)] rounded-lg bg-[var(--color-bg-cream)] min-h-0",children:c.jsxs("div",{className:"scroll-frame-body h-full",children:[b.isLoading&&c.jsxs("div",{className:"flex items-center justify-center py-12 text-[var(--color-text-muted)]",children:[c.jsx(Xe,{size:16,strokeWidth:3,className:"animate-spin mr-2"}),l("dirPicker.loading")]}),b.isError&&c.jsxs("div",{className:"p-4 text-sm text-[var(--color-crashed)]",children:[c.jsx("p",{className:"font-bold mb-1",children:l("dirPicker.error.title")}),c.jsx("p",{className:"text-xs font-[family-name:var(--font-mono)] break-all",children:b.error instanceof Error?b.error.message:String(b.error)})]}),b.data&&c.jsxs("ul",{className:"divide-y-2 divide-[var(--color-text)]/20",children:[b.data.entries.length===0&&c.jsx("li",{className:"p-4 text-xs text-[var(--color-text-subtle)] italic text-center",children:l("dirPicker.empty")}),b.data.entries.map(M=>{const T=(()=>{const $=k.endsWith("/")||k.endsWith("\\")?"":"/";return`${k}${$}${M.name}`})(),R=a==="file"&&m===T,O=M.isDirectory||a==="file";return c.jsx("li",{children:c.jsxs("button",{type:"button",className:["w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-[family-name:var(--font-mono)]","disabled:opacity-50 disabled:cursor-not-allowed",R?"bg-[var(--color-accent-mint)] font-bold":"hover:bg-[var(--color-accent-mint)]"].join(" "),disabled:!O,onClick:()=>{M.isDirectory?(y(null),g(T)):a==="file"&&y(T)},onDoubleClick:()=>{a==="file"&&!M.isDirectory&&n(T)},title:M.isDirectory?l("dirPicker.enter.aria",{name:M.name}):a==="file"?l("dirPicker.pickFile.aria",{name:M.name}):l("dirPicker.fileLocked"),children:[M.isDirectory?c.jsx(ph,{size:14,strokeWidth:2.5,className:"flex-shrink-0 text-[var(--color-text)]"}):c.jsx("span",{className:"w-3.5 h-3.5 flex-shrink-0"}),c.jsx("span",{className:"truncate",children:M.name}),M.isDirectory&&c.jsx(Zo,{size:12,strokeWidth:2.5,className:"ml-auto flex-shrink-0 text-[var(--color-text-muted)]"})]})},M.name)})]})]})}),c.jsxs("div",{className:"flex gap-2 justify-end pt-3 shrink-0",children:[c.jsx("button",{type:"button",className:"nb-btn",onClick:t,children:l("dirPicker.cancel")}),a==="file"?c.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>m&&n(m),disabled:!m||b.isLoading||b.isError,title:m??l("dirPicker.useFile.tooltip.empty"),children:[c.jsx(Eu,{size:14,strokeWidth:3}),l("dirPicker.useFile")]}):c.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>n(k),disabled:!k||b.isLoading||b.isError,children:[c.jsx(Eu,{size:14,strokeWidth:3}),l("dirPicker.useDir")]})]})]})})}function Af(e){return(e.replace(/\/+$/,"").split("/").pop()??"").replace(/[^a-zA-Z0-9_-]/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}function g2({onCancel:e,onCreated:t,dialogMode:n=!1}={}){var q,F,Y,D,K,P;const i=Be(),a=ks(),l=Gt(),{alert:o}=un(),d=e??(()=>a("/projects")),[f,h]=j.useState({name:"",projectDir:"",enableGit:!0,createIfMissing:!0,mergeBranch:"main",maxWorkers:"1",ackTimeoutMin:"5",pipelineMode:"pipeline"}),g=f.pipelineMode==="smartArrange",m=Ye({queryKey:["system-agents"],queryFn:Kb}),y=((q=m.data)==null?void 0:q.agents.worker.model)??"",b=((F=m.data)==null?void 0:F.agents.reviewer.model)??"",k=[...new Set((((Y=m.data)==null?void 0:Y.providers.openai)??[]).flatMap(H=>H.models))],v=Ye({queryKey:["providers"],queryFn:cx}),N=h2(((D=v.data)==null?void 0:D.anthropic)??[]),E=f.workerModel?`${f.workerProviderId??""}::${f.workerModel}`:"",[C,S]=j.useState(!1),_=Ct({mutationFn:H=>J3(H),onSuccess:H=>{l.invalidateQueries({queryKey:["projects"]}),t?t(H.name):a(`/projects/${encodeURIComponent(H.name)}`)},onError:H=>{o({title:i("newProject.error.create.title"),body:H instanceof Error?H.message:String(H)})}}),M=/^[a-zA-Z0-9_-]+$/.test(f.name),T=M&&f.projectDir.trim()!==""&&!_.isPending,R=f.projectDir.trim(),O=Ye({queryKey:["fs-browse-probe",R],queryFn:()=>p2(R),enabled:R.startsWith("/"),staleTime:0,gcTime:0,retry:!1}),$=O.isSuccess&&(((K=O.data)==null?void 0:K.entries.length)??0)>0,I=O.isError||O.isSuccess&&(((P=O.data)==null?void 0:P.entries.length)??0)===0;return c.jsxs("div",{className:n?"w-full h-full min-h-0":"w-full",children:[c.jsxs("div",{className:n?"nb-card flex h-full min-h-0 flex-col overflow-hidden":"nb-card flex flex-col gap-4",children:[c.jsxs("header",{className:n?"flex shrink-0 items-center gap-3 border-b-2 border-dashed border-[var(--color-text)] pb-4":"flex items-center gap-3",children:[c.jsxs("button",{type:"button",onClick:d,className:"nb-btn",style:{padding:"6px 12px"},"aria-label":i("newProject.back.aria"),children:[c.jsx(qN,{size:14,strokeWidth:3}),i("newProject.back")]}),c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:i("newProject.title")})]}),c.jsxs("form",{onSubmit:H=>{H.preventDefault(),T&&_.mutate(f)},className:n?"flex min-h-0 flex-1 flex-col":"flex flex-col gap-4",children:[c.jsxs("div",{className:["grid grid-cols-1 md:grid-cols-2 gap-x-6 gap-y-4",n?"min-h-0 flex-1 overflow-y-auto overscroll-contain pr-3 pt-4":""].join(" "),children:[c.jsx(Ui,{className:"md:col-span-2",label:i("newProject.field.mode"),hint:i(g?"newProject.field.mode.smartHint":"newProject.field.mode.pipelineHint"),children:c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:["pipeline","smartArrange"].map(H=>{const Q=f.pipelineMode===H;return c.jsxs("button",{type:"button",onClick:()=>h({...f,pipelineMode:H}),"aria-pressed":Q,className:["text-left rounded-xl border-2 p-3 transition-all",Q?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[3px_3px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:[c.jsx("div",{className:"text-sm font-bold",children:i(H==="pipeline"?"newProject.field.mode.pipeline":"newProject.field.mode.smart")}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:i(H==="pipeline"?"newProject.field.mode.pipelineDesc":"newProject.field.mode.smartDesc")})]},H)})})}),g&&c.jsx(Ui,{className:"md:col-span-2",label:i("newProject.field.goal"),hint:i("newProject.field.goal.hint"),children:c.jsx("textarea",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-sm",style:{minHeight:110,resize:"vertical"},placeholder:i("newProject.field.goal.placeholder"),value:f.goal??"",onChange:H=>h({...f,goal:H.target.value})})}),c.jsx(Ui,{label:"Worker 模型",hint:`默认:${y||"全局默认"}(留空用默认)`,children:c.jsxs("select",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:E,onChange:H=>{const Q=H.target.value;if(!Q)return h({...f,workerModel:void 0,workerProviderId:void 0});const[G,L]=Q.split("::");h({...f,workerModel:L,workerProviderId:G||void 0})},children:[c.jsx("option",{value:"",children:"用全局默认模型"}),N.map(H=>c.jsx("option",{value:`${H.providerId}::${H.model}`,children:H.label},`${H.providerId}::${H.model}`))]})}),g&&c.jsxs(Ui,{label:"OpenAI Agent(监工)模型",hint:`默认:${b||"全局默认"}(留空用默认)`,children:[c.jsx("input",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",value:f.reviewerModel??"",onChange:H=>h({...f,reviewerModel:H.target.value}),placeholder:b,list:"np-reviewer-models",spellCheck:!1}),c.jsx("datalist",{id:"np-reviewer-models",children:k.map(H=>c.jsx("option",{value:H},H))})]}),c.jsxs(Ui,{label:i("newProject.field.name"),hint:i("newProject.field.name.derived"),children:[c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",placeholder:i("newProject.field.name.placeholder"),value:f.name,onChange:H=>h({...f,name:H.target.value}),required:!0}),f.name&&!M&&c.jsx("p",{className:"text-xs text-[var(--color-crashed)] mt-1",children:i("newProject.field.name.invalid")})]}),c.jsxs(Ui,{className:"md:col-span-2",label:i("newProject.field.dir"),hint:i("newProject.field.dir.long"),children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",className:"nb-input flex-1 font-[family-name:var(--font-mono)]",placeholder:i("newProject.field.dir.placeholder"),value:f.projectDir,onChange:H=>{const Q=H.target.value,G=Af(Q),L=Af(f.projectDir),z=f.name&&f.name!==L;h({...f,projectDir:Q,name:z?f.name:G})},required:!0}),c.jsxs("button",{type:"button",className:"nb-btn flex-shrink-0",onClick:()=>S(!0),"aria-label":i("newProject.dir.browseAria"),title:i("newProject.dir.browseAria"),children:[c.jsx(VN,{size:14,strokeWidth:2.5}),i("newProject.dir.browse")]})]}),$&&c.jsx("p",{className:"text-xs mt-1.5 font-bold text-[var(--color-text)]",children:i("newProject.field.dir.adopt")}),I&&R.startsWith("/")&&c.jsx("p",{className:"text-xs mt-1.5 text-[var(--color-text-muted)]",children:i("newProject.field.dir.fresh")}),c.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:f.createIfMissing!==!1,onChange:H=>h({...f,createIfMissing:H.target.checked}),className:"w-4 h-4 cursor-pointer"}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:i("newProject.field.dir.createIfMissing")})]})]}),c.jsx(Ui,{label:i("newProject.field.maxWorkers.short"),children:c.jsx("input",{type:"number",min:"1",max:"8",className:"nb-input w-full font-[family-name:var(--font-mono)]",value:f.maxWorkers,onChange:H=>h({...f,maxWorkers:H.target.value})})}),c.jsx(Ui,{label:i("newProject.field.ackTimeout.minutes"),hint:i("newProject.field.ackTimeout.minutes.help"),children:c.jsx("input",{type:"number",min:"1",max:"30",className:"nb-input w-full font-[family-name:var(--font-mono)]",value:f.ackTimeoutMin??"5",onChange:H=>h({...f,ackTimeoutMin:H.target.value})})}),c.jsxs("div",{className:"md:col-span-2 pt-3 border-t-2 border-[var(--color-text)] border-dashed",children:[c.jsxs("label",{className:"flex items-center gap-3 mb-2 cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:f.enableReview??!1,onChange:H=>h({...f,enableReview:H.target.checked}),className:"w-4 h-4 cursor-pointer"}),c.jsx("span",{className:"text-sm font-bold",children:i("newProject.field.review.label")})]}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:i("newProject.field.review.detail")})]}),c.jsxs("div",{className:"md:col-span-2 pt-3 border-t-2 border-[var(--color-text)] border-dashed",children:[c.jsxs("label",{className:"flex items-center gap-3 mb-3 cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:f.enableGit??!0,onChange:H=>h({...f,enableGit:H.target.checked}),className:"w-4 h-4 cursor-pointer"}),c.jsx("span",{className:"text-sm font-bold",children:i("newProject.field.git.label")})]}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] mb-3",children:i("newProject.field.git.detail")}),f.enableGit!==!1&&c.jsxs("div",{className:"flex flex-col gap-4 bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg p-4",children:[c.jsx(Ui,{label:i("newProject.field.git.branch"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",value:f.mergeBranch??"main",onChange:H=>h({...f,mergeBranch:H.target.value})})}),c.jsx(Ui,{label:i("newProject.field.gitlabProject.label"),hint:i("newProject.field.gitlabProject.help2"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",placeholder:i("newProject.field.gitlabProject.placeholder"),value:f.gitlabProject??"",onChange:H=>h({...f,gitlabProject:H.target.value})})}),f.gitlabProject&&c.jsx(Ui,{label:i("newProject.field.gitlabProjectId"),hint:i("newProject.field.gitlabProjectId.help"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",placeholder:i("newProject.field.gitlabProjectId.placeholder"),value:f.gitlabProjectId??"",onChange:H=>h({...f,gitlabProjectId:H.target.value})})})]})]}),c.jsxs("div",{className:"md:col-span-2 pt-3 border-t-2 border-[var(--color-text)] border-dashed",children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-3 text-[var(--color-text-muted)]",children:i("newProject.section.notifications")}),c.jsx(Ui,{label:i("newProject.field.matrixRoom.label"),hint:i("newProject.field.matrixRoom.help2"),children:c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-mono)]",placeholder:i("newProject.field.matrixRoom.placeholder"),value:f.matrixRoomId??"",onChange:H=>h({...f,matrixRoomId:H.target.value})})})]})]}),c.jsxs("div",{className:n?"flex shrink-0 gap-3 justify-end border-t-2 border-dashed border-[var(--color-text)] pt-4 mt-4":"flex gap-3 justify-end pt-3",children:[c.jsx("button",{type:"button",className:"nb-btn",onClick:d,disabled:_.isPending,children:i("common.cancel")}),c.jsx("button",{type:"submit",className:"nb-btn nb-btn-primary",disabled:!T,"aria-label":i("newProject.submit"),children:_.isPending?c.jsxs(c.Fragment,{children:[c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}),i("newProject.creating")]}):c.jsxs(c.Fragment,{children:[c.jsx(pi,{size:14,strokeWidth:3}),i("common.create")]})})]})]})]}),C&&c.jsx(ux,{title:i("newProject.field.dir.pickerTitle"),initialPath:f.projectDir.trim()||void 0,onCancel:()=>S(!1),onSelect:H=>{const Q=Af(H),G=Af(f.projectDir),L=f.name&&f.name!==G;h({...f,projectDir:H,name:L?f.name:Q}),S(!1)}})]})}function Ui({label:e,hint:t,children:n,className:i}){return c.jsxs("label",{className:`flex flex-col gap-1.5 ${i??""}`,children:[c.jsx("span",{className:"text-sm font-bold",children:e}),n,t&&c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:t})]})}function y4({onClose:e,onCreated:t}){return c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30 p-4 overflow-hidden",children:c.jsx("div",{className:"w-full max-w-6xl h-[calc(100vh-2rem)] min-h-0",children:c.jsx(g2,{dialogMode:!0,onCancel:e,onCreated:n=>{e(),t(n)}})})})}const jk="projects.last",b4=["activity","date","name"];function Ck(){const e=Be(),t=ks(),{name:n}=Db(),[i,a]=Gb("projects.sort","activity"),[l,o]=j.useState(!1),[d,f]=j.useState(!1),{data:h,isLoading:g,isError:m,error:y,refetch:b}=Ye({queryKey:["projects"],queryFn:Es}),k=M=>t(`/projects/${encodeURIComponent(M)}`),v=h?h_(h.data,i):[],N=i!=="name",{recent:E,older:C}=N?mI(v,M=>M.lastActivityAt):{recent:v,older:[]},S=l?C:C.filter(M=>M.name===n),_=C.length-S.length;return j.useEffect(()=>{if(n)try{localStorage.setItem(jk,n)}catch{}},[n]),j.useEffect(()=>{if(n||!h)return;let M=null;try{M=localStorage.getItem(jk)}catch{}M&&h.data.some(T=>T.name===M)&&t(`/projects/${encodeURIComponent(M)}`,{replace:!0})},[n,h,t]),c.jsxs("div",{className:"flex flex-col flex-1 min-h-0 w-full",children:[m?c.jsxs("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e("projects.load.failed")}),c.jsx("p",{className:"text-sm text-[var(--color-text)]",children:y instanceof Error?y.message:String(y)}),c.jsx("button",{className:"nb-btn mt-4",onClick:()=>b(),type:"button",children:e("common.retry")})]}):h&&h.data.length===0?c.jsx(k4,{onNew:()=>f(!0)}):c.jsxs("div",{className:"flex gap-5 flex-1 min-h-0",children:[c.jsxs("aside",{className:"w-80 shrink-0 flex flex-col min-h-0",children:[c.jsxs("div",{className:"shrink-0 flex flex-col gap-2 pb-3",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold truncate",children:e("projects.title")}),c.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:h?e("projects.count",{count:h.data.length}):e("common.loading")})]}),c.jsxs("button",{className:"nb-btn nb-btn-primary shrink-0",type:"button",onClick:()=>f(!0),"aria-label":e("projects.new"),children:[c.jsx(pi,{size:16,strokeWidth:3}),e("projects.new")]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"inline-flex flex-1 rounded-full overflow-hidden bg-color-bg-soft",role:"group","aria-label":e("projects.sort.label"),children:b4.map(M=>c.jsx("button",{type:"button","aria-pressed":i===M,onClick:()=>a(M),className:["flex-1 px-2 py-1.5 text-xs font-bold font-[family-name:var(--font-mono)] focus-visible:outline focus-visible:outline-2",i===M?"bg-surface-input text-[var(--color-text)]":"bg-transparent text-[var(--color-text-muted)] hover:bg-[rgba(255,255,255,0.08)]"].join(" "),children:e(`projects.sort.${M}`)},M))}),c.jsx("button",{className:"nb-btn nb-btn-yellow shrink-0",style:{padding:"6px 10px"},onClick:()=>b(),type:"button","aria-label":e("common.refresh"),children:c.jsx($h,{size:16,strokeWidth:2.5})})]})]}),c.jsx("ul",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-0.5 pr-1",children:g?c.jsx(w4,{}):c.jsxs(c.Fragment,{children:[[...E,...S].map(M=>c.jsx(x4,{project:M,selected:M.name===n,onClick:()=>k(M.name)},M.name)),(_>0||l&&C.length>0)&&c.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>o(M=>!M),"aria-label":l?"收起更早项目":"显示更早项目",children:l?"收起更早":`含更早 (${_})`})]})})]}),c.jsx("div",{className:"flex-1 min-w-0 min-h-0 flex flex-col",children:n?c.jsx(o4,{name:n,embedded:!0}):c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-[var(--color-text-muted)]",children:e("projects.selectHint")})})})]}),d&&c.jsx(y4,{onClose:()=>f(!1),onCreated:k})]})}function x4({project:e,selected:t,onClick:n}){return c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:n,className:["dimension-menu-item w-full text-left flex-col items-stretch gap-1 px-3 py-2 pl-4",t?"dimension-menu-item-active":""].join(" "),children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] font-bold truncate",children:e.name}),c.jsx(v4,{status:e.pipelineStatus})]}),e.repoDir&&c.jsx("p",{className:"text-[10px] font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] truncate mt-0.5",children:e.repoDir}),c.jsxs("div",{className:"flex gap-3 text-[11px] font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] mt-1.5",children:[c.jsxs("span",{children:[e.cards.total," cards"]}),c.jsxs("span",{children:[e.cards.inprogress," run"]}),c.jsxs("span",{children:[e.workers.active,"/",e.workers.total," w"]})]})]})})}function v4({status:e}){const t={running:{bg:"var(--color-running-bg)",label:"running"},idle:{bg:"var(--color-idle-bg)",label:"idle"},stopping:{bg:"var(--color-stuck-bg)",label:"stopping"},error:{bg:"var(--color-crashed-bg)",label:"error"}},{bg:n,label:i}=t[e],a=e==="running"?"var(--color-running)":e==="error"?"var(--color-crashed)":e==="stopping"?"var(--color-stuck)":"var(--color-idle)";return c.jsx("span",{className:"nb-status",style:{background:n,color:a},children:i})}function w4(){return c.jsx(c.Fragment,{children:[0,1,2].map(e=>c.jsxs("div",{className:"nb-card opacity-60 animate-pulse",style:{padding:"10px 12px"},children:[c.jsx("div",{className:"h-5 w-28 bg-[var(--color-border-light)] rounded-md mb-2"}),c.jsx("div",{className:"h-3 w-2/3 bg-[var(--color-border-light)] rounded-md"})]},e))})}function k4({onNew:e}){const t=Be(),n=t("projects.empty.hint",{cmd:"__CMD__"}),[i,a]=n.split("__CMD__");return c.jsxs("div",{className:"nb-card bg-[var(--color-accent-yellow)] flex items-center gap-6 p-8",children:[c.jsx("div",{className:"w-20 h-20 rounded-3xl bg-[rgba(255,255,255,0.12)] text-[var(--color-text)] flex items-center justify-center shadow-[rgba(255,255,255,0.10)_0_0_0_1px_inset]",children:c.jsx(r_,{size:32,strokeWidth:2.5})}),c.jsxs("div",{className:"flex-1",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold mb-2",children:t("projects.empty.title")}),c.jsxs("p",{className:"text-sm text-[var(--color-text)] mb-4",children:[i,c.jsx("code",{className:"bg-[rgba(0,0,0,0.35)] px-2 py-0.5 rounded-md font-[family-name:var(--font-mono)]",children:"sps project init <name>"}),a]}),c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"button",onClick:e,children:[c.jsx(pi,{size:16,strokeWidth:3}),t("projects.new")]})]})]})}function E4({project:e,isPending:t,onCancel:n,onCreate:i}){var S;const a=Be(),[l,o]=j.useState(""),[d,f]=j.useState(""),[h,g]=j.useState(new Set),[m,y]=j.useState(!1),b=Ye({queryKey:["skills-all",e],queryFn:()=>ox(e)});j.useEffect(()=>{const _=M=>{M.key==="Escape"&&n()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n]);const v=l.trim().length>0&&l.trim().length<=200&&!t,N=_=>{const M=new Set(h);M.has(_)?M.delete(_):M.add(_),g(M)},E=()=>{v&&i({title:l.trim(),description:d.trim(),skills:[...h],labels:["AI-PIPELINE"],initialState:m?"Backlog":"Planning"})},C=((S=b.data)==null?void 0:S.data)??[];return c.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-4 md:p-6 bg-black/30 overflow-hidden",children:c.jsxs("div",{className:"nb-card w-full max-w-5xl flex flex-col",style:{maxHeight:"calc(100vh - 48px)"},children:[c.jsxs("header",{className:"flex items-center justify-between mb-4 flex-shrink-0",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-2xl font-bold",children:a("newCard.title")}),c.jsx("button",{className:"nb-btn nb-btn-mint p-2",onClick:n,type:"button","aria-label":a("common.close"),children:c.jsx(bn,{size:14,strokeWidth:3})})]}),c.jsx("form",{onSubmit:_=>{_.preventDefault(),E()},className:"flex min-h-0 flex-1 flex-col",children:c.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-4 overflow-y-auto pr-1 md:grid-cols-[minmax(0,1fr)_minmax(280px,380px)] md:overflow-hidden md:pr-0",children:[c.jsxs("div",{className:"flex min-h-0 flex-col gap-4 md:overflow-y-auto md:pr-1",children:[c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-sm font-bold",children:a("newCard.field.title")}),c.jsx("input",{type:"text",className:"nb-input w-full",placeholder:a("newCard.field.title.placeholder"),value:l,onChange:_=>o(_.target.value),maxLength:200,autoFocus:!0,required:!0}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:a("newCard.field.title.help")})]}),c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-sm font-bold",children:a("newCard.field.description")}),c.jsx("textarea",{className:"nb-input w-full",style:{minHeight:160,resize:"vertical"},placeholder:a("newCard.field.description.placeholder"),value:d,onChange:_=>f(_.target.value)}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:a("newCard.field.description.help")})]}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("span",{className:"text-sm font-bold",children:a("newCard.field.dispatch")}),c.jsxs("label",{className:"flex items-center gap-3 cursor-pointer select-none p-3 border-[2px] border-[var(--color-text)] rounded-lg bg-[var(--color-bg-cream)]",children:[c.jsx("input",{type:"checkbox",className:"w-4 h-4 accent-[var(--color-cta)] cursor-pointer",checked:m,onChange:_=>y(_.target.checked)}),c.jsxs("div",{className:"flex-1",children:[c.jsx("div",{className:"text-sm font-bold",children:a("newCard.field.dispatch.label")}),c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:a("newCard.field.dispatch.help")})]})]})]})]}),c.jsxs("section",{className:"flex min-h-[240px] flex-col gap-2 md:min-h-0 md:overflow-hidden",children:[c.jsx("span",{className:"text-sm font-bold",children:a("newCard.field.skills")}),c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:a("newCard.field.skills.help")}),c.jsx("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)]",children:c.jsxs("div",{className:"scroll-frame-body h-full p-2",children:[b.isLoading&&c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:a("newCard.field.skills.loading")}),b.isError&&c.jsx("p",{className:"text-xs text-[var(--color-crashed)]",children:a("newCard.field.skills.error",{detail:b.error instanceof Error?b.error.message:String(b.error)})}),C.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:C.map(_=>{const M=h.has(_.name);return c.jsx("button",{type:"button",onClick:()=>N(_.name),className:["max-w-full break-all px-2.5 py-1 text-left text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",M?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),"aria-pressed":M,children:_.name},_.name)})})]})}),h.size>0&&c.jsx("p",{className:"max-h-14 overflow-y-auto break-words text-xs text-[var(--color-text-muted)]",children:a("newCard.field.skills.selected",{count:h.size,names:[...h].join(", ")})})]})]})}),c.jsxs("div",{className:"flex gap-2 justify-end mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[c.jsx("button",{className:"nb-btn",style:{padding:"6px 14px"},onClick:n,disabled:t,type:"button",children:a("common.cancel")}),c.jsxs("button",{className:"nb-btn nb-btn-primary",style:{padding:"6px 14px"},onClick:E,disabled:!v,type:"button","aria-label":a("newCard.create.aria"),children:[t?c.jsx(Xe,{size:13,strokeWidth:3,className:"animate-spin"}):c.jsx(pi,{size:13,strokeWidth:3}),a("common.create")]})]})]})})}function S4(e){return ft(`/api/projects/${encodeURIComponent(e)}/cards`)}function N4(e,t){return ft(`/api/projects/${encodeURIComponent(e)}/cards/${t}`)}async function ac(e,t){const n=await fetch(e,{method:"POST",headers:t?{"Content-Type":"application/json"}:void 0,body:t?JSON.stringify(t):void 0});if(!n.ok){const i=await n.text();throw new Error(`${n.status} ${n.statusText}: ${i}`)}return n.json().catch(()=>({}))}function _4(e,t){return ac(`/api/projects/${encodeURIComponent(e)}/cards/${t}/reset`)}async function j4(e,t){const n=await fetch(`/api/projects/${encodeURIComponent(e)}/cards/${t}`,{method:"DELETE"});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}}function C4(e,t){return ac(`/api/projects/${encodeURIComponent(e)}/cards/${t}/launch`)}function A4(e,t){const n=typeof t=="string"?{title:t}:t;return ac(`/api/projects/${encodeURIComponent(e)}/cards`,n)}async function T4(e,t,n){const i=await fetch(`/api/projects/${encodeURIComponent(e)}/cards/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:n})});if(!i.ok){const a=await i.text();throw new Error(`${i.status}: ${a}`)}}async function M4(e,t,n){const i=await fetch(`/api/projects/${encodeURIComponent(e)}/cards/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const a=await i.text();throw new Error(`${i.status}: ${a}`)}return i.json()}function y2(e){return ac(`/api/projects/${encodeURIComponent(e)}/pipeline/start`)}function b2(e){return ac(`/api/projects/${encodeURIComponent(e)}/pipeline/stop`)}function D4(e,t){return ac(`/api/projects/${encodeURIComponent(e)}/pipeline/reset`,t??{})}function O4(e){const t=Gt();j.useEffect(()=>{if(!e)return;const n=`/stream/projects/${encodeURIComponent(e)}`,i=new EventSource(n),a=d=>{try{const f=JSON.parse(d.data);t.invalidateQueries({queryKey:["cards",f.project]}),t.invalidateQueries({queryKey:["card",f.project,f.seq]}),t.invalidateQueries({queryKey:["projects"]})}catch{}},l=d=>{try{const f=JSON.parse(d.data);t.invalidateQueries({queryKey:["workers",f.project]}),t.invalidateQueries({queryKey:["projects"]})}catch{}},o=d=>{try{const f=JSON.parse(d.data);t.invalidateQueries({queryKey:["pipeline-status",f.project]}),t.invalidateQueries({queryKey:["projects"]})}catch{}};return i.addEventListener("card.created",a),i.addEventListener("card.updated",a),i.addEventListener("card.moved",a),i.addEventListener("card.deleted",a),i.addEventListener("worker.updated",l),i.addEventListener("worker.added",l),i.addEventListener("worker.deleted",l),i.addEventListener("pipeline.status",o),i.addEventListener("pipeline.started",o),i.addEventListener("pipeline.stopped",o),()=>i.close()},[e,t])}const R4=new Set(["python","typescript","golang","rust","kotlin","swift","java"]),L4=new Set(["frontend","backend","mobile","database","devops"]),I4=new Set(["backend-architect","frontend-developer","code-reviewer","database-optimizer","devops-automator","security-engineer","qa-tester","security","qa","architect","db-opt"]),z4=new Set(["coding-standards","tdd-workflow","git-workflow","architecture-decision-records","debugging-workflow"]);function P4(e){return R4.has(e)?"lang":L4.has(e)?"end":I4.has(e)?"persona":z4.has(e)?"workflow":"other"}const B4={lang:"var(--skill-badge-lang-bg, var(--color-accent-purple))",end:"var(--skill-badge-end-bg, var(--color-secondary))",persona:"var(--skill-badge-persona-bg, var(--color-primary))",workflow:"var(--skill-badge-workflow-bg, var(--color-accent-mint))",other:"var(--skill-badge-other-bg, var(--color-bg))"};function dx({name:e}){const t=B4[P4(e)];return c.jsx("span",{className:"nb-badge",style:{background:t},children:e})}function x2({label:e,kind:t="default"}){const n=t==="warn"?"var(--color-accent-pink)":t==="accent"?"var(--color-accent-yellow)":"var(--color-bg-cream)";return c.jsx("span",{className:"nb-badge",style:{background:n},children:e})}function $4({card:e,onClick:t,done:n,draggable:i}){const a=Be(),l=e.labels.some(o=>o.startsWith("STARTED-"))&&!n;return c.jsxs("article",{onClick:t,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),t())},draggable:i,onDragStart:o=>{o.dataTransfer.setData("application/x-sps-card-seq",String(e.seq)),o.dataTransfer.effectAllowed="move"},tabIndex:0,role:"button","aria-label":`Card #${e.seq}: ${e.title}`,className:["nb-card nb-card-interactive p-3 cursor-pointer","transition-[transform,background-color,border-color] duration-[180ms] ease-out","focus:outline-none focus-visible:ring-[3px] focus-visible:ring-offset-2 focus-visible:ring-[var(--color-text)]",n?"opacity-60":"",i?"active:cursor-grabbing":""].join(" "),children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[c.jsxs("span",{className:"nb-badge font-[family-name:var(--font-mono)] text-[11px] px-2 py-0.5",children:["#",e.seq]}),l&&c.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)"},children:"running"})]}),c.jsx("p",{className:`font-bold text-sm leading-5 mb-2 line-clamp-2 ${n?"line-through decoration-2":""}`,children:e.title}),(e.skills.length>0||e.labels.length>0)&&c.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[e.skills.slice(0,3).map(o=>c.jsx(dx,{name:o},o)),e.labels.filter(o=>o==="NEEDS-FIX").map(o=>c.jsx(x2,{label:o,kind:"warn"},o))]}),e.checklist&&e.checklist.total>0&&c.jsx(U4,{stats:e.checklist}),c.jsxs("div",{className:"pt-2 border-t-[1.5px] border-dashed border-[var(--color-border-light)] flex items-center gap-2 text-[11px] font-[family-name:var(--font-mono)] text-[var(--color-text-subtle)]",children:[c.jsx("span",{children:F4(e.updatedAt??e.createdAt,a)}),e.branch&&c.jsxs("span",{className:"truncate",children:["· ",e.branch]})]})]})}function U4({stats:e}){const t=Be();return c.jsxs("div",{className:"mb-2",children:[c.jsxs("div",{className:"flex items-center justify-between text-[11px] font-[family-name:var(--font-mono)] mb-1",children:[c.jsx("span",{className:"font-bold",children:t("kanban.checklist.label",{done:e.done,total:e.total})}),c.jsxs("span",{className:"text-[var(--color-text-subtle)]",children:[e.percent,"%"]})]}),c.jsx("div",{className:"w-full h-1.5 bg-[rgba(255,255,255,0.08)] rounded-full overflow-hidden mb-1.5",children:c.jsx("div",{className:"h-full bg-[var(--color-snow-white)] transition-[width] duration-200",style:{width:`${e.percent}%`}})}),c.jsxs("ul",{className:"text-[11px] space-y-0.5",children:[e.items.slice(0,3).map((n,i)=>c.jsxs("li",{className:`flex items-start gap-1 ${n.done?"opacity-60 line-through":""}`,children:[c.jsx("span",{className:"flex-shrink-0 mt-0.5",children:n.done?"✓":"○"}),c.jsx("span",{className:"line-clamp-1",children:n.text})]},i)),e.items.length>3&&c.jsx("li",{className:"text-[var(--color-text-subtle)] italic pl-3",children:t("kanban.checklist.more",{count:e.items.length-3})})]})]})}function F4(e,t){if(!e)return"—";const n=new Date(e),i=Date.now()-n.getTime();return i<6e4?t("kanban.time.justNow"):i<36e5?t("kanban.time.minutes",{n:Math.floor(i/6e4)}):i<864e5?t("kanban.time.hours",{n:Math.floor(i/36e5)}):n.toLocaleDateString()}function q4({label:e,bg:t,badgeVars:n,cards:i,onCardClick:a,onDropCard:l}){const o=Be(),[d,f]=j.useState(!1);return c.jsxs("div",{className:["nb-card flex flex-col p-3 min-h-[280px] h-full min-h-0 overflow-hidden","transition-all",d?"bg-[rgba(255,255,255,0.16)]":""].join(" "),style:{background:t,...n},onDragOver:h=>{!l||!h.dataTransfer.types.includes("application/x-sps-card-seq")||(h.preventDefault(),h.dataTransfer.dropEffect="move",d||f(!0))},onDragLeave:()=>f(!1),onDrop:h=>{if(f(!1),!l)return;const g=h.dataTransfer.getData("application/x-sps-card-seq"),m=Number.parseInt(g,10);Number.isFinite(m)&&(h.preventDefault(),l(m))},children:[c.jsxs("div",{className:"flex items-center justify-between px-1 pb-2 mb-2 border-b border-[var(--color-border-light)] shrink-0",children:[c.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-sm uppercase tracking-wider",children:e}),c.jsx("span",{className:"nb-badge font-[family-name:var(--font-mono)] text-xs px-2 py-0.5",children:i.length})]}),c.jsxs("div",{className:"flex flex-col gap-2 flex-1 min-h-0 overflow-y-auto pr-1 -mr-1",style:{scrollbarWidth:"thin",scrollbarColor:"rgba(229,229,229,0.36) transparent"},children:[i.length===0&&c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] text-center py-6 italic",children:o("kanban.column.empty")}),i.map(h=>c.jsx($4,{card:h,onClick:()=>a(h),done:e==="Done",draggable:!!l},h.seq))]})]})}function Wy(e,t){if(!e)return"";const n=e.split(`
|
|
613
613
|
`),i=new RegExp(`^##\\s+${t}\\s*$`),a=n.findIndex(o=>i.test(o));if(a===-1)return"";let l=n.length;for(let o=a+1;o<n.length;o++)if(/^##\s+/.test(n[o]??"")){l=o;break}return n.slice(a+1,l).join(`
|
|
614
|
-
`).trim()}function $g(e){return Wy(e,"描述")}function H4({project:e,seq:t,onClose:n,onChanged:i}){var H,Q,G,L,z,V,B,le,ve,ke,Se;const a=Be(),l=Gt(),{confirm:o,alert:d}=un(),{data:f,isLoading:h,isError:g,error:m,refetch:y}=Ye({queryKey:["card",e,t],queryFn:()=>N4(e,t)}),[b,k]=j.useState(!1),[v,N]=j.useState(""),[E,C]=j.useState(""),[S,_]=j.useState(new Set),[M,T]=j.useState([]),[R,O]=j.useState(""),$=Ye({queryKey:["skills-all",e],queryFn:()=>ox(e),enabled:b}),q=((Q=(H=Ye({queryKey:["projects"],queryFn:Es,refetchInterval:1e4}).data)==null?void 0:H.data.find(J=>J.name===e))==null?void 0:Q.pipelineStatus)==="running";j.useEffect(()=>{b&&f&&(N(f.title),C($g(f.body)),_(new Set(f.skills)),T([...f.labels]))},[b,f]),j.useEffect(()=>{const J=ue=>{ue.key==="Escape"&&(b?k(!1):n())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[n,b]);const F=Ct({mutationFn:()=>{if(!f)throw new Error("no data");const J={},ue=v.trim();ue&&ue!==f.title&&(J.title=ue);const Te=$g(f.body);E!==Te&&(J.description=E);const Re=[...S].sort(),De=[...f.skills].sort();return JSON.stringify(Re)!==JSON.stringify(De)&&(J.skills=Re),JSON.stringify(M)!==JSON.stringify(f.labels)&&(J.labels=M),Object.keys(J).length===0?Promise.resolve({ok:!0,noop:!0}):M4(e,t,J)},onSuccess:()=>{l.invalidateQueries({queryKey:["card",e,t]}),l.invalidateQueries({queryKey:["cards",e]}),k(!1),i()},onError:J=>{d({title:a("cardModal.error.save.title"),body:J instanceof Error?J.message:String(J)})}}),Y=j.useMemo(()=>{if(!b||!f)return!1;if(v.trim()!==f.title||E!==$g(f.body))return!0;const J=[...S].sort(),ue=[...f.skills].sort();return JSON.stringify(J)!==JSON.stringify(ue)||JSON.stringify(M)!==JSON.stringify(f.labels)},[b,f,v,E,S,M]),D=J=>{const ue=new Set(S);ue.has(J)?ue.delete(J):ue.add(J),_(ue)},K=()=>{const J=R.trim();if(J){if(M.includes(J)){O("");return}T([...M,J]),O("")}},P=J=>{T(M.filter(ue=>ue!==J))};return c.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"card-modal-title",className:"fixed inset-0 z-40 flex items-start justify-center p-6 bg-black/30 overflow-auto",children:c.jsxs("div",{className:"nb-card mt-12 w-full max-w-3xl bg-[var(--color-bg)]",children:[c.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),(f==null?void 0:f.state)&&c.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-full font-semibold",children:f.state}),b&&c.jsx("span",{className:"text-xs font-bold text-[var(--color-stuck)]",children:a("cardModal.editing")})]}),b?c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-heading)] text-xl font-bold",value:v,onChange:J=>N(J.target.value),maxLength:200,"aria-label":a("cardModal.title.aria")}):c.jsx("h2",{id:"card-modal-title",className:"font-[family-name:var(--font-heading)] text-2xl font-bold break-words",children:(f==null?void 0:f.title)??a("common.loading")})]}),c.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[!b&&f&&c.jsxs("button",{onClick:()=>k(!0),className:"nb-btn",style:{padding:"6px 12px"},type:"button","aria-label":a("cardModal.editAria"),children:[c.jsx(qh,{size:12,strokeWidth:2.5})," ",a("cardModal.edit")]}),c.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2","aria-label":a("cardModal.close.aria"),type:"button",children:c.jsx(bn,{size:14,strokeWidth:3})})]})]}),h&&c.jsx("p",{className:"text-[var(--color-text-muted)]",children:a("common.loading")}),g&&c.jsx("p",{className:"text-[var(--color-crashed)]",children:a("cardModal.error.load",{detail:m instanceof Error?m.message:String(m)})}),f&&c.jsxs("div",{className:"flex flex-col gap-4",children:[f.branch&&!b&&c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(hL,{size:14}),c.jsx("span",{className:"font-[family-name:var(--font-mono)]",children:f.branch})]}),b?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Skills"}),$.isLoading&&c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:a("cardModal.skills.loading")}),$.data&&$.data.data.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.data.data.map(J=>{const ue=S.has(J.name);return c.jsx("button",{type:"button",onClick:()=>D(J.name),"aria-pressed":ue,className:["px-2.5 py-1 text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",ue?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:J.name},J.name)})})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Labels"}),c.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[M.map(J=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-[family-name:var(--font-mono)] bg-[var(--color-accent-yellow)] border-2 border-[var(--color-text)] rounded-full",children:[J,c.jsx("button",{type:"button",onClick:()=>P(J),className:"hover:text-[var(--color-crashed)]","aria-label":a("cardModal.label.removeAria",{label:J}),children:c.jsx(bn,{size:10,strokeWidth:3})})]},J)),c.jsx("input",{type:"text",className:"nb-input",style:{padding:"4px 8px",fontSize:12,width:140},placeholder:a("cardModal.label.addPlaceholder"),value:R,onChange:J=>O(J.target.value),onKeyDown:J=>{J.key==="Enter"&&!J.nativeEvent.isComposing&&(J.preventDefault(),K())}}),R&&c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"2px 6px",fontSize:11},onClick:K,"aria-label":a("cardModal.label.addAria"),children:c.jsx(pi,{size:10,strokeWidth:3})})]}),c.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:a("cardModal.label.note")})]})]}):c.jsxs(c.Fragment,{children:[f.skills.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Skills"}),c.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:f.skills.map(J=>c.jsx(dx,{name:J},J))})]}),f.labels.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Labels"}),c.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:f.labels.map(J=>c.jsx(x2,{label:J,kind:J==="NEEDS-FIX"?"warn":"default"},J))})]})]}),b?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.description")}),c.jsx("textarea",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",style:{minHeight:180,resize:"vertical"},value:E,onChange:J=>C(J.target.value),"aria-label":a("cardModal.body.aria")}),c.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:a("cardModal.body.replaceNote")})]}),(((le=f.checklist)==null?void 0:le.total)??0)>0&&c.jsxs("div",{className:"nb-card bg-[var(--color-bg-cream)] p-3",children:[c.jsx("div",{className:"flex items-center justify-between mb-2",children:c.jsxs("span",{className:"font-bold text-sm",children:[a("cardModal.section.checklist")," ",((ve=f.checklist)==null?void 0:ve.done)??0,"/",((ke=f.checklist)==null?void 0:ke.total)??0]})}),c.jsx("ul",{className:"text-sm space-y-1",children:(((Se=f.checklist)==null?void 0:Se.items)??[]).map((J,ue)=>c.jsxs("li",{className:`flex items-start gap-2 ${J.done?"opacity-60 line-through":""}`,children:[c.jsx("span",{children:J.done?"✓":"○"}),c.jsx("span",{children:J.text})]},ue))})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.description")}),c.jsx("pre",{className:"text-xs whitespace-pre-wrap font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg p-4 max-h-64 overflow-auto",children:Wy(f.body,"描述")||a("cardModal.section.empty")})]}),c.jsxs("div",{children:[c.jsxs("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:[a("cardModal.section.checklist")," ",c.jsxs("span",{className:"text-[var(--color-text-muted)] normal-case tracking-normal",children:[((G=f.checklist)==null?void 0:G.done)??0,"/",((L=f.checklist)==null?void 0:L.total)??0]})]}),c.jsx("div",{className:"nb-card bg-[var(--color-bg-cream)] p-3",children:(((z=f.checklist)==null?void 0:z.total)??0)>0?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center justify-end mb-2",children:c.jsx("div",{className:"w-24 h-2 bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-[var(--color-cta)]",style:{width:`${((V=f.checklist)==null?void 0:V.percent)??0}%`}})})}),c.jsx("ul",{className:"text-sm space-y-1",children:(((B=f.checklist)==null?void 0:B.items)??[]).map((J,ue)=>c.jsxs("li",{className:`flex items-start gap-2 ${J.done?"opacity-60 line-through":""}`,children:[c.jsx("span",{children:J.done?"✓":"○"}),c.jsx("span",{children:J.text})]},ue))})]}):c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:a("cardModal.checklist.empty")})})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.log")}),c.jsx("pre",{className:"text-xs whitespace-pre-wrap font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg p-4 max-h-64 overflow-auto",children:Wy(f.body,"日志")||a("cardModal.section.empty")})]})]}),c.jsx("div",{className:"flex gap-2 pt-2 border-t-2 border-[var(--color-border-light)] justify-end flex-wrap",children:b?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nb-btn",type:"button",onClick:()=>{k(!1),y()},disabled:F.isPending,children:a("common.cancel")}),c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"button",onClick:()=>F.mutate(),disabled:!Y||!v.trim()||F.isPending,"aria-label":a("cardDetail.save"),children:[F.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(Rr,{size:14,strokeWidth:3}),a("common.save")]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"button",disabled:f.state==="Done"||q,title:f.state==="Done"?a("cardModal.action.launch.disabledDone"):q?a("cardModal.action.launch.disabledRunning"):void 0,onClick:async()=>{try{await C4(e,t),i()}catch(J){d({title:a("cardModal.action.launch.error"),body:J instanceof Error?J.message:String(J)})}},children:[c.jsx(Yu,{size:14,strokeWidth:3}),a("cardModal.action.launch")]}),c.jsxs("button",{className:"nb-btn nb-btn-yellow",type:"button",onClick:async()=>{if(await o({title:a("cardModal.action.reset.confirm.title",{seq:t}),body:a("cardModal.action.reset.confirm.body"),confirm:a("cardModal.action.reset.confirm.button"),danger:!0}))try{await _4(e,t),i(),n()}catch(ue){d({title:a("cardModal.action.reset.error"),body:ue instanceof Error?ue.message:String(ue)})}},children:[c.jsx(Bb,{size:14,strokeWidth:2.5}),a("cardModal.action.reset")]}),c.jsxs("button",{className:"nb-btn",style:{background:"var(--color-crashed)",color:"var(--color-bg)"},type:"button",onClick:async()=>{if(!(!await o({title:a("cardModal.action.delete.confirm1.title",{seq:t}),body:a("cardModal.action.delete.confirm1.body",{title:f.title}),confirm:a("cardModal.action.delete.confirm1.button"),danger:!0})||!await o({title:a("cardModal.action.delete.confirm2.title"),body:a("cardModal.action.delete.confirm2.body",{seq:t}),confirm:a("cardModal.action.delete"),danger:!0})))try{await j4(e,t),i(),n()}catch(Te){d({title:a("projectDetail.pipelines.delete.error"),body:Te instanceof Error?Te.message:String(Te)})}},"aria-label":a("cardModal.action.delete"),children:[c.jsx(fr,{size:14,strokeWidth:2.5}),a("cardModal.action.delete")]})]})})]})]})})}function K4({current:e,onChange:t}){const[n,i]=j.useState(!1),a=j.useRef(null),{data:l}=Ye({queryKey:["projects"],queryFn:Es});return j.useEffect(()=>{const o=d=>{var f;(f=a.current)!=null&&f.contains(d.target)||i(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[]),c.jsxs("div",{className:"relative",ref:a,children:[c.jsxs("button",{type:"button",className:"nb-btn font-[family-name:var(--font-mono)] text-sm",onClick:()=>i(o=>!o),children:[e,c.jsx(Vu,{size:14,strokeWidth:2.5})]}),n&&l&&c.jsx("div",{className:"absolute right-0 mt-2 z-20 min-w-[200px] nb-card p-1 overflow-hidden",children:c.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:h_(l.data,"activity").map(o=>{const d=o.pipelineStatus==="running";return c.jsxs("button",{type:"button",onClick:()=>{t(o.name),i(!1)},className:["dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2",o.name===e?"dimension-menu-item-active":""].join(" "),children:[d&&c.jsx(Yu,{size:12,strokeWidth:3,className:"text-[var(--color-running)] shrink-0","aria-label":"运行中"}),c.jsx("span",{className:"font-[family-name:var(--font-mono)]",children:o.name}),c.jsxs("span",{className:"ml-auto text-xs text-[var(--color-text-muted)]",children:[o.cards.total," cards"]})]},o.name)})})})]})}const G4=[{state:"Planning",labelKey:"board.col.planning",bg:"linear-gradient(180deg, rgba(139, 117, 255, 0.20), rgba(188, 166, 255, 0.075))",badgeVars:{"--skill-badge-lang-bg":"rgba(172, 153, 255, 0.30)","--skill-badge-end-bg":"rgba(151, 133, 239, 0.26)","--skill-badge-persona-bg":"rgba(193, 178, 255, 0.24)","--skill-badge-workflow-bg":"rgba(159, 146, 220, 0.27)","--skill-badge-other-bg":"rgba(126, 107, 206, 0.30)"}},{state:"Backlog",labelKey:"board.col.backlog",bg:"linear-gradient(180deg, rgba(147, 158, 190, 0.14), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(149, 160, 198, 0.24)","--skill-badge-end-bg":"rgba(128, 141, 176, 0.25)","--skill-badge-persona-bg":"rgba(165, 172, 199, 0.22)","--skill-badge-workflow-bg":"rgba(138, 152, 184, 0.26)","--skill-badge-other-bg":"rgba(116, 127, 158, 0.28)"}},{state:"Todo",labelKey:"board.col.todo",bg:"linear-gradient(180deg, rgba(239, 201, 126, 0.18), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(245, 207, 135, 0.28)","--skill-badge-end-bg":"rgba(226, 182, 101, 0.25)","--skill-badge-persona-bg":"rgba(249, 221, 159, 0.23)","--skill-badge-workflow-bg":"rgba(232, 193, 118, 0.27)","--skill-badge-other-bg":"rgba(204, 159, 84, 0.29)"}},{state:"Inprogress",labelKey:"board.col.inprogress",bg:"linear-gradient(180deg, rgba(98, 176, 242, 0.18), rgba(188, 166, 255, 0.065))",badgeVars:{"--skill-badge-lang-bg":"rgba(104, 181, 246, 0.28)","--skill-badge-end-bg":"rgba(79, 153, 223, 0.26)","--skill-badge-persona-bg":"rgba(136, 198, 250, 0.22)","--skill-badge-workflow-bg":"rgba(91, 166, 228, 0.27)","--skill-badge-other-bg":"rgba(67, 128, 197, 0.29)"}},{state:"QA",labelKey:"board.col.qa",bg:"linear-gradient(180deg, rgba(222, 171, 222, 0.18), rgba(188, 166, 255, 0.065))",badgeVars:{"--skill-badge-lang-bg":"rgba(226, 174, 226, 0.28)","--skill-badge-end-bg":"rgba(206, 145, 213, 0.25)","--skill-badge-persona-bg":"rgba(236, 197, 236, 0.22)","--skill-badge-workflow-bg":"rgba(215, 158, 218, 0.27)","--skill-badge-other-bg":"rgba(184, 125, 196, 0.29)"}},{state:"Done",labelKey:"board.col.done",bg:"linear-gradient(180deg, rgba(120, 214, 163, 0.18), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(125, 216, 166, 0.27)","--skill-badge-end-bg":"rgba(93, 190, 139, 0.25)","--skill-badge-persona-bg":"rgba(154, 226, 185, 0.22)","--skill-badge-workflow-bg":"rgba(107, 202, 150, 0.28)","--skill-badge-other-bg":"rgba(75, 166, 120, 0.29)"}}],v2="sps-console:last-board-project";function V4(){if(typeof window>"u")return null;try{return localStorage.getItem(v2)}catch{return null}}function Y4(e){if(!(typeof window>"u"))try{localStorage.setItem(v2,e)}catch{}}function Q4(){var P,H,Q;const e=Be(),[t,n]=UN(),i=t.get("project"),[a,l]=j.useState(null),[o,d]=j.useState(""),[f,h]=j.useState(()=>new Set),[g,m]=j.useState(()=>new Set),{confirm:y,alert:b}=un();O4(i);const k=Ye({queryKey:["projects"],queryFn:Es}),v=Ye({queryKey:["cards",i],queryFn:()=>S4(i??""),enabled:!!i}),N=Gt(),E=()=>{N.invalidateQueries({queryKey:["cards",i]}),N.invalidateQueries({queryKey:["projects"]}),N.invalidateQueries({queryKey:["pipeline-status",i]})},C=G=>{n({project:G})};j.useEffect(()=>{var L;if(i){Y4(i);return}const G=V4();G&&((L=k.data)!=null&&L.data.some(z=>z.name===G))&&n({project:G},{replace:!0})},[i,k.data,n]);const S=Ct({mutationFn:()=>y2(i),onSuccess:()=>{E()},onError:G=>{b({title:e("board.action.startError"),body:G instanceof Error?G.message:String(G)})}}),_=Ct({mutationFn:()=>b2(i),onSuccess:()=>E(),onError:G=>{b({title:e("board.action.stopError"),body:G instanceof Error?G.message:String(G)})}}),M=Ct({mutationFn:()=>D4(i,{all:!0}),onSuccess:()=>E(),onError:G=>{b({title:e("board.action.resetError"),body:G instanceof Error?G.message:String(G)})}}),[T,R]=j.useState(!1),O=Ct({mutationFn:G=>A4(i,G),onSuccess:()=>{E(),R(!1)},onError:G=>{b({title:e("board.action.newCard.error"),body:G instanceof Error?G.message:String(G)})}}),$=Ct({mutationFn:({seq:G,state:L})=>T4(i,G,L),onMutate:async({seq:G,state:L})=>{await N.cancelQueries({queryKey:["cards",i]});const z=N.getQueryData(["cards",i]);return z&&N.setQueryData(["cards",i],{...z,data:z.data.map(V=>V.seq===G?{...V,state:L}:V)}),{prev:z}},onError:(G,L,z)=>{z!=null&&z.prev&&N.setQueryData(["cards",i],z.prev),b({title:e("board.action.moveCard.error"),body:G instanceof Error?G.message:String(G)})},onSettled:()=>{N.invalidateQueries({queryKey:["cards",i]})}}),I=((P=v.data)==null?void 0:P.data)??[],{allSkills:q,allLabels:F}=j.useMemo(()=>{const G=new Set,L=new Set;for(const z of I){for(const V of z.skills)G.add(V);for(const V of z.labels)L.add(V)}return{allSkills:[...G].sort(),allLabels:[...L].sort()}},[I]);if(!i)return c.jsxs("div",{className:"flex flex-col gap-6 w-full",children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold",children:e("board.title.bare")}),c.jsxs("div",{className:"nb-card bg-[var(--color-accent-yellow)] max-w-2xl",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-3",children:e("board.pickPrompt.title")}),c.jsx("p",{className:"text-sm mb-4 text-[var(--color-text-muted)]",children:e("board.pickPrompt.body")}),c.jsx("div",{className:"flex flex-wrap gap-2",children:(H=k.data)==null?void 0:H.data.map(G=>c.jsx("button",{className:"nb-btn nb-btn-blue",onClick:()=>C(G.name),type:"button",children:G.name},G.name))})]})]});const Y=I.filter(G=>{if(o){const L=o.toLowerCase();if(!(G.title.toLowerCase().includes(L)||G.skills.some(V=>V.toLowerCase().includes(L))||G.labels.some(V=>V.toLowerCase().includes(L))))return!1}return!(f.size>0&&!G.skills.some(z=>f.has(z))||g.size>0&&!G.labels.some(z=>g.has(z)))}),D=(Q=k.data)==null?void 0:Q.data.find(G=>G.name===i),K=(D==null?void 0:D.pipelineStatus)==="running";return c.jsxs("div",{className:"flex flex-col gap-4 max-w-full flex-1 min-h-0",children:[c.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3 shrink-0",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold tracking-tight",children:e("board.title")}),c.jsx("p",{className:"text-[var(--color-text-muted)] text-sm mt-1",children:D?e("board.subtitle",{name:D.name,cards:D.cards.total,workers:D.workers.active}):e("common.loading")})]}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(K4,{current:i,onChange:C}),c.jsxs("button",{className:K?"nb-btn nb-btn-danger":"nb-btn nb-btn-primary",onClick:()=>K?_.mutate():S.mutate(),disabled:S.isPending||_.isPending,type:"button","aria-label":e(K?"board.action.stopAria":"board.action.startAria"),title:e(K?"board.action.stopAria":"board.action.startAria"),children:[S.isPending||_.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):K?c.jsx(Ub,{size:14,strokeWidth:3}):c.jsx(Yu,{size:14,strokeWidth:3}),e(K?"board.action.stop":"board.action.start")]}),c.jsxs("button",{className:"nb-btn nb-btn-yellow",type:"button",onClick:async()=>{await y({title:e("board.action.reset.confirm.title"),body:e("board.action.reset.confirm.body"),confirm:e("board.action.reset.confirm.button"),danger:!0})&&M.mutate()},disabled:M.isPending,children:[M.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(Bb,{size:14,strokeWidth:2.5}),e("board.action.reset")]}),c.jsxs("button",{className:"nb-btn nb-btn-mint",type:"button",onClick:()=>R(!0),disabled:O.isPending,children:[O.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(pi,{size:14,strokeWidth:3}),e("board.action.newCard")]})]})]}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[c.jsxs("div",{className:"relative flex-1 max-w-md",children:[c.jsx(fl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),c.jsx("input",{className:"nb-input pl-9 w-full",placeholder:e("board.search.placeholder"),value:o,onChange:G=>d(G.target.value),"aria-label":e("board.search.aria")})]}),c.jsx(Ak,{label:"skill",options:q,selected:f,onChange:h}),c.jsx(Ak,{label:"label",options:F,selected:g,onChange:m}),(o||f.size>0||g.size>0)&&c.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:11},onClick:()=>{d(""),h(new Set),m(new Set)},type:"button","aria-label":e("board.filter.clearAria"),children:[c.jsx(bn,{size:11,strokeWidth:3}),e("board.filter.clear")]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-1 font-[family-name:var(--font-mono)]",children:[c.jsx(dL,{size:12}),Y.length," / ",I.length]})]}),v.isError&&c.jsxs("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:[c.jsx("p",{className:"font-semibold",children:e("board.error.loadCards")}),c.jsx("p",{className:"text-sm mt-1 text-[var(--color-text-muted)]",children:v.error instanceof Error?v.error.message:String(v.error)})]}),!v.isError&&c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 auto-rows-fr gap-3 flex-1 min-h-0",children:G4.map(G=>c.jsx(q4,{label:e(G.labelKey),bg:G.bg,badgeVars:G.badgeVars,cards:Y.filter(W4(G.state)),onCardClick:L=>l(L.seq),onDropCard:L=>$.mutate({seq:L,state:G.state})},G.state))}),a!==null&&c.jsx(H4,{project:i,seq:a,onClose:()=>l(null),onChanged:E}),T&&c.jsx(E4,{project:i,isPending:O.isPending,onCancel:()=>R(!1),onCreate:G=>O.mutate(G)})]})}function W4(e){return t=>e==="QA"?t.state==="QA"||t.state==="Review":e==="Done"?t.state==="Done"||t.state==="Canceled":t.state===e}function Ak({label:e,options:t,selected:n,onChange:i}){const a=Be(),[l,o]=j.useState(!1),d=j.useRef(null);j.useEffect(()=>{if(!l)return;const m=b=>{var k;(k=d.current)!=null&&k.contains(b.target)||o(!1)},y=b=>{b.key==="Escape"&&o(!1)};return window.addEventListener("click",m),window.addEventListener("keydown",y),()=>{window.removeEventListener("click",m),window.removeEventListener("keydown",y)}},[l]);const f=m=>{const y=new Set(n);y.has(m)?y.delete(m):y.add(m),i(y)},h=t.length===0,g=n.size;return c.jsxs("div",{ref:d,className:"relative",children:[c.jsxs("button",{type:"button",className:"nb-btn",style:{padding:"6px 12px",fontSize:12},onClick:()=>!h&&o(m=>!m),disabled:h,"aria-haspopup":"listbox","aria-expanded":l,"aria-label":a("board.filter.aria",{label:e}),children:[e,g>0&&c.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-[var(--color-primary)] text-[var(--color-text)] border border-[var(--color-text)]",children:g}),c.jsx(Vu,{size:11,strokeWidth:3,className:["transition-transform",l?"rotate-180":""].join(" ")})]}),l&&c.jsx("div",{className:"absolute left-0 top-full mt-2 z-20 min-w-[200px] nb-card p-2 overflow-hidden",style:{padding:8},children:c.jsxs("div",{role:"listbox",className:"max-h-64 overflow-auto",children:[t.map(m=>{const y=n.has(m);return c.jsxs("label",{className:["flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer text-sm font-[family-name:var(--font-mono)]",y?"bg-[var(--color-accent-mint)]":"hover:bg-[var(--color-bg-cream)]"].join(" "),children:[c.jsx("input",{type:"checkbox",checked:y,onChange:()=>f(m),className:"flex-shrink-0"}),c.jsx("span",{className:"truncate",children:m})]},m)}),g>0&&c.jsx("button",{type:"button",className:"w-full mt-2 pt-2 border-t-2 border-dashed border-[var(--color-text)] text-xs font-bold text-[var(--color-crashed)] text-center",onClick:()=>i(new Set),children:a("board.filter.clearSelection")})]})})]})}function X4(){return ft("/api/workers/all")}function Z4(e){return ft(`/api/projects/${encodeURIComponent(e)}/workers`)}function J4(e,t){return ft(`/api/projects/${encodeURIComponent(e)}/workers/${t}`)}async function w2(e,t){const n=await fetch(e,{method:"POST",headers:t?{"Content-Type":"application/json"}:void 0,body:t?JSON.stringify(t):void 0});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json().catch(()=>({}))}function Tk(e,t){return w2(`/api/projects/${encodeURIComponent(e)}/workers/${t}/kill`)}function eP(e,t,n){return w2(`/api/projects/${encodeURIComponent(e)}/workers/${t}/launch`,n?{seq:n}:void 0)}function fx({state:e}){const n={running:{bg:"var(--color-running-bg)",color:"var(--color-running)",label:"running"},starting:{bg:"var(--color-secondary)",color:"var(--color-text)",label:"starting",icon:c.jsx(Xe,{size:9,strokeWidth:3,className:"animate-spin"})},stuck:{bg:"var(--color-stuck-bg)",color:"var(--color-stuck)",label:"stuck"},crashed:{bg:"var(--color-crashed-bg)",color:"var(--color-crashed)",label:"crashed",icon:c.jsx(o3,{size:9,strokeWidth:2.5})},idle:{bg:"var(--color-idle-bg)",color:"var(--color-idle)",label:"idle"}}[e];return c.jsxs("span",{className:"nb-status inline-flex items-center gap-1",style:{background:n.bg,color:n.color},children:[n.icon,n.label]})}function hx(e){if(e==null||e<=0)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?`${n}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function tP(e){if(e==null||e<=0)return"text-[var(--color-text-muted)]";const t=e/6e4;return t<10?"text-[var(--color-running)]":t<60?"text-[var(--color-stuck)]":"text-[var(--color-crashed)]"}function px(e){const t=Date.now()-new Date(e).getTime();return t<6e4?`${Math.floor(t/1e3)}s 前`:t<36e5?`${Math.floor(t/6e4)}m 前`:`${Math.floor(t/36e5)}h 前`}function nP({alerts:e,selected:t,onSelect:n}){const i=Be();return e.length===0?c.jsxs("div",{className:"nb-card bg-[var(--color-running-bg)] flex items-center gap-3",children:[c.jsx(Eu,{size:18,strokeWidth:2.5,className:"text-[var(--color-running)]"}),c.jsx("span",{className:"text-sm font-bold text-[var(--color-running)]",children:i("workers.alerts.allHealthy")})]}):c.jsxs("section",{children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 flex items-center gap-2 text-[var(--color-crashed)]",children:[c.jsx(w3,{size:14,strokeWidth:2.5}),"Alerts (",e.length,")"]}),c.jsx("div",{className:"flex flex-col gap-2",children:e.map(a=>{const l=(t==null?void 0:t.project)===a.project&&(t==null?void 0:t.slot)===a.slot;return c.jsxs("button",{type:"button",onClick:()=>n(a.project,a.slot),className:["nb-card p-3 text-left",a.state==="crashed"?"bg-[var(--color-crashed-bg)]":"bg-[var(--color-stuck-bg)]",l?"ring-4 ring-[var(--color-text)]":""].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(fx,{state:a.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold",children:[a.project,"/worker-",a.slot]}),a.card&&c.jsxs("span",{className:"truncate",children:["#",a.card.seq," ",a.card.title]}),c.jsxs("span",{className:"ml-auto text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] flex items-center gap-1",children:[c.jsx(GN,{size:10,strokeWidth:2.5}),hx(a.runtimeMs)]})]}),a.markerUpdatedAt&&c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-1 font-[family-name:var(--font-mono)]",children:a.state==="crashed"?i("workers.alerts.pidDead"):i("workers.alerts.markerStale",{ago:px(a.markerUpdatedAt)})})]},`${a.project}-${a.slot}`)})})]})}function iP({active:e,selected:t,onSelect:n}){const i=Be();return e.length===0?c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] italic",children:i("workers.active.empty")})}):c.jsxs("section",{children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 flex items-center gap-2",children:[c.jsx($h,{size:14,strokeWidth:2.5}),"Active (",e.length,")"]}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:e.map(a=>{const l=(t==null?void 0:t.project)===a.project&&(t==null?void 0:t.slot)===a.slot;return c.jsxs("button",{type:"button",onClick:()=>n(a.project,a.slot),className:["nb-card p-3 text-left",a.state==="starting"?"bg-[var(--color-secondary)]":"bg-[var(--color-running-bg)]",l?"ring-4 ring-[var(--color-text)]":""].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(fx,{state:a.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm flex-1 truncate",children:[a.project,"/worker-",a.slot]}),c.jsx("span",{className:`text-xs font-[family-name:var(--font-mono)] ${tP(a.runtimeMs)}`,children:hx(a.runtimeMs)})]}),a.card&&c.jsxs("div",{className:"text-sm font-semibold mb-1 truncate",children:["#",a.card.seq," · ",a.card.title]}),c.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] flex items-center gap-2 mb-1",children:[a.stage&&c.jsxs("span",{children:["stage: ",a.stage]}),a.markerUpdatedAt&&c.jsxs("span",{className:"ml-auto",children:["marker ",px(a.markerUpdatedAt)]})]}),a.lastLogLine&&c.jsxs("div",{className:"text-[11px] font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded px-2 py-1 mt-2 truncate",children:[c.jsx(n_,{size:9,strokeWidth:2.5,className:"inline-block mr-1 align-text-bottom"}),a.lastLogLine.msg]})]},`${a.project}-${a.slot}`)})})]})}function rP({capacity:e,selected:t,onSelect:n}){const i=Be();return e.length===0?null:c.jsxs("section",{className:"flex flex-col min-h-0 flex-1",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 shrink-0",children:"Capacity"}),c.jsxs("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)] flex flex-col",children:[c.jsxs("table",{className:"w-full table-fixed text-sm shrink-0",children:[c.jsx(Mk,{}),c.jsx("thead",{children:c.jsxs("tr",{className:"border-b-2 border-[var(--color-border-light)] bg-[var(--color-bg-soft)]",children:[c.jsx("th",{className:"px-3 py-2 text-left font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.project")}),c.jsx("th",{className:"px-3 py-2 text-left font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.usage")}),c.jsx("th",{className:"px-3 py-2 text-right font-bold text-xs uppercase tracking-wider",children:"running"}),c.jsx("th",{className:"px-3 py-2 text-right font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.other")}),c.jsx("th",{className:"px-3 py-2"})]})})]}),c.jsx("div",{className:"bg-color-bg-soft scroll-frame-body flex-1",children:c.jsxs("table",{className:"w-full table-fixed text-sm",children:[c.jsx(Mk,{}),c.jsx("tbody",{children:e.map(a=>c.jsx(aP,{capacity:a,selected:(t==null?void 0:t.project)===a.project,onSelect:()=>n(a.project)},a.project))})]})})]})]})}function Mk(){return c.jsxs("colgroup",{children:[c.jsx("col",{className:"w-[24%]"}),c.jsx("col",{className:"w-[28%]"}),c.jsx("col",{className:"w-[16%]"}),c.jsx("col",{className:"w-[20%]"}),c.jsx("col",{className:"w-[12%]"})]})}function aP({capacity:e,selected:t,onSelect:n}){const i=Be(),a=e.running+e.starting+e.stuck+e.crashed;return c.jsxs("tr",{onClick:n,className:["border-b border-dashed border-[var(--color-border-light)] last:border-0 cursor-pointer hover:bg-[var(--color-accent-yellow)]",t?"bg-[var(--color-accent-yellow)]":""].join(" "),children:[c.jsx("td",{className:"px-3 py-2 font-[family-name:var(--font-mono)] font-bold",children:e.project}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(sP,{total:e.total,cap:e})}),c.jsxs("td",{className:"px-3 py-2 text-right font-[family-name:var(--font-mono)]",children:[c.jsx("span",{className:"text-[var(--color-running)] font-bold",children:e.running}),c.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",e.total]})]}),c.jsxs("td",{className:"px-3 py-2 text-right text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)]",children:[e.starting>0&&c.jsxs("span",{className:"mr-2",children:["starting ",e.starting]}),e.stuck>0&&c.jsxs("span",{className:"text-[var(--color-stuck)] font-bold mr-2",children:["stuck ",e.stuck]}),e.crashed>0&&c.jsxs("span",{className:"text-[var(--color-crashed)] font-bold mr-2",children:["crashed ",e.crashed]}),a===0&&c.jsx("span",{children:"idle"})]}),c.jsx("td",{className:"px-3 py-2 text-right",children:c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:i("workers.capacity.detailHint")})})]})}function sP({total:e,cap:t}){const n=[];for(let i=0;i<t.crashed;i++)n.push("crashed");for(let i=0;i<t.stuck;i++)n.push("stuck");for(let i=0;i<t.starting;i++)n.push("starting");for(let i=0;i<t.running;i++)n.push("running");for(let i=0;i<t.idle;i++)n.push("idle");return c.jsxs("div",{className:"flex gap-1 items-center",children:[n.map((i,a)=>c.jsx("span",{className:"inline-block w-3 h-3 rounded-full border-2 border-[var(--color-text)]",style:{background:lP(i)},title:i},a)),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] ml-2 font-[family-name:var(--font-mono)]",children:[e," slot",e!==1?"s":""]})]})}function lP(e){switch(e){case"running":return"var(--color-running-bg)";case"starting":return"var(--color-secondary)";case"stuck":return"var(--color-stuck-bg)";case"crashed":return"var(--color-crashed-bg)";default:return"var(--color-idle-bg)"}}function oP({project:e,initialSlot:t,onChange:n}){var h;const i=Be(),a=Ye({queryKey:["workers",e],queryFn:()=>Z4(e),refetchInterval:3e3}),l=((h=a.data)==null?void 0:h.data)??[],[o,d]=j.useState(null);j.useEffect(()=>{if(l.length===0){d(null);return}const g=l[0].slot;d(m=>m!=null&&l.some(y=>y.slot===m)?m:t!=null&&l.some(y=>y.slot===t)?t:g)},[e,t,l.length]);const f=l.find(g=>g.slot===o)??null;return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"px-4 bg-color-bg-soft py-3 border-b-2 border-[var(--color-text)] bg-[var(--color-bg-cream)]",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold truncate",children:e}),c.jsx(vs,{to:`/board?project=${encodeURIComponent(e)}`,className:"text-xs underline text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:i("workers.panel.boardLink")})]}),a.isLoading&&l.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.loading")}):l.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.empty.slots")}):c.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(g=>c.jsx(cP,{worker:g,active:g.slot===o,onClick:()=>d(g.slot)},g.slot))})]}),f?c.jsx(uP,{project:e,worker:f,onChange:n}):c.jsx("div",{className:"flex-1 flex items-center justify-center p-6 text-center",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:l.length===0?i("workers.panel.empty.noWorker"):i("workers.panel.empty.pickOne")})})]})}function cP({worker:e,active:t,onClick:n}){const i=Be();return c.jsxs("button",{type:"button",onClick:n,className:["nb-card p-2 text-left min-w-[130px] transition-transform",t?"ring-4 ring-[var(--color-text)]":"opacity-80 hover:opacity-100"].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(fx,{state:e.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs",children:["worker-",e.slot]})]}),e.card?c.jsxs("div",{className:"text-[11px] truncate font-[family-name:var(--font-mono)]",children:["#",e.card.seq," ",e.card.title]}):c.jsx("div",{className:"text-[11px] text-[var(--color-text-muted)] italic",children:i("workers.panel.idle.short")})]})}function uP({project:e,worker:t,onChange:n}){var y,b;const i=Be(),{confirm:a,alert:l}=un(),o=t.state==="crashed"||t.state==="stuck",d=Ye({queryKey:["worker-detail",e,t.slot],queryFn:()=>J4(e,t.slot),refetchInterval:3e3}),f=((y=d.data)==null?void 0:y.recentOutput)??[],h=((b=d.data)==null?void 0:b.recentLogs)??[],g=j.useRef(null),m=j.useRef(!0);return j.useEffect(()=>{const k=g.current;k&&m.current&&(k.scrollTop=k.scrollHeight)},[f]),c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex-1 overflow-auto p-4 flex flex-col gap-4",children:[t.card?c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:i("workers.panel.section.currentCard")}),c.jsxs("div",{className:"text-sm font-semibold break-words",children:["#",t.card.seq," · ",t.card.title]})]}):c.jsx("div",{className:"text-sm text-[var(--color-text-muted)] italic",children:i("workers.panel.idle.full")}),c.jsxs("dl",{className:"grid grid-cols-[100px_1fr] gap-y-2 text-sm",children:[c.jsx("dt",{className:"font-bold",children:"Stage"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.stage??"—"}),c.jsx("dt",{className:"font-bold",children:"PID"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.pid??"—"}),c.jsx("dt",{className:"font-bold",children:"Runtime"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:hx(t.runtimeMs)}),c.jsx("dt",{className:"font-bold",children:"Started"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)] text-xs",children:t.startedAt?new Date(t.startedAt).toLocaleString():"—"}),c.jsx("dt",{className:"font-bold",children:"Marker"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)] text-xs",children:t.markerUpdatedAt?px(t.markerUpdatedAt):"—"})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-[var(--color-text-muted)] mb-1 flex items-center gap-1",children:[c.jsx(n_,{size:10,strokeWidth:2.5}),i("workers.panel.section.claudeOutput",{n:f.length})]}),d.isLoading&&f.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.output.loading")}):f.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.output.empty")}):c.jsx("pre",{ref:g,onScroll:k=>{const v=k.currentTarget;m.current=v.scrollHeight-v.scrollTop-v.clientHeight<24},className:"text-xs font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-2 max-h-80 overflow-auto whitespace-pre-wrap break-words",children:f.map(k=>`${k.ts?`${k.ts} [${k.kind}] `:`[${k.kind}] `}${k.text}`).join(`
|
|
614
|
+
`).trim()}function $g(e){return Wy(e,"描述")}function H4({project:e,seq:t,onClose:n,onChanged:i}){var H,Q,G,L,z,V,B,le,ve,ke,Se;const a=Be(),l=Gt(),{confirm:o,alert:d}=un(),{data:f,isLoading:h,isError:g,error:m,refetch:y}=Ye({queryKey:["card",e,t],queryFn:()=>N4(e,t)}),[b,k]=j.useState(!1),[v,N]=j.useState(""),[E,C]=j.useState(""),[S,_]=j.useState(new Set),[M,T]=j.useState([]),[R,O]=j.useState(""),$=Ye({queryKey:["skills-all",e],queryFn:()=>ox(e),enabled:b}),q=((Q=(H=Ye({queryKey:["projects"],queryFn:Es,refetchInterval:1e4}).data)==null?void 0:H.data.find(J=>J.name===e))==null?void 0:Q.pipelineStatus)==="running";j.useEffect(()=>{b&&f&&(N(f.title),C($g(f.body)),_(new Set(f.skills)),T([...f.labels]))},[b,f]),j.useEffect(()=>{const J=ue=>{ue.key==="Escape"&&(b?k(!1):n())};return window.addEventListener("keydown",J),()=>window.removeEventListener("keydown",J)},[n,b]);const F=Ct({mutationFn:()=>{if(!f)throw new Error("no data");const J={},ue=v.trim();ue&&ue!==f.title&&(J.title=ue);const Te=$g(f.body);E!==Te&&(J.description=E);const Re=[...S].sort(),De=[...f.skills].sort();return JSON.stringify(Re)!==JSON.stringify(De)&&(J.skills=Re),JSON.stringify(M)!==JSON.stringify(f.labels)&&(J.labels=M),Object.keys(J).length===0?Promise.resolve({ok:!0,noop:!0}):M4(e,t,J)},onSuccess:()=>{l.invalidateQueries({queryKey:["card",e,t]}),l.invalidateQueries({queryKey:["cards",e]}),k(!1),i()},onError:J=>{d({title:a("cardModal.error.save.title"),body:J instanceof Error?J.message:String(J)})}}),Y=j.useMemo(()=>{if(!b||!f)return!1;if(v.trim()!==f.title||E!==$g(f.body))return!0;const J=[...S].sort(),ue=[...f.skills].sort();return JSON.stringify(J)!==JSON.stringify(ue)||JSON.stringify(M)!==JSON.stringify(f.labels)},[b,f,v,E,S,M]),D=J=>{const ue=new Set(S);ue.has(J)?ue.delete(J):ue.add(J),_(ue)},K=()=>{const J=R.trim();if(J){if(M.includes(J)){O("");return}T([...M,J]),O("")}},P=J=>{T(M.filter(ue=>ue!==J))};return c.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"card-modal-title",className:"fixed inset-0 z-40 flex items-start justify-center p-6 bg-black/30 overflow-auto",children:c.jsxs("div",{className:"nb-card mt-12 w-full max-w-3xl bg-[var(--color-bg)]",children:[c.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4",children:[c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),(f==null?void 0:f.state)&&c.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-full font-semibold",children:f.state}),b&&c.jsx("span",{className:"text-xs font-bold text-[var(--color-stuck)]",children:a("cardModal.editing")})]}),b?c.jsx("input",{type:"text",className:"nb-input w-full font-[family-name:var(--font-heading)] text-xl font-bold",value:v,onChange:J=>N(J.target.value),maxLength:200,"aria-label":a("cardModal.title.aria")}):c.jsx("h2",{id:"card-modal-title",className:"font-[family-name:var(--font-heading)] text-2xl font-bold break-words",children:(f==null?void 0:f.title)??a("common.loading")})]}),c.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[!b&&f&&c.jsxs("button",{onClick:()=>k(!0),className:"nb-btn",style:{padding:"6px 12px"},type:"button","aria-label":a("cardModal.editAria"),children:[c.jsx(qh,{size:12,strokeWidth:2.5})," ",a("cardModal.edit")]}),c.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2","aria-label":a("cardModal.close.aria"),type:"button",children:c.jsx(bn,{size:14,strokeWidth:3})})]})]}),h&&c.jsx("p",{className:"text-[var(--color-text-muted)]",children:a("common.loading")}),g&&c.jsx("p",{className:"text-[var(--color-crashed)]",children:a("cardModal.error.load",{detail:m instanceof Error?m.message:String(m)})}),f&&c.jsxs("div",{className:"flex flex-col gap-4",children:[f.branch&&!b&&c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(hL,{size:14}),c.jsx("span",{className:"font-[family-name:var(--font-mono)]",children:f.branch})]}),b?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Skills"}),$.isLoading&&c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:a("cardModal.skills.loading")}),$.data&&$.data.data.length>0&&c.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.data.data.map(J=>{const ue=S.has(J.name);return c.jsx("button",{type:"button",onClick:()=>D(J.name),"aria-pressed":ue,className:["px-2.5 py-1 text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",ue?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:J.name},J.name)})})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Labels"}),c.jsxs("div",{className:"flex flex-wrap gap-1.5 items-center",children:[M.map(J=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-[family-name:var(--font-mono)] bg-[var(--color-accent-yellow)] border-2 border-[var(--color-text)] rounded-full",children:[J,c.jsx("button",{type:"button",onClick:()=>P(J),className:"hover:text-[var(--color-crashed)]","aria-label":a("cardModal.label.removeAria",{label:J}),children:c.jsx(bn,{size:10,strokeWidth:3})})]},J)),c.jsx("input",{type:"text",className:"nb-input",style:{padding:"4px 8px",fontSize:12,width:140},placeholder:a("cardModal.label.addPlaceholder"),value:R,onChange:J=>O(J.target.value),onKeyDown:J=>{J.key==="Enter"&&!J.nativeEvent.isComposing&&(J.preventDefault(),K())}}),R&&c.jsx("button",{type:"button",className:"nb-btn",style:{padding:"2px 6px",fontSize:11},onClick:K,"aria-label":a("cardModal.label.addAria"),children:c.jsx(pi,{size:10,strokeWidth:3})})]}),c.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:a("cardModal.label.note")})]})]}):c.jsxs(c.Fragment,{children:[f.skills.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Skills"}),c.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:f.skills.map(J=>c.jsx(dx,{name:J},J))})]}),f.labels.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-bold mb-1.5",children:"Labels"}),c.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:f.labels.map(J=>c.jsx(x2,{label:J,kind:J==="NEEDS-FIX"?"warn":"default"},J))})]})]}),b?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.description")}),c.jsx("textarea",{className:"nb-input w-full font-[family-name:var(--font-mono)] text-xs",style:{minHeight:180,resize:"vertical"},value:E,onChange:J=>C(J.target.value),"aria-label":a("cardModal.body.aria")}),c.jsx("p",{className:"text-[10px] text-[var(--color-text-muted)] mt-1",children:a("cardModal.body.replaceNote")})]}),(((le=f.checklist)==null?void 0:le.total)??0)>0&&c.jsxs("div",{className:"nb-card bg-[var(--color-bg-cream)] p-3",children:[c.jsx("div",{className:"flex items-center justify-between mb-2",children:c.jsxs("span",{className:"font-bold text-sm",children:[a("cardModal.section.checklist")," ",((ve=f.checklist)==null?void 0:ve.done)??0,"/",((ke=f.checklist)==null?void 0:ke.total)??0]})}),c.jsx("ul",{className:"text-sm space-y-1",children:(((Se=f.checklist)==null?void 0:Se.items)??[]).map((J,ue)=>c.jsxs("li",{className:`flex items-start gap-2 ${J.done?"opacity-60 line-through":""}`,children:[c.jsx("span",{children:J.done?"✓":"○"}),c.jsx("span",{children:J.text})]},ue))})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.description")}),c.jsx("pre",{className:"text-xs whitespace-pre-wrap font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg p-4 max-h-64 overflow-auto",children:Wy(f.body,"描述")||a("cardModal.section.empty")})]}),c.jsxs("div",{children:[c.jsxs("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:[a("cardModal.section.checklist")," ",c.jsxs("span",{className:"text-[var(--color-text-muted)] normal-case tracking-normal",children:[((G=f.checklist)==null?void 0:G.done)??0,"/",((L=f.checklist)==null?void 0:L.total)??0]})]}),c.jsx("div",{className:"nb-card bg-[var(--color-bg-cream)] p-3",children:(((z=f.checklist)==null?void 0:z.total)??0)>0?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex items-center justify-end mb-2",children:c.jsx("div",{className:"w-24 h-2 bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded-full overflow-hidden",children:c.jsx("div",{className:"h-full bg-[var(--color-cta)]",style:{width:`${((V=f.checklist)==null?void 0:V.percent)??0}%`}})})}),c.jsx("ul",{className:"text-sm space-y-1",children:(((B=f.checklist)==null?void 0:B.items)??[]).map((J,ue)=>c.jsxs("li",{className:`flex items-start gap-2 ${J.done?"opacity-60 line-through":""}`,children:[c.jsx("span",{children:J.done?"✓":"○"}),c.jsx("span",{children:J.text})]},ue))})]}):c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:a("cardModal.checklist.empty")})})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-[family-name:var(--font-heading)] text-sm font-bold mb-2 uppercase tracking-wider",children:a("cardModal.section.log")}),c.jsx("pre",{className:"text-xs whitespace-pre-wrap font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded-lg p-4 max-h-64 overflow-auto",children:Wy(f.body,"日志")||a("cardModal.section.empty")})]})]}),c.jsx("div",{className:"flex gap-2 pt-2 border-t-2 border-[var(--color-border-light)] justify-end flex-wrap",children:b?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"nb-btn",type:"button",onClick:()=>{k(!1),y()},disabled:F.isPending,children:a("common.cancel")}),c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"button",onClick:()=>F.mutate(),disabled:!Y||!v.trim()||F.isPending,"aria-label":a("cardDetail.save"),children:[F.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(Rr,{size:14,strokeWidth:3}),a("common.save")]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"nb-btn nb-btn-primary",type:"button",disabled:f.state==="Done"||q,title:f.state==="Done"?a("cardModal.action.launch.disabledDone"):q?a("cardModal.action.launch.disabledRunning"):void 0,onClick:async()=>{try{await C4(e,t),i()}catch(J){d({title:a("cardModal.action.launch.error"),body:J instanceof Error?J.message:String(J)})}},children:[c.jsx(Yu,{size:14,strokeWidth:3}),a("cardModal.action.launch")]}),c.jsxs("button",{className:"nb-btn nb-btn-yellow",type:"button",onClick:async()=>{if(await o({title:a("cardModal.action.reset.confirm.title",{seq:t}),body:a("cardModal.action.reset.confirm.body"),confirm:a("cardModal.action.reset.confirm.button"),danger:!0}))try{await _4(e,t),i(),n()}catch(ue){d({title:a("cardModal.action.reset.error"),body:ue instanceof Error?ue.message:String(ue)})}},children:[c.jsx(Bb,{size:14,strokeWidth:2.5}),a("cardModal.action.reset")]}),c.jsxs("button",{className:"nb-btn",style:{background:"var(--color-crashed)",color:"var(--color-bg)"},type:"button",onClick:async()=>{if(!(!await o({title:a("cardModal.action.delete.confirm1.title",{seq:t}),body:a("cardModal.action.delete.confirm1.body",{title:f.title}),confirm:a("cardModal.action.delete.confirm1.button"),danger:!0})||!await o({title:a("cardModal.action.delete.confirm2.title"),body:a("cardModal.action.delete.confirm2.body",{seq:t}),confirm:a("cardModal.action.delete"),danger:!0})))try{await j4(e,t),i(),n()}catch(Te){d({title:a("projectDetail.pipelines.delete.error"),body:Te instanceof Error?Te.message:String(Te)})}},"aria-label":a("cardModal.action.delete"),children:[c.jsx(fr,{size:14,strokeWidth:2.5}),a("cardModal.action.delete")]})]})})]})]})})}function K4({current:e,onChange:t}){const[n,i]=j.useState(!1),a=j.useRef(null),{data:l}=Ye({queryKey:["projects"],queryFn:Es});return j.useEffect(()=>{const o=d=>{var f;(f=a.current)!=null&&f.contains(d.target)||i(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[]),c.jsxs("div",{className:"relative",ref:a,children:[c.jsxs("button",{type:"button",className:"nb-btn font-[family-name:var(--font-mono)] text-sm",onClick:()=>i(o=>!o),children:[e,c.jsx(Vu,{size:14,strokeWidth:2.5})]}),n&&l&&c.jsx("div",{className:"absolute right-0 mt-2 z-20 min-w-[200px] nb-card p-1 overflow-hidden",children:c.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:h_(l.data,"activity").map(o=>{const d=o.pipelineStatus==="running";return c.jsxs("button",{type:"button",onClick:()=>{t(o.name),i(!1)},className:["dimension-menu-item w-full text-left px-4 py-2 text-sm font-semibold flex items-center gap-2",o.name===e?"dimension-menu-item-active":""].join(" "),children:[d&&c.jsx(Yu,{size:12,strokeWidth:3,className:"text-[var(--color-running)] shrink-0","aria-label":"运行中"}),c.jsx("span",{className:"font-[family-name:var(--font-mono)]",children:o.name}),c.jsxs("span",{className:"ml-auto text-xs text-[var(--color-text-muted)]",children:[o.cards.total," cards"]})]},o.name)})})})]})}const G4=[{state:"Planning",labelKey:"board.col.planning",bg:"linear-gradient(180deg, rgba(139, 117, 255, 0.20), rgba(188, 166, 255, 0.075))",badgeVars:{"--skill-badge-lang-bg":"rgba(172, 153, 255, 0.30)","--skill-badge-end-bg":"rgba(151, 133, 239, 0.26)","--skill-badge-persona-bg":"rgba(193, 178, 255, 0.24)","--skill-badge-workflow-bg":"rgba(159, 146, 220, 0.27)","--skill-badge-other-bg":"rgba(126, 107, 206, 0.30)"}},{state:"Backlog",labelKey:"board.col.backlog",bg:"linear-gradient(180deg, rgba(147, 158, 190, 0.14), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(149, 160, 198, 0.24)","--skill-badge-end-bg":"rgba(128, 141, 176, 0.25)","--skill-badge-persona-bg":"rgba(165, 172, 199, 0.22)","--skill-badge-workflow-bg":"rgba(138, 152, 184, 0.26)","--skill-badge-other-bg":"rgba(116, 127, 158, 0.28)"}},{state:"Todo",labelKey:"board.col.todo",bg:"linear-gradient(180deg, rgba(239, 201, 126, 0.18), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(245, 207, 135, 0.28)","--skill-badge-end-bg":"rgba(226, 182, 101, 0.25)","--skill-badge-persona-bg":"rgba(249, 221, 159, 0.23)","--skill-badge-workflow-bg":"rgba(232, 193, 118, 0.27)","--skill-badge-other-bg":"rgba(204, 159, 84, 0.29)"}},{state:"Inprogress",labelKey:"board.col.inprogress",bg:"linear-gradient(180deg, rgba(98, 176, 242, 0.18), rgba(188, 166, 255, 0.065))",badgeVars:{"--skill-badge-lang-bg":"rgba(104, 181, 246, 0.28)","--skill-badge-end-bg":"rgba(79, 153, 223, 0.26)","--skill-badge-persona-bg":"rgba(136, 198, 250, 0.22)","--skill-badge-workflow-bg":"rgba(91, 166, 228, 0.27)","--skill-badge-other-bg":"rgba(67, 128, 197, 0.29)"}},{state:"QA",labelKey:"board.col.qa",bg:"linear-gradient(180deg, rgba(222, 171, 222, 0.18), rgba(188, 166, 255, 0.065))",badgeVars:{"--skill-badge-lang-bg":"rgba(226, 174, 226, 0.28)","--skill-badge-end-bg":"rgba(206, 145, 213, 0.25)","--skill-badge-persona-bg":"rgba(236, 197, 236, 0.22)","--skill-badge-workflow-bg":"rgba(215, 158, 218, 0.27)","--skill-badge-other-bg":"rgba(184, 125, 196, 0.29)"}},{state:"Done",labelKey:"board.col.done",bg:"linear-gradient(180deg, rgba(120, 214, 163, 0.18), rgba(188, 166, 255, 0.055))",badgeVars:{"--skill-badge-lang-bg":"rgba(125, 216, 166, 0.27)","--skill-badge-end-bg":"rgba(93, 190, 139, 0.25)","--skill-badge-persona-bg":"rgba(154, 226, 185, 0.22)","--skill-badge-workflow-bg":"rgba(107, 202, 150, 0.28)","--skill-badge-other-bg":"rgba(75, 166, 120, 0.29)"}}],v2="sps-console:last-board-project";function V4(){if(typeof window>"u")return null;try{return localStorage.getItem(v2)}catch{return null}}function Y4(e){if(!(typeof window>"u"))try{localStorage.setItem(v2,e)}catch{}}function Q4(){var P,H,Q;const e=Be(),[t,n]=UN(),i=t.get("project"),[a,l]=j.useState(null),[o,d]=j.useState(""),[f,h]=j.useState(()=>new Set),[g,m]=j.useState(()=>new Set),{confirm:y,alert:b}=un();O4(i);const k=Ye({queryKey:["projects"],queryFn:Es}),v=Ye({queryKey:["cards",i],queryFn:()=>S4(i??""),enabled:!!i,refetchInterval:3e3}),N=Gt(),E=()=>{N.invalidateQueries({queryKey:["cards",i]}),N.invalidateQueries({queryKey:["projects"]}),N.invalidateQueries({queryKey:["pipeline-status",i]})},C=G=>{n({project:G})};j.useEffect(()=>{var L;if(i){Y4(i);return}const G=V4();G&&((L=k.data)!=null&&L.data.some(z=>z.name===G))&&n({project:G},{replace:!0})},[i,k.data,n]);const S=Ct({mutationFn:()=>y2(i),onSuccess:()=>{E()},onError:G=>{b({title:e("board.action.startError"),body:G instanceof Error?G.message:String(G)})}}),_=Ct({mutationFn:()=>b2(i),onSuccess:()=>E(),onError:G=>{b({title:e("board.action.stopError"),body:G instanceof Error?G.message:String(G)})}}),M=Ct({mutationFn:()=>D4(i,{all:!0}),onSuccess:()=>E(),onError:G=>{b({title:e("board.action.resetError"),body:G instanceof Error?G.message:String(G)})}}),[T,R]=j.useState(!1),O=Ct({mutationFn:G=>A4(i,G),onSuccess:()=>{E(),R(!1)},onError:G=>{b({title:e("board.action.newCard.error"),body:G instanceof Error?G.message:String(G)})}}),$=Ct({mutationFn:({seq:G,state:L})=>T4(i,G,L),onMutate:async({seq:G,state:L})=>{await N.cancelQueries({queryKey:["cards",i]});const z=N.getQueryData(["cards",i]);return z&&N.setQueryData(["cards",i],{...z,data:z.data.map(V=>V.seq===G?{...V,state:L}:V)}),{prev:z}},onError:(G,L,z)=>{z!=null&&z.prev&&N.setQueryData(["cards",i],z.prev),b({title:e("board.action.moveCard.error"),body:G instanceof Error?G.message:String(G)})},onSettled:()=>{N.invalidateQueries({queryKey:["cards",i]})}}),I=((P=v.data)==null?void 0:P.data)??[],{allSkills:q,allLabels:F}=j.useMemo(()=>{const G=new Set,L=new Set;for(const z of I){for(const V of z.skills)G.add(V);for(const V of z.labels)L.add(V)}return{allSkills:[...G].sort(),allLabels:[...L].sort()}},[I]);if(!i)return c.jsxs("div",{className:"flex flex-col gap-6 w-full",children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold",children:e("board.title.bare")}),c.jsxs("div",{className:"nb-card bg-[var(--color-accent-yellow)] max-w-2xl",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-3",children:e("board.pickPrompt.title")}),c.jsx("p",{className:"text-sm mb-4 text-[var(--color-text-muted)]",children:e("board.pickPrompt.body")}),c.jsx("div",{className:"flex flex-wrap gap-2",children:(H=k.data)==null?void 0:H.data.map(G=>c.jsx("button",{className:"nb-btn nb-btn-blue",onClick:()=>C(G.name),type:"button",children:G.name},G.name))})]})]});const Y=I.filter(G=>{if(o){const L=o.toLowerCase();if(!(G.title.toLowerCase().includes(L)||G.skills.some(V=>V.toLowerCase().includes(L))||G.labels.some(V=>V.toLowerCase().includes(L))))return!1}return!(f.size>0&&!G.skills.some(z=>f.has(z))||g.size>0&&!G.labels.some(z=>g.has(z)))}),D=(Q=k.data)==null?void 0:Q.data.find(G=>G.name===i),K=(D==null?void 0:D.pipelineStatus)==="running";return c.jsxs("div",{className:"flex flex-col gap-4 max-w-full flex-1 min-h-0",children:[c.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3 shrink-0",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold tracking-tight",children:e("board.title")}),c.jsx("p",{className:"text-[var(--color-text-muted)] text-sm mt-1",children:D?e("board.subtitle",{name:D.name,cards:D.cards.total,workers:D.workers.active}):e("common.loading")})]}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[c.jsx(K4,{current:i,onChange:C}),c.jsxs("button",{className:K?"nb-btn nb-btn-danger":"nb-btn nb-btn-primary",onClick:()=>K?_.mutate():S.mutate(),disabled:S.isPending||_.isPending,type:"button","aria-label":e(K?"board.action.stopAria":"board.action.startAria"),title:e(K?"board.action.stopAria":"board.action.startAria"),children:[S.isPending||_.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):K?c.jsx(Ub,{size:14,strokeWidth:3}):c.jsx(Yu,{size:14,strokeWidth:3}),e(K?"board.action.stop":"board.action.start")]}),c.jsxs("button",{className:"nb-btn nb-btn-yellow",type:"button",onClick:async()=>{await y({title:e("board.action.reset.confirm.title"),body:e("board.action.reset.confirm.body"),confirm:e("board.action.reset.confirm.button"),danger:!0})&&M.mutate()},disabled:M.isPending,children:[M.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(Bb,{size:14,strokeWidth:2.5}),e("board.action.reset")]}),c.jsxs("button",{className:"nb-btn nb-btn-mint",type:"button",onClick:()=>R(!0),disabled:O.isPending,children:[O.isPending?c.jsx(Xe,{size:14,strokeWidth:3,className:"animate-spin"}):c.jsx(pi,{size:14,strokeWidth:3}),e("board.action.newCard")]})]})]}),c.jsxs("div",{className:"flex items-center gap-3 flex-wrap shrink-0",children:[c.jsxs("div",{className:"relative flex-1 max-w-md",children:[c.jsx(fl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),c.jsx("input",{className:"nb-input pl-9 w-full",placeholder:e("board.search.placeholder"),value:o,onChange:G=>d(G.target.value),"aria-label":e("board.search.aria")})]}),c.jsx(Ak,{label:"skill",options:q,selected:f,onChange:h}),c.jsx(Ak,{label:"label",options:F,selected:g,onChange:m}),(o||f.size>0||g.size>0)&&c.jsxs("button",{className:"nb-btn",style:{padding:"4px 10px",fontSize:11},onClick:()=>{d(""),h(new Set),m(new Set)},type:"button","aria-label":e("board.filter.clearAria"),children:[c.jsx(bn,{size:11,strokeWidth:3}),e("board.filter.clear")]}),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] flex items-center gap-1 font-[family-name:var(--font-mono)]",children:[c.jsx(dL,{size:12}),Y.length," / ",I.length]})]}),v.isError&&c.jsxs("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:[c.jsx("p",{className:"font-semibold",children:e("board.error.loadCards")}),c.jsx("p",{className:"text-sm mt-1 text-[var(--color-text-muted)]",children:v.error instanceof Error?v.error.message:String(v.error)})]}),!v.isError&&c.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 auto-rows-fr gap-3 flex-1 min-h-0",children:G4.map(G=>c.jsx(q4,{label:e(G.labelKey),bg:G.bg,badgeVars:G.badgeVars,cards:Y.filter(W4(G.state)),onCardClick:L=>l(L.seq),onDropCard:L=>$.mutate({seq:L,state:G.state})},G.state))}),a!==null&&c.jsx(H4,{project:i,seq:a,onClose:()=>l(null),onChanged:E}),T&&c.jsx(E4,{project:i,isPending:O.isPending,onCancel:()=>R(!1),onCreate:G=>O.mutate(G)})]})}function W4(e){return t=>e==="QA"?t.state==="QA"||t.state==="Review":e==="Done"?t.state==="Done"||t.state==="Canceled":t.state===e}function Ak({label:e,options:t,selected:n,onChange:i}){const a=Be(),[l,o]=j.useState(!1),d=j.useRef(null);j.useEffect(()=>{if(!l)return;const m=b=>{var k;(k=d.current)!=null&&k.contains(b.target)||o(!1)},y=b=>{b.key==="Escape"&&o(!1)};return window.addEventListener("click",m),window.addEventListener("keydown",y),()=>{window.removeEventListener("click",m),window.removeEventListener("keydown",y)}},[l]);const f=m=>{const y=new Set(n);y.has(m)?y.delete(m):y.add(m),i(y)},h=t.length===0,g=n.size;return c.jsxs("div",{ref:d,className:"relative",children:[c.jsxs("button",{type:"button",className:"nb-btn",style:{padding:"6px 12px",fontSize:12},onClick:()=>!h&&o(m=>!m),disabled:h,"aria-haspopup":"listbox","aria-expanded":l,"aria-label":a("board.filter.aria",{label:e}),children:[e,g>0&&c.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-[var(--color-primary)] text-[var(--color-text)] border border-[var(--color-text)]",children:g}),c.jsx(Vu,{size:11,strokeWidth:3,className:["transition-transform",l?"rotate-180":""].join(" ")})]}),l&&c.jsx("div",{className:"absolute left-0 top-full mt-2 z-20 min-w-[200px] nb-card p-2 overflow-hidden",style:{padding:8},children:c.jsxs("div",{role:"listbox",className:"max-h-64 overflow-auto",children:[t.map(m=>{const y=n.has(m);return c.jsxs("label",{className:["flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer text-sm font-[family-name:var(--font-mono)]",y?"bg-[var(--color-accent-mint)]":"hover:bg-[var(--color-bg-cream)]"].join(" "),children:[c.jsx("input",{type:"checkbox",checked:y,onChange:()=>f(m),className:"flex-shrink-0"}),c.jsx("span",{className:"truncate",children:m})]},m)}),g>0&&c.jsx("button",{type:"button",className:"w-full mt-2 pt-2 border-t-2 border-dashed border-[var(--color-text)] text-xs font-bold text-[var(--color-crashed)] text-center",onClick:()=>i(new Set),children:a("board.filter.clearSelection")})]})})]})}function X4(){return ft("/api/workers/all")}function Z4(e){return ft(`/api/projects/${encodeURIComponent(e)}/workers`)}function J4(e,t){return ft(`/api/projects/${encodeURIComponent(e)}/workers/${t}`)}async function w2(e,t){const n=await fetch(e,{method:"POST",headers:t?{"Content-Type":"application/json"}:void 0,body:t?JSON.stringify(t):void 0});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json().catch(()=>({}))}function Tk(e,t){return w2(`/api/projects/${encodeURIComponent(e)}/workers/${t}/kill`)}function eP(e,t,n){return w2(`/api/projects/${encodeURIComponent(e)}/workers/${t}/launch`,n?{seq:n}:void 0)}function fx({state:e}){const n={running:{bg:"var(--color-running-bg)",color:"var(--color-running)",label:"running"},starting:{bg:"var(--color-secondary)",color:"var(--color-text)",label:"starting",icon:c.jsx(Xe,{size:9,strokeWidth:3,className:"animate-spin"})},stuck:{bg:"var(--color-stuck-bg)",color:"var(--color-stuck)",label:"stuck"},crashed:{bg:"var(--color-crashed-bg)",color:"var(--color-crashed)",label:"crashed",icon:c.jsx(o3,{size:9,strokeWidth:2.5})},idle:{bg:"var(--color-idle-bg)",color:"var(--color-idle)",label:"idle"}}[e];return c.jsxs("span",{className:"nb-status inline-flex items-center gap-1",style:{background:n.bg,color:n.color},children:[n.icon,n.label]})}function hx(e){if(e==null||e<=0)return"—";const t=Math.floor(e/1e3),n=Math.floor(t/3600),i=Math.floor(t%3600/60),a=t%60;return n>0?`${n}h ${i}m`:i>0?`${i}m ${a}s`:`${a}s`}function tP(e){if(e==null||e<=0)return"text-[var(--color-text-muted)]";const t=e/6e4;return t<10?"text-[var(--color-running)]":t<60?"text-[var(--color-stuck)]":"text-[var(--color-crashed)]"}function px(e){const t=Date.now()-new Date(e).getTime();return t<6e4?`${Math.floor(t/1e3)}s 前`:t<36e5?`${Math.floor(t/6e4)}m 前`:`${Math.floor(t/36e5)}h 前`}function nP({alerts:e,selected:t,onSelect:n}){const i=Be();return e.length===0?c.jsxs("div",{className:"nb-card bg-[var(--color-running-bg)] flex items-center gap-3",children:[c.jsx(Eu,{size:18,strokeWidth:2.5,className:"text-[var(--color-running)]"}),c.jsx("span",{className:"text-sm font-bold text-[var(--color-running)]",children:i("workers.alerts.allHealthy")})]}):c.jsxs("section",{children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 flex items-center gap-2 text-[var(--color-crashed)]",children:[c.jsx(w3,{size:14,strokeWidth:2.5}),"Alerts (",e.length,")"]}),c.jsx("div",{className:"flex flex-col gap-2",children:e.map(a=>{const l=(t==null?void 0:t.project)===a.project&&(t==null?void 0:t.slot)===a.slot;return c.jsxs("button",{type:"button",onClick:()=>n(a.project,a.slot),className:["nb-card p-3 text-left",a.state==="crashed"?"bg-[var(--color-crashed-bg)]":"bg-[var(--color-stuck-bg)]",l?"ring-4 ring-[var(--color-text)]":""].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[c.jsx(fx,{state:a.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold",children:[a.project,"/worker-",a.slot]}),a.card&&c.jsxs("span",{className:"truncate",children:["#",a.card.seq," ",a.card.title]}),c.jsxs("span",{className:"ml-auto text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] flex items-center gap-1",children:[c.jsx(GN,{size:10,strokeWidth:2.5}),hx(a.runtimeMs)]})]}),a.markerUpdatedAt&&c.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-1 font-[family-name:var(--font-mono)]",children:a.state==="crashed"?i("workers.alerts.pidDead"):i("workers.alerts.markerStale",{ago:px(a.markerUpdatedAt)})})]},`${a.project}-${a.slot}`)})})]})}function iP({active:e,selected:t,onSelect:n}){const i=Be();return e.length===0?c.jsx("div",{className:"nb-card",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] italic",children:i("workers.active.empty")})}):c.jsxs("section",{children:[c.jsxs("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 flex items-center gap-2",children:[c.jsx($h,{size:14,strokeWidth:2.5}),"Active (",e.length,")"]}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:e.map(a=>{const l=(t==null?void 0:t.project)===a.project&&(t==null?void 0:t.slot)===a.slot;return c.jsxs("button",{type:"button",onClick:()=>n(a.project,a.slot),className:["nb-card p-3 text-left",a.state==="starting"?"bg-[var(--color-secondary)]":"bg-[var(--color-running-bg)]",l?"ring-4 ring-[var(--color-text)]":""].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(fx,{state:a.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-sm flex-1 truncate",children:[a.project,"/worker-",a.slot]}),c.jsx("span",{className:`text-xs font-[family-name:var(--font-mono)] ${tP(a.runtimeMs)}`,children:hx(a.runtimeMs)})]}),a.card&&c.jsxs("div",{className:"text-sm font-semibold mb-1 truncate",children:["#",a.card.seq," · ",a.card.title]}),c.jsxs("div",{className:"text-xs text-[var(--color-text-muted)] font-[family-name:var(--font-mono)] flex items-center gap-2 mb-1",children:[a.stage&&c.jsxs("span",{children:["stage: ",a.stage]}),a.markerUpdatedAt&&c.jsxs("span",{className:"ml-auto",children:["marker ",px(a.markerUpdatedAt)]})]}),a.lastLogLine&&c.jsxs("div",{className:"text-[11px] font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] bg-[var(--color-bg)] border-2 border-[var(--color-text)] rounded px-2 py-1 mt-2 truncate",children:[c.jsx(n_,{size:9,strokeWidth:2.5,className:"inline-block mr-1 align-text-bottom"}),a.lastLogLine.msg]})]},`${a.project}-${a.slot}`)})})]})}function rP({capacity:e,selected:t,onSelect:n}){const i=Be();return e.length===0?null:c.jsxs("section",{className:"flex flex-col min-h-0 flex-1",children:[c.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-sm font-bold uppercase tracking-wider mb-2 shrink-0",children:"Capacity"}),c.jsxs("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)] flex flex-col",children:[c.jsxs("table",{className:"w-full table-fixed text-sm shrink-0",children:[c.jsx(Mk,{}),c.jsx("thead",{children:c.jsxs("tr",{className:"border-b-2 border-[var(--color-border-light)] bg-[var(--color-bg-soft)]",children:[c.jsx("th",{className:"px-3 py-2 text-left font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.project")}),c.jsx("th",{className:"px-3 py-2 text-left font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.usage")}),c.jsx("th",{className:"px-3 py-2 text-right font-bold text-xs uppercase tracking-wider",children:"running"}),c.jsx("th",{className:"px-3 py-2 text-right font-bold text-xs uppercase tracking-wider",children:i("workers.capacity.col.other")}),c.jsx("th",{className:"px-3 py-2"})]})})]}),c.jsx("div",{className:"bg-color-bg-soft scroll-frame-body flex-1",children:c.jsxs("table",{className:"w-full table-fixed text-sm",children:[c.jsx(Mk,{}),c.jsx("tbody",{children:e.map(a=>c.jsx(aP,{capacity:a,selected:(t==null?void 0:t.project)===a.project,onSelect:()=>n(a.project)},a.project))})]})})]})]})}function Mk(){return c.jsxs("colgroup",{children:[c.jsx("col",{className:"w-[24%]"}),c.jsx("col",{className:"w-[28%]"}),c.jsx("col",{className:"w-[16%]"}),c.jsx("col",{className:"w-[20%]"}),c.jsx("col",{className:"w-[12%]"})]})}function aP({capacity:e,selected:t,onSelect:n}){const i=Be(),a=e.running+e.starting+e.stuck+e.crashed;return c.jsxs("tr",{onClick:n,className:["border-b border-dashed border-[var(--color-border-light)] last:border-0 cursor-pointer hover:bg-[var(--color-accent-yellow)]",t?"bg-[var(--color-accent-yellow)]":""].join(" "),children:[c.jsx("td",{className:"px-3 py-2 font-[family-name:var(--font-mono)] font-bold",children:e.project}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(sP,{total:e.total,cap:e})}),c.jsxs("td",{className:"px-3 py-2 text-right font-[family-name:var(--font-mono)]",children:[c.jsx("span",{className:"text-[var(--color-running)] font-bold",children:e.running}),c.jsxs("span",{className:"text-[var(--color-text-muted)]",children:["/",e.total]})]}),c.jsxs("td",{className:"px-3 py-2 text-right text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)]",children:[e.starting>0&&c.jsxs("span",{className:"mr-2",children:["starting ",e.starting]}),e.stuck>0&&c.jsxs("span",{className:"text-[var(--color-stuck)] font-bold mr-2",children:["stuck ",e.stuck]}),e.crashed>0&&c.jsxs("span",{className:"text-[var(--color-crashed)] font-bold mr-2",children:["crashed ",e.crashed]}),a===0&&c.jsx("span",{children:"idle"})]}),c.jsx("td",{className:"px-3 py-2 text-right",children:c.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:i("workers.capacity.detailHint")})})]})}function sP({total:e,cap:t}){const n=[];for(let i=0;i<t.crashed;i++)n.push("crashed");for(let i=0;i<t.stuck;i++)n.push("stuck");for(let i=0;i<t.starting;i++)n.push("starting");for(let i=0;i<t.running;i++)n.push("running");for(let i=0;i<t.idle;i++)n.push("idle");return c.jsxs("div",{className:"flex gap-1 items-center",children:[n.map((i,a)=>c.jsx("span",{className:"inline-block w-3 h-3 rounded-full border-2 border-[var(--color-text)]",style:{background:lP(i)},title:i},a)),c.jsxs("span",{className:"text-xs text-[var(--color-text-muted)] ml-2 font-[family-name:var(--font-mono)]",children:[e," slot",e!==1?"s":""]})]})}function lP(e){switch(e){case"running":return"var(--color-running-bg)";case"starting":return"var(--color-secondary)";case"stuck":return"var(--color-stuck-bg)";case"crashed":return"var(--color-crashed-bg)";default:return"var(--color-idle-bg)"}}function oP({project:e,initialSlot:t,onChange:n}){var h;const i=Be(),a=Ye({queryKey:["workers",e],queryFn:()=>Z4(e),refetchInterval:3e3}),l=((h=a.data)==null?void 0:h.data)??[],[o,d]=j.useState(null);j.useEffect(()=>{if(l.length===0){d(null);return}const g=l[0].slot;d(m=>m!=null&&l.some(y=>y.slot===m)?m:t!=null&&l.some(y=>y.slot===t)?t:g)},[e,t,l.length]);const f=l.find(g=>g.slot===o)??null;return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"px-4 bg-color-bg-soft py-3 border-b-2 border-[var(--color-text)] bg-[var(--color-bg-cream)]",children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx("span",{className:"font-[family-name:var(--font-mono)] font-bold truncate",children:e}),c.jsx(vs,{to:`/board?project=${encodeURIComponent(e)}`,className:"text-xs underline text-[var(--color-text-muted)] hover:text-[var(--color-text)]",children:i("workers.panel.boardLink")})]}),a.isLoading&&l.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.loading")}):l.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.empty.slots")}):c.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(g=>c.jsx(cP,{worker:g,active:g.slot===o,onClick:()=>d(g.slot)},g.slot))})]}),f?c.jsx(uP,{project:e,worker:f,onChange:n}):c.jsx("div",{className:"flex-1 flex items-center justify-center p-6 text-center",children:c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:l.length===0?i("workers.panel.empty.noWorker"):i("workers.panel.empty.pickOne")})})]})}function cP({worker:e,active:t,onClick:n}){const i=Be();return c.jsxs("button",{type:"button",onClick:n,className:["nb-card p-2 text-left min-w-[130px] transition-transform",t?"ring-4 ring-[var(--color-text)]":"opacity-80 hover:opacity-100"].join(" "),children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx(fx,{state:e.state}),c.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs",children:["worker-",e.slot]})]}),e.card?c.jsxs("div",{className:"text-[11px] truncate font-[family-name:var(--font-mono)]",children:["#",e.card.seq," ",e.card.title]}):c.jsx("div",{className:"text-[11px] text-[var(--color-text-muted)] italic",children:i("workers.panel.idle.short")})]})}function uP({project:e,worker:t,onChange:n}){var y,b;const i=Be(),{confirm:a,alert:l}=un(),o=t.state==="crashed"||t.state==="stuck",d=Ye({queryKey:["worker-detail",e,t.slot],queryFn:()=>J4(e,t.slot),refetchInterval:3e3}),f=((y=d.data)==null?void 0:y.recentOutput)??[],h=((b=d.data)==null?void 0:b.recentLogs)??[],g=j.useRef(null),m=j.useRef(!0);return j.useEffect(()=>{const k=g.current;k&&m.current&&(k.scrollTop=k.scrollHeight)},[f]),c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex-1 overflow-auto p-4 flex flex-col gap-4",children:[t.card?c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-[var(--color-text-muted)] mb-1",children:i("workers.panel.section.currentCard")}),c.jsxs("div",{className:"text-sm font-semibold break-words",children:["#",t.card.seq," · ",t.card.title]})]}):c.jsx("div",{className:"text-sm text-[var(--color-text-muted)] italic",children:i("workers.panel.idle.full")}),c.jsxs("dl",{className:"grid grid-cols-[100px_1fr] gap-y-2 text-sm",children:[c.jsx("dt",{className:"font-bold",children:"Stage"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.stage??"—"}),c.jsx("dt",{className:"font-bold",children:"PID"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:t.pid??"—"}),c.jsx("dt",{className:"font-bold",children:"Runtime"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)]",children:hx(t.runtimeMs)}),c.jsx("dt",{className:"font-bold",children:"Started"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)] text-xs",children:t.startedAt?new Date(t.startedAt).toLocaleString():"—"}),c.jsx("dt",{className:"font-bold",children:"Marker"}),c.jsx("dd",{className:"font-[family-name:var(--font-mono)] text-xs",children:t.markerUpdatedAt?px(t.markerUpdatedAt):"—"})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"text-xs font-bold uppercase tracking-wider text-[var(--color-text-muted)] mb-1 flex items-center gap-1",children:[c.jsx(n_,{size:10,strokeWidth:2.5}),i("workers.panel.section.claudeOutput",{n:f.length})]}),d.isLoading&&f.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.output.loading")}):f.length===0?c.jsx("p",{className:"text-xs text-[var(--color-text-muted)] italic",children:i("workers.panel.output.empty")}):c.jsx("pre",{ref:g,onScroll:k=>{const v=k.currentTarget;m.current=v.scrollHeight-v.scrollTop-v.clientHeight<24},className:"text-xs font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-2 max-h-80 overflow-auto whitespace-pre-wrap break-words",children:f.map(k=>`${k.ts?`${k.ts} [${k.kind}] `:`[${k.kind}] `}${k.text}`).join(`
|
|
615
615
|
`)})]}),h.length>0&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-bold uppercase tracking-wider text-[var(--color-text-muted)] mb-1 opacity-60",children:i("workers.panel.section.heartbeat",{n:h.length})}),c.jsx("pre",{className:"text-xs font-[family-name:var(--font-mono)] bg-[var(--color-bg-cream)] border-2 border-[var(--color-text)] rounded p-2 max-h-40 overflow-auto whitespace-pre-wrap break-words opacity-80",children:h.map(k=>`${k.ts??""} [${k.level}] ${k.msg}`).join(`
|
|
616
616
|
`)}),c.jsx(vs,{to:`/projects/${encodeURIComponent(e)}?tab=logs&worker=${t.slot}`,className:"text-xs underline text-[var(--color-running)] mt-1 inline-block",children:i("workers.panel.heartbeat.fullLog")})]})]}),c.jsxs("div",{className:"px-4 py-3 border-t-2 border-[var(--color-text)] bg-[var(--color-bg-cream)] flex gap-2 justify-end flex-wrap",children:[o&&t.card&&c.jsxs("button",{type:"button",className:"nb-btn nb-btn-mint",style:{padding:"4px 10px",fontSize:11},onClick:async()=>{if(await a({title:i("workers.panel.action.restart.confirm.title",{slot:t.slot}),body:i("workers.panel.action.restart.confirm.body",{seq:t.card.seq}),confirm:i("workers.panel.action.restart.confirm.button")})){try{await Tk(e,t.slot)}catch{}try{await eP(e,t.slot,t.card.seq),n()}catch(v){l({title:i("workers.panel.action.restart.error"),body:v instanceof Error?v.message:String(v)})}}},children:[c.jsx(g3,{size:11,strokeWidth:2.5})," ",i("workers.panel.action.restart")]}),t.state!=="idle"&&c.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",style:{padding:"4px 10px",fontSize:11},onClick:async()=>{if(await a({title:i("workers.panel.action.kill.confirm.title",{slot:t.slot}),body:i("workers.panel.action.kill.confirm.body"),confirm:i("workers.panel.action.kill.confirm.button"),danger:!0}))try{await Tk(e,t.slot),n()}catch(v){l({title:i("workers.panel.action.kill.error"),body:v instanceof Error?v.message:String(v)})}},children:[c.jsx(C3,{size:11,strokeWidth:2.5})," ",i("workers.panel.action.kill")]})]})]})}function dP(){var o;const e=Be(),t=Gt(),[n,i]=j.useState(null),a=Ye({queryKey:["workers-agg"],queryFn:X4,refetchInterval:5e3});j.useEffect(()=>{if(!a.data)return;const d=a.data.capacity.map(h=>h.project),f=[];for(const h of d){const g=new EventSource(`/stream/projects/${encodeURIComponent(h)}`),m=()=>{t.invalidateQueries({queryKey:["workers-agg"]})};g.addEventListener("worker.updated",m),g.addEventListener("worker.added",m),g.addEventListener("worker.deleted",m),g.addEventListener("card.updated",m),f.push(g)}return()=>{for(const h of f)h.close()}},[(o=a.data)==null?void 0:o.capacity.map(d=>d.project).join(","),t]);const l=j.useMemo(()=>{if(!a.data)return{projects:0,running:0,starting:0,stuck:0,crashed:0,idle:0};const d={projects:a.data.capacity.length,running:0,starting:0,stuck:0,crashed:0,idle:0};for(const f of a.data.capacity)d.running+=f.running,d.starting+=f.starting,d.stuck+=f.stuck,d.crashed+=f.crashed,d.idle+=f.idle;return d},[a.data]);return c.jsxs("div",{className:"flex flex-col gap-4 h-[calc(100vh-140px)]",children:[c.jsxs("header",{className:"flex items-center justify-between flex-wrap gap-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold tracking-tight",children:e("workers.title")}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mt-1",children:e("workers.summary",{projects:l.projects,running:l.running,starting:l.starting,stuck:l.stuck,crashed:l.crashed,idle:l.idle})})]}),c.jsxs("button",{className:"nb-btn",style:{padding:"6px 12px",fontSize:12},onClick:()=>a.refetch(),disabled:a.isFetching,type:"button","aria-label":e("workers.refresh.aria"),children:[a.isFetching?c.jsx(Xe,{size:12,strokeWidth:3,className:"animate-spin"}):c.jsx(ya,{size:12,strokeWidth:2.5}),e("workers.refresh")]})]}),c.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4 flex-1 min-h-0",children:[c.jsxs("div",{className:"flex flex-col gap-4 min-h-0 pr-2",children:[a.isLoading&&c.jsx("p",{className:"text-[var(--color-text-muted)] italic",children:e("common.loading")}),a.isError&&c.jsx("div",{className:"nb-card bg-[var(--color-crashed-bg)]",children:c.jsx("p",{children:e("workers.error.load",{detail:a.error instanceof Error?a.error.message:String(a.error)})})}),a.data&&c.jsxs(c.Fragment,{children:[c.jsx(nP,{alerts:a.data.alerts,selected:n,onSelect:(d,f)=>i({project:d,slot:f})}),c.jsx(iP,{active:a.data.active,selected:n,onSelect:(d,f)=>i({project:d,slot:f})}),c.jsx(rP,{capacity:a.data.capacity,selected:n,onSelect:d=>i({project:d})})]})]}),c.jsx("aside",{className:"nb-card p-0 overflow-hidden flex flex-col h-full",children:n?c.jsx(oP,{project:n.project,initialSlot:n.slot,onChange:()=>t.invalidateQueries({queryKey:["workers-agg"]})}):c.jsx("div",{className:"flex-1 bg-color-bg-soft bg-surface-input flex items-center justify-center p-6 text-center",children:c.jsxs("div",{children:[c.jsx($h,{size:32,className:"mx-auto mb-3 text-[var(--color-text-subtle)]",strokeWidth:2}),c.jsx("p",{className:"text-sm text-[var(--color-text-muted)]",children:e("workers.empty.hint")})]})})})]})]})}function k2(){return ft("/api/gen/jobs")}function fP(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const hP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,mP={};function Dk(e,t){return(mP.jsx?pP:hP).test(e)}const gP=/[ \t\n\f\r]/g;function yP(e){return typeof e=="object"?e.type==="text"?Ok(e.value):!1:Ok(e)}function Ok(e){return e.replace(gP,"")===""}class Zu{constructor(t,n,i){this.normal=n,this.property=t,i&&(this.space=i)}}Zu.prototype.normal={};Zu.prototype.property={};Zu.prototype.space=void 0;function E2(e,t){const n={},i={};for(const a of e)Object.assign(n,a.property),Object.assign(i,a.normal);return new Zu(n,i,t)}function Xy(e){return e.toLowerCase()}class mi{constructor(t,n){this.attribute=n,this.property=t}}mi.prototype.attribute="";mi.prototype.booleanish=!1;mi.prototype.boolean=!1;mi.prototype.commaOrSpaceSeparated=!1;mi.prototype.commaSeparated=!1;mi.prototype.defined=!1;mi.prototype.mustUseProperty=!1;mi.prototype.number=!1;mi.prototype.overloadedBoolean=!1;mi.prototype.property="";mi.prototype.spaceSeparated=!1;mi.prototype.space=void 0;let bP=0;const dt=El(),Sn=El(),Zy=El(),je=El(),Yt=El(),So=El(),Ei=El();function El(){return 2**++bP}const Jy=Object.freeze(Object.defineProperty({__proto__:null,boolean:dt,booleanish:Sn,commaOrSpaceSeparated:Ei,commaSeparated:So,number:je,overloadedBoolean:Zy,spaceSeparated:Yt},Symbol.toStringTag,{value:"Module"})),Ug=Object.keys(Jy);class mx extends mi{constructor(t,n,i,a){let l=-1;if(super(t,n),Rk(this,"space",a),typeof i=="number")for(;++l<Ug.length;){const o=Ug[l];Rk(this,Ug[l],(i&Jy[o])===Jy[o])}}}mx.prototype.defined=!0;function Rk(e,t,n){n&&(e[t]=n)}function sc(e){const t={},n={};for(const[i,a]of Object.entries(e.properties)){const l=new mx(i,e.transform(e.attributes||{},i),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(l.mustUseProperty=!0),t[i]=l,n[Xy(i)]=i,n[Xy(l.attribute)]=i}return new Zu(t,n,e.space)}const S2=sc({properties:{ariaActiveDescendant:null,ariaAtomic:Sn,ariaAutoComplete:null,ariaBusy:Sn,ariaChecked:Sn,ariaColCount:je,ariaColIndex:je,ariaColSpan:je,ariaControls:Yt,ariaCurrent:null,ariaDescribedBy:Yt,ariaDetails:null,ariaDisabled:Sn,ariaDropEffect:Yt,ariaErrorMessage:null,ariaExpanded:Sn,ariaFlowTo:Yt,ariaGrabbed:Sn,ariaHasPopup:null,ariaHidden:Sn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Yt,ariaLevel:je,ariaLive:null,ariaModal:Sn,ariaMultiLine:Sn,ariaMultiSelectable:Sn,ariaOrientation:null,ariaOwns:Yt,ariaPlaceholder:null,ariaPosInSet:je,ariaPressed:Sn,ariaReadOnly:Sn,ariaRelevant:null,ariaRequired:Sn,ariaRoleDescription:Yt,ariaRowCount:je,ariaRowIndex:je,ariaRowSpan:je,ariaSelected:Sn,ariaSetSize:je,ariaSort:null,ariaValueMax:je,ariaValueMin:je,ariaValueNow:je,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function N2(e,t){return t in e?e[t]:t}function _2(e,t){return N2(e,t.toLowerCase())}const xP=sc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:So,acceptCharset:Yt,accessKey:Yt,action:null,allow:null,allowFullScreen:dt,allowPaymentRequest:dt,allowUserMedia:dt,alt:null,as:null,async:dt,autoCapitalize:null,autoComplete:Yt,autoFocus:dt,autoPlay:dt,blocking:Yt,capture:null,charSet:null,checked:dt,cite:null,className:Yt,cols:je,colSpan:null,content:null,contentEditable:Sn,controls:dt,controlsList:Yt,coords:je|So,crossOrigin:null,data:null,dateTime:null,decoding:null,default:dt,defer:dt,dir:null,dirName:null,disabled:dt,download:Zy,draggable:Sn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:dt,formTarget:null,headers:Yt,height:je,hidden:Zy,high:je,href:null,hrefLang:null,htmlFor:Yt,httpEquiv:Yt,id:null,imageSizes:null,imageSrcSet:null,inert:dt,inputMode:null,integrity:null,is:null,isMap:dt,itemId:null,itemProp:Yt,itemRef:Yt,itemScope:dt,itemType:Yt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:dt,low:je,manifest:null,max:null,maxLength:je,media:null,method:null,min:null,minLength:je,multiple:dt,muted:dt,name:null,nonce:null,noModule:dt,noValidate:dt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:dt,optimum:je,pattern:null,ping:Yt,placeholder:null,playsInline:dt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:dt,referrerPolicy:null,rel:Yt,required:dt,reversed:dt,rows:je,rowSpan:je,sandbox:Yt,scope:null,scoped:dt,seamless:dt,selected:dt,shadowRootClonable:dt,shadowRootDelegatesFocus:dt,shadowRootMode:null,shape:null,size:je,sizes:null,slot:null,span:je,spellCheck:Sn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:je,step:null,style:null,tabIndex:je,target:null,title:null,translate:null,type:null,typeMustMatch:dt,useMap:null,value:Sn,width:je,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Yt,axis:null,background:null,bgColor:null,border:je,borderColor:null,bottomMargin:je,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:dt,declare:dt,event:null,face:null,frame:null,frameBorder:null,hSpace:je,leftMargin:je,link:null,longDesc:null,lowSrc:null,marginHeight:je,marginWidth:je,noResize:dt,noHref:dt,noShade:dt,noWrap:dt,object:null,profile:null,prompt:null,rev:null,rightMargin:je,rules:null,scheme:null,scrolling:Sn,standby:null,summary:null,text:null,topMargin:je,valueType:null,version:null,vAlign:null,vLink:null,vSpace:je,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:dt,disableRemotePlayback:dt,prefix:null,property:null,results:je,security:null,unselectable:null},space:"html",transform:_2}),vP=sc({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Ei,accentHeight:je,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:je,amplitude:je,arabicForm:null,ascent:je,attributeName:null,attributeType:null,azimuth:je,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:je,by:null,calcMode:null,capHeight:je,className:Yt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:je,diffuseConstant:je,direction:null,display:null,dur:null,divisor:je,dominantBaseline:null,download:dt,dx:null,dy:null,edgeMode:null,editable:null,elevation:je,enableBackground:null,end:null,event:null,exponent:je,externalResourcesRequired:null,fill:null,fillOpacity:je,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:So,g2:So,glyphName:So,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:je,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:je,horizOriginX:je,horizOriginY:je,id:null,ideographic:je,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:je,k:je,k1:je,k2:je,k3:je,k4:je,kernelMatrix:Ei,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:je,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:je,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:je,overlineThickness:je,paintOrder:null,panose1:null,path:null,pathLength:je,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Yt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:je,pointsAtY:je,pointsAtZ:je,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ei,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ei,rev:Ei,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ei,requiredFeatures:Ei,requiredFonts:Ei,requiredFormats:Ei,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:je,specularExponent:je,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:je,strikethroughThickness:je,string:null,stroke:null,strokeDashArray:Ei,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:je,strokeOpacity:je,strokeWidth:null,style:null,surfaceScale:je,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ei,tabIndex:je,tableValues:null,target:null,targetX:je,targetY:je,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ei,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:je,underlineThickness:je,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:je,values:null,vAlphabetic:je,vMathematical:je,vectorEffect:null,vHanging:je,vIdeographic:je,version:null,vertAdvY:je,vertOriginX:je,vertOriginY:je,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:je,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:N2}),j2=sc({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),C2=sc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:_2}),A2=sc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),wP={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},kP=/[A-Z]/g,Lk=/-[a-z]/g,EP=/^data[-\w.:]+$/i;function SP(e,t){const n=Xy(t);let i=t,a=mi;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&EP.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Lk,_P);i="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Lk.test(l)){let o=l.replace(kP,NP);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=mx}return new a(i,t)}function NP(e){return"-"+e.toLowerCase()}function _P(e){return e.charAt(1).toUpperCase()}const jP=E2([S2,xP,j2,C2,A2],"html"),gx=E2([S2,vP,j2,C2,A2],"svg");function CP(e){return e.join(" ").trim()}var oo={},Fg,Ik;function AP(){if(Ik)return Fg;Ik=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,d=/^\s+|\s+$/g,f=`
|
|
617
617
|
`,h="/",g="*",m="",y="comment",b="declaration";function k(N,E){if(typeof N!="string")throw new TypeError("First argument must be a string");if(!N)return[];E=E||{};var C=1,S=1;function _(D){var K=D.match(t);K&&(C+=K.length);var P=D.lastIndexOf(f);S=~P?D.length-P:S+D.length}function M(){var D={line:C,column:S};return function(K){return K.position=new T(D),$(),K}}function T(D){this.start=D,this.end={line:C,column:S},this.source=E.source}T.prototype.content=N;function R(D){var K=new Error(E.source+":"+C+":"+S+": "+D);if(K.reason=D,K.filename=E.source,K.line=C,K.column=S,K.source=N,!E.silent)throw K}function O(D){var K=D.exec(N);if(K){var P=K[0];return _(P),N=N.slice(P.length),K}}function $(){O(n)}function I(D){var K;for(D=D||[];K=q();)K!==!1&&D.push(K);return D}function q(){var D=M();if(!(h!=N.charAt(0)||g!=N.charAt(1))){for(var K=2;m!=N.charAt(K)&&(g!=N.charAt(K)||h!=N.charAt(K+1));)++K;if(K+=2,m===N.charAt(K-1))return R("End of comment missing");var P=N.slice(2,K-2);return S+=2,_(P),N=N.slice(K),S+=2,D({type:y,comment:P})}}function F(){var D=M(),K=O(i);if(K){if(q(),!O(a))return R("property missing ':'");var P=O(l),H=D({type:b,property:v(K[0].replace(e,m)),value:P?v(P[0].replace(e,m)):m});return O(o),H}}function Y(){var D=[];I(D);for(var K;K=F();)K!==!1&&(D.push(K),I(D));return D}return $(),Y()}function v(N){return N?N.replace(d,m):m}return Fg=k,Fg}var zk;function TP(){if(zk)return oo;zk=1;var e=oo&&oo.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(oo,"__esModule",{value:!0}),oo.default=n;const t=e(AP());function n(i,a){let l=null;if(!i||typeof i!="string")return l;const o=(0,t.default)(i),d=typeof a=="function";return o.forEach(f=>{if(f.type!=="declaration")return;const{property:h,value:g}=f;d?a(h,g,f):g&&(l=l||{},l[h]=g)}),l}return oo}var tu={},Pk;function MP(){if(Pk)return tu;Pk=1,Object.defineProperty(tu,"__esModule",{value:!0}),tu.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},o=function(h,g){return g.toUpperCase()},d=function(h,g){return"".concat(g,"-")},f=function(h,g){return g===void 0&&(g={}),l(h)?h:(h=h.toLowerCase(),g.reactCompat?h=h.replace(a,d):h=h.replace(i,d),h.replace(t,o))};return tu.camelCase=f,tu}var nu,Bk;function DP(){if(Bk)return nu;Bk=1;var e=nu&&nu.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(TP()),n=MP();function i(a,l){var o={};return!a||typeof a!="string"||(0,t.default)(a,function(d,f){d&&f&&(o[(0,n.camelCase)(d,l)]=f)}),o}return i.default=i,nu=i,nu}var OP=DP();const RP=qu(OP),T2=M2("end"),yx=M2("start");function M2(e){return t;function t(n){const i=n&&n.position&&n.position[e]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function LP(e){const t=yx(e),n=T2(e);if(t&&n)return{start:t,end:n}}function hu(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?$k(e.position):"start"in e||"end"in e?$k(e):"line"in e||"column"in e?eb(e):""}function eb(e){return Uk(e&&e.line)+":"+Uk(e&&e.column)}function $k(e){return eb(e&&e.start)+"-"+eb(e&&e.end)}function Uk(e){return e&&typeof e=="number"?e:1}class Yn extends Error{constructor(t,n,i){super(),typeof n=="string"&&(i=n,n=void 0);let a="",l={},o=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?a=t:!l.cause&&t&&(o=!0,a=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?l.ruleId=i:(l.source=i.slice(0,f),l.ruleId=i.slice(f+1))}if(!l.place&&l.ancestors&&l.ancestors){const f=l.ancestors[l.ancestors.length-1];f&&(l.place=f.position)}const d=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=d?d.line:void 0,this.name=hu(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=o&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Yn.prototype.file="";Yn.prototype.name="";Yn.prototype.reason="";Yn.prototype.message="";Yn.prototype.stack="";Yn.prototype.column=void 0;Yn.prototype.line=void 0;Yn.prototype.ancestors=void 0;Yn.prototype.cause=void 0;Yn.prototype.fatal=void 0;Yn.prototype.place=void 0;Yn.prototype.ruleId=void 0;Yn.prototype.source=void 0;const bx={}.hasOwnProperty,IP=new Map,zP=/[A-Z]/g,PP=new Set(["table","tbody","thead","tfoot","tr"]),BP=new Set(["td","th"]),D2="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function $P(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=YP(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=VP(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?gx:jP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=O2(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function O2(e,t,n){if(t.type==="element")return UP(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return FP(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return HP(e,t,n);if(t.type==="mdxjsEsm")return qP(e,t);if(t.type==="root")return KP(e,t,n);if(t.type==="text")return GP(e,t)}function UP(e,t,n){const i=e.schema;let a=i;t.tagName.toLowerCase()==="svg"&&i.space==="html"&&(a=gx,e.schema=a),e.ancestors.push(t);const l=L2(e,t.tagName,!1),o=QP(e,t);let d=vx(e,t);return PP.has(t.tagName)&&(d=d.filter(function(f){return typeof f=="string"?!yP(f):!0})),R2(e,o,l,t),xx(o,d),e.ancestors.pop(),e.schema=i,e.create(t,l,o,n)}function FP(e,t){if(t.data&&t.data.estree&&e.evaluater){const i=t.data.estree.body[0];return i.type,e.evaluater.evaluateExpression(i.expression)}ju(e,t.position)}function qP(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ju(e,t.position)}function HP(e,t,n){const i=e.schema;let a=i;t.name==="svg"&&i.space==="html"&&(a=gx,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:L2(e,t.name,!0),o=WP(e,t),d=vx(e,t);return R2(e,o,l,t),xx(o,d),e.ancestors.pop(),e.schema=i,e.create(t,l,o,n)}function KP(e,t,n){const i={};return xx(i,vx(e,t)),e.create(t,e.Fragment,i,n)}function GP(e,t){return t.value}function R2(e,t,n,i){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=i)}function xx(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function VP(e,t,n){return i;function i(a,l,o,d){const h=Array.isArray(o.children)?n:t;return d?h(l,o,d):h(l,o)}}function YP(e,t){return n;function n(i,a,l,o){const d=Array.isArray(l.children),f=yx(i);return t(a,l,o,d,{columnNumber:f?f.column-1:void 0,fileName:e,lineNumber:f?f.line:void 0},void 0)}}function QP(e,t){const n={};let i,a;for(a in t.properties)if(a!=="children"&&bx.call(t.properties,a)){const l=XP(e,a,t.properties[a]);if(l){const[o,d]=l;e.tableCellAlignToStyle&&o==="align"&&typeof d=="string"&&BP.has(t.tagName)?i=d:n[o]=d}}if(i){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return n}function WP(e,t){const n={};for(const i of t.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&e.evaluater){const l=i.data.estree.body[0];l.type;const o=l.expression;o.type;const d=o.properties[0];d.type,Object.assign(n,e.evaluater.evaluateExpression(d.argument))}else ju(e,t.position);else{const a=i.name;let l;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&e.evaluater){const d=i.value.data.estree.body[0];d.type,l=e.evaluater.evaluateExpression(d.expression)}else ju(e,t.position);else l=i.value===null?!0:i.value;n[a]=l}return n}function vx(e,t){const n=[];let i=-1;const a=e.passKeys?new Map:IP;for(;++i<t.children.length;){const l=t.children[i];let o;if(e.passKeys){const f=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(f){const h=a.get(f)||0;o=f+"-"+h,a.set(f,h+1)}}const d=O2(e,l,o);d!==void 0&&n.push(d)}return n}function XP(e,t,n){const i=SP(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?fP(n):CP(n)),i.property==="style"){let a=typeof n=="object"?n:ZP(e,String(n));return e.stylePropertyNameCase==="css"&&(a=JP(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&i.space?wP[i.property]||i.property:i.attribute,n]}}function ZP(e,t){try{return RP(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const i=n,a=new Yn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=D2+"#cannot-parse-style-attribute",a}}function L2(e,t,n){let i;if(!n)i={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,o;for(;++l<a.length;){const d=Dk(a[l])?{type:"Identifier",name:a[l]}:{type:"Literal",value:a[l]};o=o?{type:"MemberExpression",object:o,property:d,computed:!!(l&&d.type==="Literal"),optional:!1}:d}i=o}else i=Dk(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(i.type==="Literal"){const a=i.value;return bx.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(i);ju(e)}function ju(e,t){const n=new Yn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=D2+"#cannot-handle-mdx-estrees-without-createevaluater",n}function JP(e){const t={};let n;for(n in e)bx.call(e,n)&&(t[e5(n)]=e[n]);return t}function e5(e){let t=e.replace(zP,t5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function t5(e){return"-"+e.toLowerCase()}const qg={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},n5={};function wx(e,t){const n=n5,i=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return I2(e,i,a)}function I2(e,t,n){if(i5(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Fk(e.children,t,n)}return Array.isArray(e)?Fk(e,t,n):""}function Fk(e,t,n){const i=[];let a=-1;for(;++a<e.length;)i[a]=I2(e[a],t,n);return i.join("")}function i5(e){return!!(e&&typeof e=="object")}const qk=document.createElement("i");function kx(e){const t="&"+e+";";qk.innerHTML=t;const n=qk.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ji(e,t,n,i){const a=e.length;let l=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,i.length<1e4)o=Array.from(i),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);l<i.length;)o=i.slice(l,l+1e4),o.unshift(t,0),e.splice(...o),l+=1e4,t+=1e4}function Hi(e,t){return e.length>0?(ji(e,e.length,0,t),e):t}const Hk={}.hasOwnProperty;function z2(e){const t={};let n=-1;for(;++n<e.length;)r5(t,e[n]);return t}function r5(e,t){let n;for(n in t){const a=(Hk.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let o;if(l)for(o in l){Hk.call(a,o)||(a[o]=[]);const d=l[o];a5(a[o],Array.isArray(d)?d:d?[d]:[])}}}function a5(e,t){let n=-1;const i=[];for(;++n<t.length;)(t[n].add==="after"?e:i).push(t[n]);ji(e,0,0,i)}function P2(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function dr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ni=Ns(/[A-Za-z]/),Gn=Ns(/[\dA-Za-z]/),s5=Ns(/[#-'*+\--9=?A-Z^-~]/);function xh(e){return e!==null&&(e<32||e===127)}const tb=Ns(/\d/),l5=Ns(/[\dA-Fa-f]/),o5=Ns(/[!-/:-@[-`{-~]/);function Je(e){return e!==null&&e<-2}function Ht(e){return e!==null&&(e<0||e===32)}function gt(e){return e===-2||e===-1||e===32}const rp=Ns(new RegExp("\\p{P}|\\p{S}","u")),ml=Ns(/\s/);function Ns(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function lc(e){const t=[];let n=-1,i=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let o="";if(l===37&&Gn(e.charCodeAt(n+1))&&Gn(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(o=String.fromCharCode(l));else if(l>55295&&l<57344){const d=e.charCodeAt(n+1);l<56320&&d>56319&&d<57344?(o=String.fromCharCode(l,d),a=1):o="�"}else o=String.fromCharCode(l);o&&(t.push(e.slice(i,n),encodeURIComponent(o)),i=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(i)}function Et(e,t,n,i){const a=i?i-1:Number.POSITIVE_INFINITY;let l=0;return o;function o(f){return gt(f)?(e.enter(n),d(f)):t(f)}function d(f){return gt(f)&&l++<a?(e.consume(f),d):(e.exit(n),t(f))}}const c5={tokenize:u5};function u5(e){const t=e.attempt(this.parser.constructs.contentInitial,i,a);let n;return t;function i(d){if(d===null){e.consume(d);return}return e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),Et(e,t,"linePrefix")}function a(d){return e.enter("paragraph"),l(d)}function l(d){const f=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=f),n=f,o(d)}function o(d){if(d===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(d);return}return Je(d)?(e.consume(d),e.exit("chunkText"),l):(e.consume(d),o)}}const d5={tokenize:f5},Kk={tokenize:h5};function f5(e){const t=this,n=[];let i=0,a,l,o;return d;function d(S){if(i<n.length){const _=n[i];return t.containerState=_[1],e.attempt(_[0].continuation,f,h)(S)}return h(S)}function f(S){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&C();const _=t.events.length;let M=_,T;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){T=t.events[M][1].end;break}E(i);let R=_;for(;R<t.events.length;)t.events[R][1].end={...T},R++;return ji(t.events,M+1,0,t.events.slice(_)),t.events.length=R,h(S)}return d(S)}function h(S){if(i===n.length){if(!a)return y(S);if(a.currentConstruct&&a.currentConstruct.concrete)return k(S);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Kk,g,m)(S)}function g(S){return a&&C(),E(i),y(S)}function m(S){return t.parser.lazy[t.now().line]=i!==n.length,o=t.now().offset,k(S)}function y(S){return t.containerState={},e.attempt(Kk,b,k)(S)}function b(S){return i++,n.push([t.currentConstruct,t.containerState]),y(S)}function k(S){if(S===null){a&&C(),E(0),e.consume(S);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),v(S)}function v(S){if(S===null){N(e.exit("chunkFlow"),!0),E(0),e.consume(S);return}return Je(S)?(e.consume(S),N(e.exit("chunkFlow")),i=0,t.interrupt=void 0,d):(e.consume(S),v)}function N(S,_){const M=t.sliceStream(S);if(_&&M.push(null),S.previous=l,l&&(l.next=S),l=S,a.defineSkip(S.start),a.write(M),t.parser.lazy[S.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<o&&(!a.events[T][1].end||a.events[T][1].end.offset>o))return;const R=t.events.length;let O=R,$,I;for(;O--;)if(t.events[O][0]==="exit"&&t.events[O][1].type==="chunkFlow"){if($){I=t.events[O][1].end;break}$=!0}for(E(i),T=R;T<t.events.length;)t.events[T][1].end={...I},T++;ji(t.events,O+1,0,t.events.slice(R)),t.events.length=T}}function E(S){let _=n.length;for(;_-- >S;){const M=n[_];t.containerState=M[1],M[0].exit.call(t,e)}n.length=S}function C(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function h5(e,t,n){return Et(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Uo(e){if(e===null||Ht(e)||ml(e))return 1;if(rp(e))return 2}function ap(e,t,n){const i=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!i.includes(l)&&(t=l(t,n),i.push(l))}return t}const nb={name:"attention",resolveAll:p5,tokenize:m5};function p5(e,t){let n=-1,i,a,l,o,d,f,h,g;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(i=n;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&t.sliceSerialize(e[i][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[i][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;f=e[i][1].end.offset-e[i][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[i][1].end},y={...e[n][1].start};Gk(m,-f),Gk(y,f),o={type:f>1?"strongSequence":"emphasisSequence",start:m,end:{...e[i][1].end}},d={type:f>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:y},l={type:f>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[n][1].start}},a={type:f>1?"strong":"emphasis",start:{...o.start},end:{...d.end}},e[i][1].end={...o.start},e[n][1].start={...d.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Hi(h,[["enter",e[i][1],t],["exit",e[i][1],t]])),h=Hi(h,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",l,t]]),h=Hi(h,ap(t.parser.constructs.insideSpan.null,e.slice(i+1,n),t)),h=Hi(h,[["exit",l,t],["enter",d,t],["exit",d,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(g=2,h=Hi(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):g=0,ji(e,i-1,n-i+3,h),n=i+h.length-g-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function m5(e,t){const n=this.parser.constructs.attentionMarkers.null,i=this.previous,a=Uo(i);let l;return o;function o(f){return l=f,e.enter("attentionSequence"),d(f)}function d(f){if(f===l)return e.consume(f),d;const h=e.exit("attentionSequence"),g=Uo(f),m=!g||g===2&&a||n.includes(f),y=!a||a===2&&g||n.includes(i);return h._open=!!(l===42?m:m&&(a||!y)),h._close=!!(l===42?y:y&&(g||!m)),t(f)}}function Gk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const g5={name:"autolink",tokenize:y5};function y5(e,t,n){let i=0;return a;function a(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(b){return ni(b)?(e.consume(b),o):b===64?n(b):h(b)}function o(b){return b===43||b===45||b===46||Gn(b)?(i=1,d(b)):h(b)}function d(b){return b===58?(e.consume(b),i=0,f):(b===43||b===45||b===46||Gn(b))&&i++<32?(e.consume(b),d):(i=0,h(b))}function f(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):b===null||b===32||b===60||xh(b)?n(b):(e.consume(b),f)}function h(b){return b===64?(e.consume(b),g):s5(b)?(e.consume(b),h):n(b)}function g(b){return Gn(b)?m(b):n(b)}function m(b){return b===46?(e.consume(b),i=0,g):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),t):y(b)}function y(b){if((b===45||Gn(b))&&i++<63){const k=b===45?y:m;return e.consume(b),k}return n(b)}}const Ju={partial:!0,tokenize:b5};function b5(e,t,n){return i;function i(l){return gt(l)?Et(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||Je(l)?t(l):n(l)}}const B2={continuation:{tokenize:v5},exit:w5,name:"blockQuote",tokenize:x5};function x5(e,t,n){const i=this;return a;function a(o){if(o===62){const d=i.containerState;return d.open||(e.enter("blockQuote",{_container:!0}),d.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),l}return n(o)}function l(o){return gt(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function v5(e,t,n){const i=this;return a;function a(o){return gt(o)?Et(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):l(o)}function l(o){return e.attempt(B2,t,n)(o)}}function w5(e){e.exit("blockQuote")}const $2={name:"characterEscape",tokenize:k5};function k5(e,t,n){return i;function i(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return o5(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const U2={name:"characterReference",tokenize:E5};function E5(e,t,n){const i=this;let a=0,l,o;return d;function d(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),f}function f(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),l=31,o=Gn,g(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,o=l5,g):(e.enter("characterReferenceValue"),l=7,o=tb,g(m))}function g(m){if(m===59&&a){const y=e.exit("characterReferenceValue");return o===Gn&&!kx(i.sliceSerialize(y))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(m)&&a++<l?(e.consume(m),g):n(m)}}const Vk={partial:!0,tokenize:N5},Yk={concrete:!0,name:"codeFenced",tokenize:S5};function S5(e,t,n){const i=this,a={partial:!0,tokenize:M};let l=0,o=0,d;return f;function f(T){return h(T)}function h(T){const R=i.events[i.events.length-1];return l=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,d=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(T)}function g(T){return T===d?(o++,e.consume(T),g):o<3?n(T):(e.exit("codeFencedFenceSequence"),gt(T)?Et(e,m,"whitespace")(T):m(T))}function m(T){return T===null||Je(T)?(e.exit("codeFencedFence"),i.interrupt?t(T):e.check(Vk,v,_)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(T))}function y(T){return T===null||Je(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):gt(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Et(e,b,"whitespace")(T)):T===96&&T===d?n(T):(e.consume(T),y)}function b(T){return T===null||Je(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),k(T))}function k(T){return T===null||Je(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===d?n(T):(e.consume(T),k)}function v(T){return e.attempt(a,_,N)(T)}function N(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),E}function E(T){return l>0&>(T)?Et(e,C,"linePrefix",l+1)(T):C(T)}function C(T){return T===null||Je(T)?e.check(Vk,v,_)(T):(e.enter("codeFlowValue"),S(T))}function S(T){return T===null||Je(T)?(e.exit("codeFlowValue"),C(T)):(e.consume(T),S)}function _(T){return e.exit("codeFenced"),t(T)}function M(T,R,O){let $=0;return I;function I(K){return T.enter("lineEnding"),T.consume(K),T.exit("lineEnding"),q}function q(K){return T.enter("codeFencedFence"),gt(K)?Et(T,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):F(K)}function F(K){return K===d?(T.enter("codeFencedFenceSequence"),Y(K)):O(K)}function Y(K){return K===d?($++,T.consume(K),Y):$>=o?(T.exit("codeFencedFenceSequence"),gt(K)?Et(T,D,"whitespace")(K):D(K)):O(K)}function D(K){return K===null||Je(K)?(T.exit("codeFencedFence"),R(K)):O(K)}}}function N5(e,t,n){const i=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l)}function l(o){return i.parser.lazy[i.now().line]?n(o):t(o)}}const Hg={name:"codeIndented",tokenize:j5},_5={partial:!0,tokenize:C5};function j5(e,t,n){const i=this;return a;function a(h){return e.enter("codeIndented"),Et(e,l,"linePrefix",5)(h)}function l(h){const g=i.events[i.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?o(h):n(h)}function o(h){return h===null?f(h):Je(h)?e.attempt(_5,o,f)(h):(e.enter("codeFlowValue"),d(h))}function d(h){return h===null||Je(h)?(e.exit("codeFlowValue"),o(h)):(e.consume(h),d)}function f(h){return e.exit("codeIndented"),t(h)}}function C5(e,t,n){const i=this;return a;function a(o){return i.parser.lazy[i.now().line]?n(o):Je(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):Et(e,l,"linePrefix",5)(o)}function l(o){const d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(o):Je(o)?a(o):n(o)}}const A5={name:"codeText",previous:M5,resolve:T5,tokenize:D5};function T5(e){let t=e.length-4,n=3,i,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(i=n;++i<t;)if(e[i][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(i=n-1,t++;++i<=t;)a===void 0?i!==t&&e[i][1].type!=="lineEnding"&&(a=i):(i===t||e[i][1].type==="lineEnding")&&(e[a][1].type="codeTextData",i!==a+2&&(e[a][1].end=e[i-1][1].end,e.splice(a+2,i-a-2),t-=i-a-2,i=a+2),a=void 0);return e}function M5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function D5(e,t,n){let i=0,a,l;return o;function o(m){return e.enter("codeText"),e.enter("codeTextSequence"),d(m)}function d(m){return m===96?(e.consume(m),i++,d):(e.exit("codeTextSequence"),f(m))}function f(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),f):m===96?(l=e.enter("codeTextSequence"),a=0,g(m)):Je(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||Je(m)?(e.exit("codeTextData"),f(m)):(e.consume(m),h)}function g(m){return m===96?(e.consume(m),a++,g):a===i?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",h(m))}}class O5{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const i=n??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(t,i):t>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(t,n,i){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return i&&iu(this.left,i),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),iu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),iu(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);iu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);iu(this.left,n.reverse())}}}function iu(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function F2(e){const t={};let n=-1,i,a,l,o,d,f,h;const g=new O5(e);for(;++n<g.length;){for(;n in t;)n=t[n];if(i=g.get(n),n&&i[1].type==="chunkFlow"&&g.get(n-1)[1].type==="listItemPrefix"&&(f=i[1]._tokenizer.events,l=0,l<f.length&&f[l][1].type==="lineEndingBlank"&&(l+=2),l<f.length&&f[l][1].type==="content"))for(;++l<f.length&&f[l][1].type!=="content";)f[l][1].type==="chunkText"&&(f[l][1]._isInFirstContentOfListItem=!0,l++);if(i[0]==="enter")i[1].contentType&&(Object.assign(t,R5(g,n)),n=t[n],h=!0);else if(i[1]._container){for(l=n,a=void 0;l--;)if(o=g.get(l),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(g.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=l);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(i[1].end={...g.get(a)[1].start},d=g.slice(a,n),d.unshift(i),g.splice(a,n-a+1,d))}}return ji(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!h}function R5(e,t){const n=e.get(t)[1],i=e.get(t)[2];let a=t-1;const l=[];let o=n._tokenizer;o||(o=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const d=o.events,f=[],h={};let g,m,y=-1,b=n,k=0,v=0;const N=[v];for(;b;){for(;e.get(++a)[1]!==b;);l.push(a),b._tokenizer||(g=i.sliceStream(b),b.next||g.push(null),m&&o.defineSkip(b.start),b._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(g),b._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),m=b,b=b.next}for(b=n;++y<d.length;)d[y][0]==="exit"&&d[y-1][0]==="enter"&&d[y][1].type===d[y-1][1].type&&d[y][1].start.line!==d[y][1].end.line&&(v=y+1,N.push(v),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(o.events=[],b?(b._tokenizer=void 0,b.previous=void 0):N.pop(),y=N.length;y--;){const E=d.slice(N[y],N[y+1]),C=l.pop();f.push([C,C+E.length-1]),e.splice(C,2,E)}for(f.reverse(),y=-1;++y<f.length;)h[k+f[y][0]]=k+f[y][1],k+=f[y][1]-f[y][0]-1;return h}const L5={resolve:z5,tokenize:P5},I5={partial:!0,tokenize:B5};function z5(e){return F2(e),e}function P5(e,t){let n;return i;function i(d){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(d)}function a(d){return d===null?l(d):Je(d)?e.check(I5,o,l)(d):(e.consume(d),a)}function l(d){return e.exit("chunkContent"),e.exit("content"),t(d)}function o(d){return e.consume(d),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function B5(e,t,n){const i=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Et(e,l,"linePrefix")}function l(o){if(o===null||Je(o))return n(o);const d=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?t(o):e.interrupt(i.parser.constructs.flow,n,t)(o)}}function q2(e,t,n,i,a,l,o,d,f){const h=f||Number.POSITIVE_INFINITY;let g=0;return m;function m(E){return E===60?(e.enter(i),e.enter(a),e.enter(l),e.consume(E),e.exit(l),y):E===null||E===32||E===41||xh(E)?n(E):(e.enter(i),e.enter(o),e.enter(d),e.enter("chunkString",{contentType:"string"}),v(E))}function y(E){return E===62?(e.enter(l),e.consume(E),e.exit(l),e.exit(a),e.exit(i),t):(e.enter(d),e.enter("chunkString",{contentType:"string"}),b(E))}function b(E){return E===62?(e.exit("chunkString"),e.exit(d),y(E)):E===null||E===60||Je(E)?n(E):(e.consume(E),E===92?k:b)}function k(E){return E===60||E===62||E===92?(e.consume(E),b):b(E)}function v(E){return!g&&(E===null||E===41||Ht(E))?(e.exit("chunkString"),e.exit(d),e.exit(o),e.exit(i),t(E)):g<h&&E===40?(e.consume(E),g++,v):E===41?(e.consume(E),g--,v):E===null||E===32||E===40||xh(E)?n(E):(e.consume(E),E===92?N:v)}function N(E){return E===40||E===41||E===92?(e.consume(E),v):v(E)}}function H2(e,t,n,i,a,l){const o=this;let d=0,f;return h;function h(b){return e.enter(i),e.enter(a),e.consume(b),e.exit(a),e.enter(l),g}function g(b){return d>999||b===null||b===91||b===93&&!f||b===94&&!d&&"_hiddenFootnoteSupport"in o.parser.constructs?n(b):b===93?(e.exit(l),e.enter(a),e.consume(b),e.exit(a),e.exit(i),t):Je(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===null||b===91||b===93||Je(b)||d++>999?(e.exit("chunkString"),g(b)):(e.consume(b),f||(f=!gt(b)),b===92?y:m)}function y(b){return b===91||b===92||b===93?(e.consume(b),d++,m):m(b)}}function K2(e,t,n,i,a,l){let o;return d;function d(y){return y===34||y===39||y===40?(e.enter(i),e.enter(a),e.consume(y),e.exit(a),o=y===40?41:y,f):n(y)}function f(y){return y===o?(e.enter(a),e.consume(y),e.exit(a),e.exit(i),t):(e.enter(l),h(y))}function h(y){return y===o?(e.exit(l),f(o)):y===null?n(y):Je(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),Et(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(y))}function g(y){return y===o||y===null||Je(y)?(e.exit("chunkString"),h(y)):(e.consume(y),y===92?m:g)}function m(y){return y===o||y===92?(e.consume(y),g):g(y)}}function pu(e,t){let n;return i;function i(a){return Je(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,i):gt(a)?Et(e,i,n?"linePrefix":"lineSuffix")(a):t(a)}}const $5={name:"definition",tokenize:F5},U5={partial:!0,tokenize:q5};function F5(e,t,n){const i=this;let a;return l;function l(b){return e.enter("definition"),o(b)}function o(b){return H2.call(i,e,d,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function d(b){return a=dr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),f):n(b)}function f(b){return Ht(b)?pu(e,h)(b):h(b)}function h(b){return q2(e,g,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function g(b){return e.attempt(U5,m,m)(b)}function m(b){return gt(b)?Et(e,y,"whitespace")(b):y(b)}function y(b){return b===null||Je(b)?(e.exit("definition"),i.parser.defined.push(a),t(b)):n(b)}}function q5(e,t,n){return i;function i(d){return Ht(d)?pu(e,a)(d):n(d)}function a(d){return K2(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function l(d){return gt(d)?Et(e,o,"whitespace")(d):o(d)}function o(d){return d===null||Je(d)?t(d):n(d)}}const H5={name:"hardBreakEscape",tokenize:K5};function K5(e,t,n){return i;function i(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return Je(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const G5={name:"headingAtx",resolve:V5,tokenize:Y5};function V5(e,t){let n=e.length-2,i=3,a,l;return e[i][1].type==="whitespace"&&(i+=2),n-2>i&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&e[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(a={type:"atxHeadingText",start:e[i][1].start,end:e[n][1].end},l={type:"chunkText",start:e[i][1].start,end:e[n][1].end,contentType:"text"},ji(e,i,n-i+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function Y5(e,t,n){let i=0;return a;function a(g){return e.enter("atxHeading"),l(g)}function l(g){return e.enter("atxHeadingSequence"),o(g)}function o(g){return g===35&&i++<6?(e.consume(g),o):g===null||Ht(g)?(e.exit("atxHeadingSequence"),d(g)):n(g)}function d(g){return g===35?(e.enter("atxHeadingSequence"),f(g)):g===null||Je(g)?(e.exit("atxHeading"),t(g)):gt(g)?Et(e,d,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function f(g){return g===35?(e.consume(g),f):(e.exit("atxHeadingSequence"),d(g))}function h(g){return g===null||g===35||Ht(g)?(e.exit("atxHeadingText"),d(g)):(e.consume(g),h)}}const Q5=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Qk=["pre","script","style","textarea"],W5={concrete:!0,name:"htmlFlow",resolveTo:J5,tokenize:eB},X5={partial:!0,tokenize:nB},Z5={partial:!0,tokenize:tB};function J5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function eB(e,t,n){const i=this;let a,l,o,d,f;return h;function h(B){return g(B)}function g(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),y):B===47?(e.consume(B),l=!0,v):B===63?(e.consume(B),a=3,i.interrupt?t:L):ni(B)?(e.consume(B),o=String.fromCharCode(B),N):n(B)}function y(B){return B===45?(e.consume(B),a=2,b):B===91?(e.consume(B),a=5,d=0,k):ni(B)?(e.consume(B),a=4,i.interrupt?t:L):n(B)}function b(B){return B===45?(e.consume(B),i.interrupt?t:L):n(B)}function k(B){const le="CDATA[";return B===le.charCodeAt(d++)?(e.consume(B),d===le.length?i.interrupt?t:F:k):n(B)}function v(B){return ni(B)?(e.consume(B),o=String.fromCharCode(B),N):n(B)}function N(B){if(B===null||B===47||B===62||Ht(B)){const le=B===47,ve=o.toLowerCase();return!le&&!l&&Qk.includes(ve)?(a=1,i.interrupt?t(B):F(B)):Q5.includes(o.toLowerCase())?(a=6,le?(e.consume(B),E):i.interrupt?t(B):F(B)):(a=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(B):l?C(B):S(B))}return B===45||Gn(B)?(e.consume(B),o+=String.fromCharCode(B),N):n(B)}function E(B){return B===62?(e.consume(B),i.interrupt?t:F):n(B)}function C(B){return gt(B)?(e.consume(B),C):I(B)}function S(B){return B===47?(e.consume(B),I):B===58||B===95||ni(B)?(e.consume(B),_):gt(B)?(e.consume(B),S):I(B)}function _(B){return B===45||B===46||B===58||B===95||Gn(B)?(e.consume(B),_):M(B)}function M(B){return B===61?(e.consume(B),T):gt(B)?(e.consume(B),M):S(B)}function T(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),f=B,R):gt(B)?(e.consume(B),T):O(B)}function R(B){return B===f?(e.consume(B),f=null,$):B===null||Je(B)?n(B):(e.consume(B),R)}function O(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Ht(B)?M(B):(e.consume(B),O)}function $(B){return B===47||B===62||gt(B)?S(B):n(B)}function I(B){return B===62?(e.consume(B),q):n(B)}function q(B){return B===null||Je(B)?F(B):gt(B)?(e.consume(B),q):n(B)}function F(B){return B===45&&a===2?(e.consume(B),P):B===60&&a===1?(e.consume(B),H):B===62&&a===4?(e.consume(B),z):B===63&&a===3?(e.consume(B),L):B===93&&a===5?(e.consume(B),G):Je(B)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(X5,V,Y)(B)):B===null||Je(B)?(e.exit("htmlFlowData"),Y(B)):(e.consume(B),F)}function Y(B){return e.check(Z5,D,V)(B)}function D(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),K}function K(B){return B===null||Je(B)?Y(B):(e.enter("htmlFlowData"),F(B))}function P(B){return B===45?(e.consume(B),L):F(B)}function H(B){return B===47?(e.consume(B),o="",Q):F(B)}function Q(B){if(B===62){const le=o.toLowerCase();return Qk.includes(le)?(e.consume(B),z):F(B)}return ni(B)&&o.length<8?(e.consume(B),o+=String.fromCharCode(B),Q):F(B)}function G(B){return B===93?(e.consume(B),L):F(B)}function L(B){return B===62?(e.consume(B),z):B===45&&a===2?(e.consume(B),L):F(B)}function z(B){return B===null||Je(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),z)}function V(B){return e.exit("htmlFlow"),t(B)}}function tB(e,t,n){const i=this;return a;function a(o){return Je(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),l):n(o)}function l(o){return i.parser.lazy[i.now().line]?n(o):t(o)}}function nB(e,t,n){return i;function i(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Ju,t,n)}}const iB={name:"htmlText",tokenize:rB};function rB(e,t,n){const i=this;let a,l,o;return d;function d(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),f}function f(L){return L===33?(e.consume(L),h):L===47?(e.consume(L),M):L===63?(e.consume(L),S):ni(L)?(e.consume(L),O):n(L)}function h(L){return L===45?(e.consume(L),g):L===91?(e.consume(L),l=0,k):ni(L)?(e.consume(L),C):n(L)}function g(L){return L===45?(e.consume(L),b):n(L)}function m(L){return L===null?n(L):L===45?(e.consume(L),y):Je(L)?(o=m,H(L)):(e.consume(L),m)}function y(L){return L===45?(e.consume(L),b):m(L)}function b(L){return L===62?P(L):L===45?y(L):m(L)}function k(L){const z="CDATA[";return L===z.charCodeAt(l++)?(e.consume(L),l===z.length?v:k):n(L)}function v(L){return L===null?n(L):L===93?(e.consume(L),N):Je(L)?(o=v,H(L)):(e.consume(L),v)}function N(L){return L===93?(e.consume(L),E):v(L)}function E(L){return L===62?P(L):L===93?(e.consume(L),E):v(L)}function C(L){return L===null||L===62?P(L):Je(L)?(o=C,H(L)):(e.consume(L),C)}function S(L){return L===null?n(L):L===63?(e.consume(L),_):Je(L)?(o=S,H(L)):(e.consume(L),S)}function _(L){return L===62?P(L):S(L)}function M(L){return ni(L)?(e.consume(L),T):n(L)}function T(L){return L===45||Gn(L)?(e.consume(L),T):R(L)}function R(L){return Je(L)?(o=R,H(L)):gt(L)?(e.consume(L),R):P(L)}function O(L){return L===45||Gn(L)?(e.consume(L),O):L===47||L===62||Ht(L)?$(L):n(L)}function $(L){return L===47?(e.consume(L),P):L===58||L===95||ni(L)?(e.consume(L),I):Je(L)?(o=$,H(L)):gt(L)?(e.consume(L),$):P(L)}function I(L){return L===45||L===46||L===58||L===95||Gn(L)?(e.consume(L),I):q(L)}function q(L){return L===61?(e.consume(L),F):Je(L)?(o=q,H(L)):gt(L)?(e.consume(L),q):$(L)}function F(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),a=L,Y):Je(L)?(o=F,H(L)):gt(L)?(e.consume(L),F):(e.consume(L),D)}function Y(L){return L===a?(e.consume(L),a=void 0,K):L===null?n(L):Je(L)?(o=Y,H(L)):(e.consume(L),Y)}function D(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||Ht(L)?$(L):(e.consume(L),D)}function K(L){return L===47||L===62||Ht(L)?$(L):n(L)}function P(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function H(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),Q}function Q(L){return gt(L)?Et(e,G,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):G(L)}function G(L){return e.enter("htmlTextData"),o(L)}}const Ex={name:"labelEnd",resolveAll:oB,resolveTo:cB,tokenize:uB},aB={tokenize:dB},sB={tokenize:fB},lB={tokenize:hB};function oB(e){let t=-1;const n=[];for(;++t<e.length;){const i=e[t][1];if(n.push(e[t]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const a=i.type==="labelImage"?4:2;i.type="data",t+=a}}return e.length!==n.length&&ji(e,0,e.length,n),e}function cB(e,t){let n=e.length,i=0,a,l,o,d;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){i=2;break}}else a.type==="labelEnd"&&(o=n);const f={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[l][1].start},end:{...e[o][1].end}},g={type:"labelText",start:{...e[l+i+2][1].end},end:{...e[o-2][1].start}};return d=[["enter",f,t],["enter",h,t]],d=Hi(d,e.slice(l+1,l+i+3)),d=Hi(d,[["enter",g,t]]),d=Hi(d,ap(t.parser.constructs.insideSpan.null,e.slice(l+i+4,o-3),t)),d=Hi(d,[["exit",g,t],e[o-2],e[o-1],["exit",h,t]]),d=Hi(d,e.slice(o+1)),d=Hi(d,[["exit",f,t]]),ji(e,l,e.length,d),e}function uB(e,t,n){const i=this;let a=i.events.length,l,o;for(;a--;)if((i.events[a][1].type==="labelImage"||i.events[a][1].type==="labelLink")&&!i.events[a][1]._balanced){l=i.events[a][1];break}return d;function d(y){return l?l._inactive?m(y):(o=i.parser.defined.includes(dr(i.sliceSerialize({start:l.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),f):n(y)}function f(y){return y===40?e.attempt(aB,g,o?g:m)(y):y===91?e.attempt(sB,g,o?h:m)(y):o?g(y):m(y)}function h(y){return e.attempt(lB,g,m)(y)}function g(y){return t(y)}function m(y){return l._balanced=!0,n(y)}}function dB(e,t,n){return i;function i(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return Ht(m)?pu(e,l)(m):l(m)}function l(m){return m===41?g(m):q2(e,o,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function o(m){return Ht(m)?pu(e,f)(m):g(m)}function d(m){return n(m)}function f(m){return m===34||m===39||m===40?K2(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):g(m)}function h(m){return Ht(m)?pu(e,g)(m):g(m)}function g(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function fB(e,t,n){const i=this;return a;function a(d){return H2.call(i,e,l,o,"reference","referenceMarker","referenceString")(d)}function l(d){return i.parser.defined.includes(dr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(d):n(d)}function o(d){return n(d)}}function hB(e,t,n){return i;function i(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),a}function a(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const pB={name:"labelStartImage",resolveAll:Ex.resolveAll,tokenize:mB};function mB(e,t,n){const i=this;return a;function a(d){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(d),e.exit("labelImageMarker"),l}function l(d){return d===91?(e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelImage"),o):n(d)}function o(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(d):t(d)}}const gB={name:"labelStartLink",resolveAll:Ex.resolveAll,tokenize:yB};function yB(e,t,n){const i=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),l}function l(o){return o===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(o):t(o)}}const Kg={name:"lineEnding",tokenize:bB};function bB(e,t){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Et(e,t,"linePrefix")}}const nh={name:"thematicBreak",tokenize:xB};function xB(e,t,n){let i=0,a;return l;function l(h){return e.enter("thematicBreak"),o(h)}function o(h){return a=h,d(h)}function d(h){return h===a?(e.enter("thematicBreakSequence"),f(h)):i>=3&&(h===null||Je(h))?(e.exit("thematicBreak"),t(h)):n(h)}function f(h){return h===a?(e.consume(h),i++,f):(e.exit("thematicBreakSequence"),gt(h)?Et(e,d,"whitespace")(h):d(h))}}const ci={continuation:{tokenize:EB},exit:NB,name:"list",tokenize:kB},vB={partial:!0,tokenize:_B},wB={partial:!0,tokenize:SB};function kB(e,t,n){const i=this,a=i.events[i.events.length-1];let l=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return d;function d(b){const k=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:tb(b)){if(i.containerState.type||(i.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(nh,n,h)(b):h(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),f(b)}return n(b)}function f(b){return tb(b)&&++o<10?(e.consume(b),f):(!i.interrupt||o<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):n(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(Ju,i.interrupt?n:g,e.attempt(vB,y,m))}function g(b){return i.containerState.initialBlankLine=!0,l++,y(b)}function m(b){return gt(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),y):n(b)}function y(b){return i.containerState.size=l+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(b)}}function EB(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(Ju,a,l);function a(d){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Et(e,t,"listItemIndent",i.containerState.size+1)(d)}function l(d){return i.containerState.furtherBlankLines||!gt(d)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,o(d)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(wB,t,o)(d))}function o(d){return i.containerState._closeFlow=!0,i.interrupt=void 0,Et(e,e.attempt(ci,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function SB(e,t,n){const i=this;return Et(e,a,"listItemIndent",i.containerState.size+1);function a(l){const o=i.events[i.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===i.containerState.size?t(l):n(l)}}function NB(e){e.exit(this.containerState.type)}function _B(e,t,n){const i=this;return Et(e,a,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const o=i.events[i.events.length-1];return!gt(l)&&o&&o[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Wk={name:"setextUnderline",resolveTo:jB,tokenize:CB};function jB(e,t){let n=e.length,i,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){i=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const o={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",l?(e.splice(a,0,["enter",o,t]),e.splice(l+1,0,["exit",e[i][1],t]),e[i][1].end={...e[l][1].end}):e[i][1]=o,e.push(["exit",o,t]),e}function CB(e,t,n){const i=this;let a;return l;function l(h){let g=i.events.length,m;for(;g--;)if(i.events[g][1].type!=="lineEnding"&&i.events[g][1].type!=="linePrefix"&&i.events[g][1].type!=="content"){m=i.events[g][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||m)?(e.enter("setextHeadingLine"),a=h,o(h)):n(h)}function o(h){return e.enter("setextHeadingLineSequence"),d(h)}function d(h){return h===a?(e.consume(h),d):(e.exit("setextHeadingLineSequence"),gt(h)?Et(e,f,"lineSuffix")(h):f(h))}function f(h){return h===null||Je(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const AB={tokenize:TB};function TB(e){const t=this,n=e.attempt(Ju,i,e.attempt(this.parser.constructs.flowInitial,a,Et(e,e.attempt(this.parser.constructs.flow,a,e.attempt(L5,a)),"linePrefix")));return n;function i(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const MB={resolveAll:V2()},DB=G2("string"),OB=G2("text");function G2(e){return{resolveAll:V2(e==="text"?RB:void 0),tokenize:t};function t(n){const i=this,a=this.parser.constructs[e],l=n.attempt(a,o,d);return o;function o(g){return h(g)?l(g):d(g)}function d(g){if(g===null){n.consume(g);return}return n.enter("data"),n.consume(g),f}function f(g){return h(g)?(n.exit("data"),l(g)):(n.consume(g),f)}function h(g){if(g===null)return!0;const m=a[g];let y=-1;if(m)for(;++y<m.length;){const b=m[y];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function V2(e){return t;function t(n,i){let a=-1,l;for(;++a<=n.length;)l===void 0?n[a]&&n[a][1].type==="data"&&(l=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==l+2&&(n[l][1].end=n[a-1][1].end,n.splice(l+2,a-l-2),a=l+2),l=void 0);return e?e(n,i):n}}function RB(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const i=e[n-1][1],a=t.sliceStream(i);let l=a.length,o=-1,d=0,f;for(;l--;){const h=a[l];if(typeof h=="string"){for(o=h.length;h.charCodeAt(o-1)===32;)d++,o--;if(o)break;o=-1}else if(h===-2)f=!0,d++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(d=0),d){const h={type:n===e.length||f||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?o:i.start._bufferIndex+o,_index:i.start._index+l,line:i.end.line,column:i.end.column-d,offset:i.end.offset-d},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const LB={42:ci,43:ci,45:ci,48:ci,49:ci,50:ci,51:ci,52:ci,53:ci,54:ci,55:ci,56:ci,57:ci,62:B2},IB={91:$5},zB={[-2]:Hg,[-1]:Hg,32:Hg},PB={35:G5,42:nh,45:[Wk,nh],60:W5,61:Wk,95:nh,96:Yk,126:Yk},BB={38:U2,92:$2},$B={[-5]:Kg,[-4]:Kg,[-3]:Kg,33:pB,38:U2,42:nb,60:[g5,iB],91:gB,92:[H5,$2],93:Ex,95:nb,96:A5},UB={null:[nb,MB]},FB={null:[42,95]},qB={null:[]},HB=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:FB,contentInitial:IB,disable:qB,document:LB,flow:PB,flowInitial:zB,insideSpan:UB,string:BB,text:$B},Symbol.toStringTag,{value:"Module"}));function KB(e,t,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let o=[],d=[];const f={attempt:R(M),check:R(T),consume:C,enter:S,exit:_,interrupt:R(T,{interrupt:!0})},h={code:null,containerState:{},defineSkip:v,events:[],now:k,parser:e,previous:null,sliceSerialize:y,sliceStream:b,write:m};let g=t.tokenize.call(h,f);return t.resolveAll&&l.push(t),h;function m(q){return o=Hi(o,q),N(),o[o.length-1]!==null?[]:(O(t,0),h.events=ap(l,h.events,h),h.events)}function y(q,F){return VB(b(q),F)}function b(q){return GB(o,q)}function k(){const{_bufferIndex:q,_index:F,line:Y,column:D,offset:K}=i;return{_bufferIndex:q,_index:F,line:Y,column:D,offset:K}}function v(q){a[q.line]=q.column,I()}function N(){let q;for(;i._index<o.length;){const F=o[i._index];if(typeof F=="string")for(q=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===q&&i._bufferIndex<F.length;)E(F.charCodeAt(i._bufferIndex));else E(F)}}function E(q){g=g(q)}function C(q){Je(q)?(i.line++,i.column=1,i.offset+=q===-3?2:1,I()):q!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===o[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=q}function S(q,F){const Y=F||{};return Y.type=q,Y.start=k(),h.events.push(["enter",Y,h]),d.push(Y),Y}function _(q){const F=d.pop();return F.end=k(),h.events.push(["exit",F,h]),F}function M(q,F){O(q,F.from)}function T(q,F){F.restore()}function R(q,F){return Y;function Y(D,K,P){let H,Q,G,L;return Array.isArray(D)?V(D):"tokenize"in D?V([D]):z(D);function z(ke){return Se;function Se(J){const ue=J!==null&&ke[J],Te=J!==null&&ke.null,Re=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(Te)?Te:Te?[Te]:[]];return V(Re)(J)}}function V(ke){return H=ke,Q=0,ke.length===0?P:B(ke[Q])}function B(ke){return Se;function Se(J){return L=$(),G=ke,ke.partial||(h.currentConstruct=ke),ke.name&&h.parser.constructs.disable.null.includes(ke.name)?ve():ke.tokenize.call(F?Object.assign(Object.create(h),F):h,f,le,ve)(J)}}function le(ke){return q(G,L),K}function ve(ke){return L.restore(),++Q<H.length?B(H[Q]):P}}}function O(q,F){q.resolveAll&&!l.includes(q)&&l.push(q),q.resolve&&ji(h.events,F,h.events.length-F,q.resolve(h.events.slice(F),h)),q.resolveTo&&(h.events=q.resolveTo(h.events,h))}function $(){const q=k(),F=h.previous,Y=h.currentConstruct,D=h.events.length,K=Array.from(d);return{from:D,restore:P};function P(){i=q,h.previous=F,h.currentConstruct=Y,h.events.length=D,d=K,I()}}function I(){i.line in a&&i.column<2&&(i.column=a[i.line],i.offset+=a[i.line]-1)}}function GB(e,t){const n=t.start._index,i=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(i,l)];else{if(o=e.slice(n,a),i>-1){const d=o[0];typeof d=="string"?o[0]=d.slice(i):o.shift()}l>0&&o.push(e[a].slice(0,l))}return o}function VB(e,t){let n=-1;const i=[];let a;for(;++n<e.length;){const l=e[n];let o;if(typeof l=="string")o=l;else switch(l){case-5:{o="\r";break}case-4:{o=`
|