@gobing-ai/spur 0.4.31 → 0.4.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/config/config.global.yaml +1 -4
  3. package/config/decisions/task-pipeline.yaml +1 -29
  4. package/config/rules/boundary/sp-runtime-path.yaml +0 -2
  5. package/config/rules/strict/runtime-boundaries.yaml +2 -12
  6. package/config/rules/structure/protected-files.yaml +0 -3
  7. package/config/rules/surface/check-cli-surface.yaml +1 -2
  8. package/config/workflow-candidates.json +1 -1
  9. package/config/workflows/idea-pipeline.yaml +1 -1
  10. package/config/workflows/task-pipeline.yaml +53 -185
  11. package/package.json +1 -1
  12. package/plugins/sp/agents/super-reviewer.md +18 -60
  13. package/plugins/sp/commands/dev-fixall.md +0 -7
  14. package/plugins/sp/commands/dev-review.md +1 -1
  15. package/plugins/sp/commands/dev-run.md +8 -3
  16. package/plugins/sp/commands/dev-runall.md +7 -4
  17. package/plugins/sp/commands/dev-verify.md +0 -10
  18. package/plugins/sp/commands/dev-verifyall.md +0 -5
  19. package/plugins/sp/plugin.json +1 -1
  20. package/plugins/sp/skills/code-implementation/SKILL.md +1 -3
  21. package/plugins/sp/skills/code-verification/SKILL.md +11 -41
  22. package/plugins/sp/skills/code-verification/references/verdict-schema.md +18 -119
  23. package/plugins/sp/skills/issue-finding/SKILL.md +1 -1
  24. package/plugins/sp/skills/next-router/references/routing-table.md +0 -7
  25. package/plugins/sp/skills/spec-decomposition/references/decomposition.md +1 -6
  26. package/plugins/sp/skills/spur-cli/references/decision.md +3 -6
  27. package/plugins/sp/skills/spur-cli/references/tasks/verbs.md +0 -28
  28. package/plugins/sp/skills/spur-cli/references/tasks.md +9 -7
  29. package/plugins/sp/skills/spur-dev/references/ac-style-guide.md +5 -12
  30. package/plugins/sp/skills/spur-dev/references/cross-cutting.md +2 -3
  31. package/plugins/sp/skills/spur-dev/references/dev-operations.md +4 -4
  32. package/plugins/sp/skills/spur-dev/references/done-housekeeping.md +4 -5
  33. package/plugins/sp/skills/spur-dev/references/execution-batch-report.md +9 -5
  34. package/plugins/sp/skills/spur-dev/references/execution-batch.md +4 -5
  35. package/plugins/sp/skills/spur-dev/references/execution-workflow.md +1 -1
  36. package/plugins/sp/skills/spur-dev/references/execution-worktree-landing.md +34 -0
  37. package/plugins/sp/skills/spur-dev/references/flag-glossary.md +14 -1
  38. package/spur.js +1437 -4409
  39. package/web/_astro/{BoardApp.CuCuw0lw.js → BoardApp.BzY_krKQ.js} +1 -1
  40. package/web/_astro/{BoardApp.BGGDrfHl.js → BoardApp.CIImQFjG.js} +3 -3
  41. package/web/_astro/{TaskDetail.DWXct9_X.js → TaskDetail.c48Pnba6.js} +1 -1
  42. package/web/_astro/{arc.BxG3NS1o.js → arc.CpU6Cddr.js} +1 -1
  43. package/web/_astro/{architectureDiagram-3BPJPVTR.BxaiM2Hv.js → architectureDiagram-3BPJPVTR.CaXT9ZEz.js} +1 -1
  44. package/web/_astro/{blockDiagram-GPEHLZMM.DJ3r6SdD.js → blockDiagram-GPEHLZMM.Cnv3IsW9.js} +1 -1
  45. package/web/_astro/{c4Diagram-AAUBKEIU.BkzpXBQs.js → c4Diagram-AAUBKEIU.VO_hjv9n.js} +1 -1
  46. package/web/_astro/channel.DrtdR7d_.js +1 -0
  47. package/web/_astro/{chunk-2J33WTMH.DI7UanTc.js → chunk-2J33WTMH.BOunhbrU.js} +1 -1
  48. package/web/_astro/{chunk-4BX2VUAB.C2uLhAlQ.js → chunk-4BX2VUAB.Brg-Gmb2.js} +1 -1
  49. package/web/_astro/{chunk-55IACEB6.KwNI2kxL.js → chunk-55IACEB6.BqF9dxiC.js} +1 -1
  50. package/web/_astro/{chunk-727SXJPM.CHZUthkg.js → chunk-727SXJPM.CEIGJZdc.js} +1 -1
  51. package/web/_astro/{chunk-AQP2D5EJ.DLr4QNJo.js → chunk-AQP2D5EJ.BxXI0bx9.js} +1 -1
  52. package/web/_astro/{chunk-FMBD7UC4.B1G8WrnE.js → chunk-FMBD7UC4.CveXCF83.js} +1 -1
  53. package/web/_astro/{chunk-ND2GUHAM.CzsA-SkD.js → chunk-ND2GUHAM.DwKjp403.js} +1 -1
  54. package/web/_astro/{chunk-QZHKN3VN.DAvBQYli.js → chunk-QZHKN3VN.DgwjHrXx.js} +1 -1
  55. package/web/_astro/{classDiagram-4FO5ZUOK.Cddmz8Ze.js → classDiagram-4FO5ZUOK.BcVv8Qmo.js} +1 -1
  56. package/web/_astro/{classDiagram-v2-Q7XG4LA2.Cddmz8Ze.js → classDiagram-v2-Q7XG4LA2.BcVv8Qmo.js} +1 -1
  57. package/web/_astro/{cose-bilkent-S5V4N54A.CKEu7KRX.js → cose-bilkent-S5V4N54A.28xfMBER.js} +1 -1
  58. package/web/_astro/{cynefin-OW5HDTMX.-B4Cy_Vl.js → cynefin-OW5HDTMX.BAFHBcJj.js} +1 -1
  59. package/web/_astro/{dagre-BM42HDAG.bLxFvI-t.js → dagre-BM42HDAG.DzR6wa9Z.js} +1 -1
  60. package/web/_astro/{diagram-2AECGRRQ.DAHU0t5h.js → diagram-2AECGRRQ.IpFlr4yd.js} +1 -1
  61. package/web/_astro/{diagram-5GNKFQAL.DFciwCNk.js → diagram-5GNKFQAL.DGNU2pOL.js} +1 -1
  62. package/web/_astro/{diagram-KO2AKTUF.BvH0dGId.js → diagram-KO2AKTUF.D_wP6t4w.js} +1 -1
  63. package/web/_astro/{diagram-LMA3HP47.BgVlskRO.js → diagram-LMA3HP47.B0DMC97s.js} +1 -1
  64. package/web/_astro/{diagram-OG6HWLK6.BpurMISo.js → diagram-OG6HWLK6.DQXmNEBs.js} +1 -1
  65. package/web/_astro/{erDiagram-TEJ5UH35.SDj5bUMU.js → erDiagram-TEJ5UH35.BZ0VPjjp.js} +1 -1
  66. package/web/_astro/{flowDiagram-I6XJVG4X.Bm5U58FE.js → flowDiagram-I6XJVG4X.zu5gJs9Z.js} +1 -1
  67. package/web/_astro/{ganttDiagram-6RSMTGT7.CnMnds77.js → ganttDiagram-6RSMTGT7.DYy6LDqD.js} +1 -1
  68. package/web/_astro/{gitGraphDiagram-PVQCEYII.BQUwwyWo.js → gitGraphDiagram-PVQCEYII.C6c_wPdO.js} +1 -1
  69. package/web/_astro/index.C4tUn4AU.css +1 -0
  70. package/web/_astro/{infoDiagram-5YYISTIA.BiSKdORH.js → infoDiagram-5YYISTIA.C3bQPQl8.js} +1 -1
  71. package/web/_astro/{ishikawaDiagram-YF4QCWOH.Br69sBTI.js → ishikawaDiagram-YF4QCWOH.Cc1D58oG.js} +1 -1
  72. package/web/_astro/{journeyDiagram-JHISSGLW.C39WX1W8.js → journeyDiagram-JHISSGLW.CY51-lNM.js} +1 -1
  73. package/web/_astro/{kanban-definition-UN3LZRKU.DppWcbSX.js → kanban-definition-UN3LZRKU.D_3v92y6.js} +1 -1
  74. package/web/_astro/{linear.DeivTDuc.js → linear.C6BrJ38s.js} +1 -1
  75. package/web/_astro/{mermaid.core.Dixrjrnj.js → mermaid.core.DO9lF20B.js} +4 -4
  76. package/web/_astro/{mindmap-definition-RKZ34NQL.BWIQ2MWG.js → mindmap-definition-RKZ34NQL.BMiM91P6.js} +1 -1
  77. package/web/_astro/{pieDiagram-4H26LBE5.vvtHpfT7.js → pieDiagram-4H26LBE5.CcgIgRlR.js} +1 -1
  78. package/web/_astro/{quadrantDiagram-W4KKPZXB.9c-T6qCy.js → quadrantDiagram-W4KKPZXB.CM1CzrHl.js} +1 -1
  79. package/web/_astro/{requirementDiagram-4Y6WPE33.9ZuRw-kn.js → requirementDiagram-4Y6WPE33.CQvQ1E8r.js} +1 -1
  80. package/web/_astro/{sankeyDiagram-5OEKKPKP.CTIWteEl.js → sankeyDiagram-5OEKKPKP.D-b1ONCV.js} +1 -1
  81. package/web/_astro/{sequenceDiagram-3UESZ5HK.DEvu4vLL.js → sequenceDiagram-3UESZ5HK.BQzFGYtH.js} +1 -1
  82. package/web/_astro/{stateDiagram-AJRCARHV.Bxvsgk-_.js → stateDiagram-AJRCARHV.DiCukZ7I.js} +1 -1
  83. package/web/_astro/{stateDiagram-v2-BHNVJYJU.CVuog5yY.js → stateDiagram-v2-BHNVJYJU.4Iut-DMk.js} +1 -1
  84. package/web/_astro/{timeline-definition-PNZ67QCA.CpPItB3E.js → timeline-definition-PNZ67QCA.BKQiLF24.js} +1 -1
  85. package/web/_astro/{vennDiagram-CIIHVFJN.C7eKaLRK.js → vennDiagram-CIIHVFJN.CyeSCofx.js} +1 -1
  86. package/web/_astro/{wardleyDiagram-YWT4CUSO.DWXHT_CW.js → wardleyDiagram-YWT4CUSO.B140ei48.js} +1 -1
  87. package/web/_astro/{xychartDiagram-2RQKCTM6.DOsrNQOF.js → xychartDiagram-2RQKCTM6.DjPyVoO1.js} +1 -1
  88. package/web/index.html +2 -2
  89. package/config/rules/structure/scratch-evidence-pointer.yaml +0 -35
  90. package/web/_astro/channel.CYWRkoDI.js +0 -1
  91. package/web/_astro/index.CKtaGArK.css +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/mermaid.core.Dixrjrnj.js","_astro/_commonjsHelpers.CqkleIqs.js","_astro/TaskDetail.DWXct9_X.js","_astro/jsx-runtime.DWOiEOII.js","_astro/index.5dn-Zm-2.js","_astro/index.tZfqwSut.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/mermaid.core.DO9lF20B.js","_astro/_commonjsHelpers.CqkleIqs.js","_astro/TaskDetail.c48Pnba6.js","_astro/jsx-runtime.DWOiEOII.js","_astro/index.5dn-Zm-2.js","_astro/index.tZfqwSut.js"])))=>i.map(i=>d[i]);
2
2
  import{j as a}from"./jsx-runtime.DWOiEOII.js";import{r as h,R as st}from"./index.5dn-Zm-2.js";import{aQ as Ca,aF as mc,L as gl,aC as Ji,N as MS,O as bC,e as _o,a2 as xC,i as yC}from"./chunk-JMJ3UQ3L.BQJEJHu4.js";import{g as hc}from"./_commonjsHelpers.CqkleIqs.js";import{r as Ur}from"./index.Cyc_GA4f.js";function EC(e){return e[0]??{}}function Dl(e){return Array.isArray(e)?e:e==null?[]:[e]}const S0="orpc",SC="@orpc/shared",wC="1.14.4";class vC extends Error{constructor(...t){super(...t),this.name="AbortError"}}function NC(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function TC(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}const kC=2,AC=`__${SC}@${wC}/otel/config__`;function gc(){return globalThis[AC]}function Hp(e,t={},n){return gc()?.tracer?.startSpan(e,t,n)}function xs(e,t,n={}){if(!e)return;const r=CC(t);e.recordException(r),(!n.signal?.aborted||n.signal.reason!==t)&&e.setStatus({code:kC,message:r.message})}function CC(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return"code"in e&&(typeof e.code=="string"||typeof e.code=="number")&&(t.code=e.code),t}return{message:String(e)}}async function ui({name:e,context:t,...n},r){const s=gc()?.tracer;if(!s)return r();const i=async o=>{try{return await r(o)}catch(l){throw xs(o,l,n),l}finally{o.end()}};return t?s.startActiveSpan(e,n,t,i):s.startActiveSpan(e,n,i)}async function ga(e,t){const n=gc();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function Li(e){return!e||typeof e!="object"?!1:"next"in e&&typeof e.next=="function"&&Symbol.asyncIterator in e&&typeof e[Symbol.asyncIterator]=="function"}const _C=Symbol.for("asyncDispose"),IC=Symbol.asyncDispose??_C;class Gp{#e=!1;#t=!1;#n;#r;constructor(t,n){this.#n=n,this.#r=TC(async()=>{if(this.#e)return{done:!0,value:void 0};try{const r=await t();return r.done&&(this.#e=!0),r}catch(r){throw this.#e=!0,r}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(t){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:t}}async throw(t){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),t}async[IC](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}}function w0({name:e,...t},n){let r;return new Gp(async()=>{r??=Hp(e);try{const s=await ga(r,()=>n.next());return r?.addEvent(s.done?"completed":"yielded"),s}catch(s){throw xs(r,s,t),s}},async s=>{try{s!=="next"&&await ga(r,()=>n.return?.())}catch(i){throw xs(r,i,t),i}finally{r?.end()}})}function RC(e){return async(t,...n)=>{try{return await t.next()}catch(r){throw await e(r,t,...n),r}}}function Fd(e,t,n){const r=(s,i)=>{const o=e[i];return o?o({...s,next:(l=s)=>r(l,i+1)}):n(s)};return r(t,0)}function bl(e){if(e)return JSON.parse(e)}function Pd(e){return JSON.stringify(e)}function DC(e){return ys(e)?Object.getPrototypeOf(e)?.constructor:null}function zr(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function ys(e){return!!e&&(typeof e=="object"||typeof e=="function")}function v0(e,t){let n=e;for(const r of t){if(!ys(n))return;n=n[r]}return n}const FS=(()=>{const e=function(){};return e.prototype=Object.create(null),Object.freeze(e.prototype),e})();function N0(e,...t){return typeof e=="function"?e(...t):e}function PS(e){return new Proxy(e,{get(t,n,r){const s=Reflect.get(t,n,r);return n!=="then"||typeof s!="function"?s:new Proxy(s,{apply(i,o,l){if(l.length!==2||l.some(u=>!LC(u)))return Reflect.apply(i,o,l);let c=!0;l[0].call(o,PS(new Proxy(t,{get:(u,d,p)=>{if(c&&d==="then"){c=!1;return}return Reflect.get(u,d,p)}})))}})}})}const OC=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;function LC(e){return typeof e=="function"&&OC.test(e.toString())}function jC(e){try{return decodeURIComponent(e)}catch{return e}}const MC="@orpc/client",FC="1.14.4",Wp={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};function PC(e,t){return t??Wp[e]?.status??500}function BC(e,t){return t||Wp[e]?.message||e}const BS=Symbol.for(`__${MC}@${FC}/error/ORPC_ERROR_CONSTRUCTORS__`);globalThis[BS]??=new WeakSet;const Bd=globalThis[BS];class ba extends Error{defined;code;status;data;constructor(t,...n){const r=EC(n);if(r.status!==void 0&&!ji(r.status))throw new Error("[ORPCError] Invalid error status code.");const s=BC(t,r.message);super(s,r),this.code=t,this.status=PC(t,r.status),this.defined=r.defined??!1,this.data=r.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](t){if(Bd.has(this)){const n=DC(t);if(n&&Bd.has(n))return!0}return super[Symbol.hasInstance](t)}}Bd.add(ba);function $C(e){return e instanceof ba?e:new ba("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:e})}function ji(e){return e<200||e>=400}function $S(e){if(!zr(e))return!1;const t=["defined","code","status","message","data"];return Object.keys(e).some(n=>!t.includes(n))?!1:"defined"in e&&typeof e.defined=="boolean"&&"code"in e&&typeof e.code=="string"&&"status"in e&&typeof e.status=="number"&&ji(e.status)&&"message"in e&&typeof e.message=="string"}function US(e,t={}){return new ba(e.code,{...t,...e})}class bc extends TypeError{}class UC extends TypeError{}class Mi extends Error{data;constructor(t){super(t?.message??"An error event was received",t),this.data=t?.data}}function zC(e){const t=e.replace(/\n+$/,"").split(/\n/),n={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const r of t){const s=r.indexOf(":"),i=s===-1?r:r.slice(0,s),o=s===-1?"":r.slice(s+1).replace(/^\s/,"");if(s===0)n.comments.push(o);else if(i==="data")n.data??="",n.data+=`${o}
3
3
  `;else if(i==="event")n.event=o;else if(i==="id")n.id=o;else if(i==="retry"){const l=Number.parseInt(o);Number.isInteger(l)&&l>=0&&l.toString()===o&&(n.retry=l)}}return n.data=n.data?.replace(/\n$/,""),n}class HC{constructor(t={}){this.options=t}incomplete="";feed(t){this.incomplete+=t;const n=this.incomplete.lastIndexOf(`
4
4
 
@@ -294,7 +294,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
294
294
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
295
295
  `,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=Jo(t),r=zs(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=Jo(t),r=zs(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(r=>r.type==="newline"||r.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;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function BW(e){const t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new FW||null,prettyErrors:t}}function $W(e,t={}){const{lineCounter:n,prettyErrors:r}=BW(t),s=new PW(n?.addNewLine),i=new DW(t);let o=null;for(const l of i.compose(s.parse(e),!0,e.length))if(!o)o=l;else if(o.options.logLevel!=="silent"){o.errors.push(new mi(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(s1(e,n)),o.warnings.forEach(s1(e,n))),o}function UW(e,t,n){let r;const s=$W(e,n);if(!s)return null;if(s.warnings.forEach(i=>qT(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}const Sk=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;function Px(e){if(!e)return"";const t=e.charCodeAt(0)===65279?e.slice(1):e,n=t.match(Sk);return n?t.slice(n[0].length):t}function zW(e){if(!e)return{frontmatterRaw:null,body:""};const t=e.charCodeAt(0)===65279?e.slice(1):e,n=t.match(Sk);return n?{frontmatterRaw:n[1]?.trim()??"",body:t.slice(n[0].length)}:{frontmatterRaw:null,body:t}}function wk(e){const{frontmatterRaw:t,body:n}=zW(e);if(!t)return{frontmatterRaw:null,frontmatter:null,body:n};let r=null;try{const s=UW(t);s&&typeof s=="object"&&!Array.isArray(s)&&(r=s)}catch{r=null}return{frontmatterRaw:t,frontmatter:r,body:n}}function HW({files:e,selectedPath:t,onSelect:n}){const[r,s]=h.useState(""),i=h.useMemo(()=>{if(!r.trim())return e;const c=r.toLowerCase();return e.filter(u=>u.name.toLowerCase().includes(c)||u.title.toLowerCase().includes(c)||u.path.toLowerCase().includes(c))},[e,r]),o=h.useMemo(()=>i.filter(c=>c.category==="root"||c.category==="architecture"),[i]),l=h.useMemo(()=>i.filter(c=>c.category==="satellite"),[i]);return a.jsxs("div",{className:"flex flex-col h-full overflow-hidden","data-testid":"design-file-list",children:[a.jsx("div",{className:"p-2 border-b border-spur-border bg-base-100/50 shrink-0",children:a.jsxs("div",{className:"relative",children:[a.jsx("input",{type:"text",value:r,onChange:c=>s(c.target.value),placeholder:"Filter design docs...",className:"w-full text-xs px-2.5 py-1.5 pl-7 rounded border border-spur-border bg-base-100 text-spur-text placeholder:text-spur-text-muted/60 focus:outline-none focus:border-spur-accent","aria-label":"Filter design documents"}),a.jsx("span",{className:"absolute left-2 top-1.5 text-xs text-spur-text-muted pointer-events-none",children:"🔍"}),r&&a.jsx("button",{type:"button",onClick:()=>s(""),className:"absolute right-2 top-1 text-xs text-spur-text-muted hover:text-spur-text p-0.5","aria-label":"Clear filter",children:"✕"})]})}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-3",children:i.length===0?a.jsx("div",{className:"p-4 text-xs text-spur-text-muted italic text-center",children:r?`No documents match "${r}"`:"No design documents found."}):a.jsxs(a.Fragment,{children:[o.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"px-2 py-1 text-[11px] font-bold uppercase tracking-wider text-spur-text-muted flex items-center justify-between",children:[a.jsx("span",{children:"Core Specifications"}),a.jsx("span",{className:"text-[10px] font-mono",children:o.length})]}),a.jsx("div",{className:"space-y-0.5 mt-1",children:o.map(c=>{const u=t===c.path;return a.jsxs("button",{type:"button",onClick:()=>n(c.path),title:c.name,className:`w-full text-left px-2.5 py-1.5 rounded-md transition-colors flex items-center gap-2 cursor-pointer ${u?"bg-spur-accent/15 text-spur-accent font-semibold shadow-xs":"hover:bg-base-300 text-spur-text hover:text-spur-text"}`,children:[a.jsx("span",{className:"text-sm shrink-0",children:c.name==="DESIGN.md"?"🎨":"📐"}),a.jsx("span",{className:"flex-1 min-w-0 text-xs truncate font-medium",title:c.name,children:c.title})]},c.id)})})]}),l.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"px-2 py-1 text-[11px] font-bold uppercase tracking-wider text-spur-text-muted flex items-center justify-between",children:[a.jsx("span",{children:"Design Satellites"}),a.jsx("span",{className:"text-[10px] font-mono",children:l.length})]}),a.jsx("div",{className:"space-y-0.5 mt-1",children:l.map(c=>{const u=t===c.path;return a.jsxs("button",{type:"button",onClick:()=>n(c.path),title:c.name,className:`w-full text-left px-2.5 py-1.5 rounded-md transition-colors flex items-center gap-2 cursor-pointer ${u?"bg-spur-accent/15 text-spur-accent font-semibold shadow-xs":"hover:bg-base-300 text-spur-text hover:text-spur-text"}`,children:[a.jsx("span",{className:"text-xs shrink-0 text-spur-text-muted",children:"📄"}),a.jsx("span",{className:"flex-1 min-w-0 text-xs truncate",title:c.name,children:c.title})]},c.id)})})]})]})})]})}function u1(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function GW(e){if(Array.isArray(e))return e}function WW(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,s,i,o,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw s}}return l}}function qW(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
296
296
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VW(e,t){return GW(e)||WW(e,t)||YW(e,t)||qW()}function YW(e,t){if(e){if(typeof e=="string")return u1(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u1(e,t):void 0}}const vk=Object.entries,d1=Object.setPrototypeOf,KW=Object.isFrozen,ZW=Object.getPrototypeOf,XW=Object.getOwnPropertyDescriptor;let cn=Object.freeze,dn=Object.seal,Zs=Object.create,Nk=typeof Reflect<"u"&&Reflect,vp=Nk.apply,Np=Nk.construct;cn||(cn=function(t){return t});dn||(dn=function(t){return t});vp||(vp=function(t,n){for(var r=arguments.length,s=new Array(r>2?r-2:0),i=2;i<r;i++)s[i-2]=arguments[i];return t.apply(n,s)});Np||(Np=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return new t(...r)});const ii=Kt(Array.prototype.forEach),QW=Kt(Array.prototype.lastIndexOf),p1=Kt(Array.prototype.pop),Hs=Kt(Array.prototype.push),JW=Kt(Array.prototype.splice),$r=Array.isArray,hi=Kt(String.prototype.toLowerCase),ud=Kt(String.prototype.toString),f1=Kt(String.prototype.match),oi=Kt(String.prototype.replace),m1=Kt(String.prototype.indexOf),eq=Kt(String.prototype.trim),tq=Kt(Number.prototype.toString),nq=Kt(Boolean.prototype.toString),h1=typeof BigInt>"u"?null:Kt(BigInt.prototype.toString),g1=typeof Symbol>"u"?null:Kt(Symbol.prototype.toString),tn=Kt(Object.prototype.hasOwnProperty),li=Kt(Object.prototype.toString),on=Kt(RegExp.prototype.test),ss=rq(TypeError);function Kt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),s=1;s<n;s++)r[s-1]=arguments[s];return vp(e,t,r)}}function rq(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Np(e,n)}}function ht(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:hi;if(d1&&d1(e,null),!$r(t))return e;let r=t.length;for(;r--;){let s=t[r];if(typeof s=="string"){const i=n(s);i!==s&&(KW(t)||(t[r]=i),s=i)}e[s]=!0}return e}function sq(e){for(let t=0;t<e.length;t++)tn(e,t)||(e[t]=null);return e}function yn(e){const t=Zs(null);for(const r of vk(e)){var n=VW(r,2);const s=n[0],i=n[1];tn(e,s)&&($r(i)?t[s]=sq(i):i&&typeof i=="object"&&i.constructor===Object?t[s]=yn(i):t[s]=i)}return t}function aq(e){switch(typeof e){case"string":return e;case"number":return tq(e);case"boolean":return nq(e);case"bigint":return h1?h1(e):"0";case"symbol":return g1?g1(e):"Symbol()";case"undefined":return li(e);case"function":case"object":{if(e===null)return li(e);const t=e,n=or(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:li(r)}return li(e)}default:return li(e)}}function or(e,t){for(;e!==null;){const r=XW(e,t);if(r){if(r.get)return Kt(r.get);if(typeof r.value=="function")return Kt(r.value)}e=ZW(e)}function n(){return null}return n}function iq(e){try{return on(e,""),!0}catch{return!1}}const b1=cn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),dd=cn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),pd=cn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),oq=cn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),fd=cn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),lq=cn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),x1=cn(["#text"]),y1=cn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),md=cn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),E1=cn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),el=cn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),cq=dn(/{{[\w\W]*|^[\w\W]*}}/g),uq=dn(/<%[\w\W]*|^[\w\W]*%>/g),dq=dn(/\${[\w\W]*/g),pq=dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),fq=dn(/^aria-[\-\w]+$/),S1=dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mq=dn(/^(?:\w+script|data):/i),hq=dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gq=dn(/^html$/i),bq=dn(/^[a-z][.\w]*(-[.\w]+)+$/i),w1=dn(/<[/\w!]/g),xq=dn(/<[/\w]/g),yq=dn(/<\/no(script|embed|frames)/i),Eq=dn(/\/>/i),sr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Sq=function(){return typeof window>"u"?null:window},wq=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(r=n.getAttribute(s));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},v1=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Lr=function(t,n,r,s){return tn(t,n)&&$r(t[n])?ht(s.base?yn(s.base):{},t[n],s.transform):r};function Tk(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Sq();const t=Ae=>Tk(Ae);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==sr.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,s=r.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,o=e.Node,l=e.Element,c=e.NodeFilter,u=e.NamedNodeMap;u===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,p=e.trustedTypes,f=l.prototype,m=or(f,"cloneNode"),b=or(f,"remove"),x=or(f,"nextSibling"),y=or(f,"childNodes"),E=or(f,"parentNode"),A=or(f,"shadowRoot"),w=or(f,"attributes"),N=o&&o.prototype?or(o.prototype,"nodeType"):null,_=o&&o.prototype?or(o.prototype,"nodeName"):null;if(typeof i=="function"){const Ae=n.createElement("template");Ae.content&&Ae.content.ownerDocument&&(n=Ae.content.ownerDocument)}let k,S="",v,O=!1,C=0;const M=function(){if(C>0)throw ss('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},B=function(U){M(),C++;try{return k.createHTML(U)}finally{C--}},R=function(U){M(),C++;try{return k.createScriptURL(U)}finally{C--}},z=function(){return O||(v=wq(p,s),O=!0),v},W=n,F=W.implementation,J=W.createNodeIterator,K=W.createDocumentFragment,X=W.getElementsByTagName,I=r.importNode;let V=v1();t.isSupported=typeof vk=="function"&&typeof E=="function"&&F&&F.createHTMLDocument!==void 0;const te=cq,L=uq,ye=dq,xe=pq,P=fq,oe=mq,re=hq,H=bq;let Ce=S1,me=null;const he=ht({},[...b1,...dd,...pd,...fd,...x1]);let Ne=null;const Ge=ht({},[...y1,...md,...E1,...el]);let Z=Object.seal(Zs(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,Fe=null;const Re=Object.seal(Zs(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let rt=!0,ae=!0,pe=!1,De=!0,Me=!1,Le=!0,ot=!1,dt=!1,se=null,fe=null,je=!1,Y=!1,He=!1,Ue=!1,at=!0,Nt=!1;const At="user-content-";let de=!0,_e=!1,Ve={},Pe=null;const Je=ht({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ct=null;const Oe=ht({},["audio","video","img","source","image","track"]);let Qe=null;const qe=ht({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),St="http://www.w3.org/1998/Math/MathML",ce="http://www.w3.org/2000/svg",Ee="http://www.w3.org/1999/xhtml";let Ye=Ee,Dt=!1,ee=null;const We=ht({},[St,ce,Ee],ud),lt=cn(["mi","mo","mn","ms","mtext"]);let bt=ht({},lt);const In=cn(["annotation-xml"]);let xr=ht({},In);const nr=ht({},["title","style","font","a","script"]);let Hn=null;const Ka=["application/xhtml+xml","text/html"],sC="text/html";let Ut=null,Fs=null;const aC=n.createElement("form"),d0=function(U){return U instanceof RegExp||U instanceof Function},Su=function(){let U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Fs&&Fs===U)return;(!U||typeof U!="object")&&(U={}),U=yn(U),Hn=Ka.indexOf(U.PARSER_MEDIA_TYPE)===-1?sC:U.PARSER_MEDIA_TYPE,Ut=Hn==="application/xhtml+xml"?ud:hi,me=Lr(U,"ALLOWED_TAGS",he,{transform:Ut}),Ne=Lr(U,"ALLOWED_ATTR",Ge,{transform:Ut}),ee=Lr(U,"ALLOWED_NAMESPACES",We,{transform:ud}),Qe=Lr(U,"ADD_URI_SAFE_ATTR",qe,{transform:Ut,base:qe}),Ct=Lr(U,"ADD_DATA_URI_TAGS",Oe,{transform:Ut,base:Oe}),Pe=Lr(U,"FORBID_CONTENTS",Je,{transform:Ut}),ke=Lr(U,"FORBID_TAGS",yn({}),{transform:Ut}),Fe=Lr(U,"FORBID_ATTR",yn({}),{transform:Ut}),Ve=tn(U,"USE_PROFILES")?U.USE_PROFILES&&typeof U.USE_PROFILES=="object"?yn(U.USE_PROFILES):U.USE_PROFILES:!1,rt=U.ALLOW_ARIA_ATTR!==!1,ae=U.ALLOW_DATA_ATTR!==!1,pe=U.ALLOW_UNKNOWN_PROTOCOLS||!1,De=U.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=U.SAFE_FOR_TEMPLATES||!1,Le=U.SAFE_FOR_XML!==!1,ot=U.WHOLE_DOCUMENT||!1,Y=U.RETURN_DOM||!1,He=U.RETURN_DOM_FRAGMENT||!1,Ue=U.RETURN_TRUSTED_TYPE||!1,je=U.FORCE_BODY||!1,at=U.SANITIZE_DOM!==!1,Nt=U.SANITIZE_NAMED_PROPS||!1,de=U.KEEP_CONTENT!==!1,_e=U.IN_PLACE||!1,Ce=iq(U.ALLOWED_URI_REGEXP)?U.ALLOWED_URI_REGEXP:S1,Ye=typeof U.NAMESPACE=="string"?U.NAMESPACE:Ee,bt=tn(U,"MATHML_TEXT_INTEGRATION_POINTS")&&U.MATHML_TEXT_INTEGRATION_POINTS&&typeof U.MATHML_TEXT_INTEGRATION_POINTS=="object"?yn(U.MATHML_TEXT_INTEGRATION_POINTS):ht({},lt),xr=tn(U,"HTML_INTEGRATION_POINTS")&&U.HTML_INTEGRATION_POINTS&&typeof U.HTML_INTEGRATION_POINTS=="object"?yn(U.HTML_INTEGRATION_POINTS):ht({},In);const ie=tn(U,"CUSTOM_ELEMENT_HANDLING")&&U.CUSTOM_ELEMENT_HANDLING&&typeof U.CUSTOM_ELEMENT_HANDLING=="object"?yn(U.CUSTOM_ELEMENT_HANDLING):Zs(null);if(Z=Zs(null),tn(ie,"tagNameCheck")&&d0(ie.tagNameCheck)&&(Z.tagNameCheck=ie.tagNameCheck),tn(ie,"attributeNameCheck")&&d0(ie.attributeNameCheck)&&(Z.attributeNameCheck=ie.attributeNameCheck),tn(ie,"allowCustomizedBuiltInElements")&&typeof ie.allowCustomizedBuiltInElements=="boolean"&&(Z.allowCustomizedBuiltInElements=ie.allowCustomizedBuiltInElements),dn(Z),Me&&(ae=!1),He&&(Y=!0),Ve&&(me=ht({},x1),Ne=Zs(null),Ve.html===!0&&(ht(me,b1),ht(Ne,y1)),Ve.svg===!0&&(ht(me,dd),ht(Ne,md),ht(Ne,el)),Ve.svgFilters===!0&&(ht(me,pd),ht(Ne,md),ht(Ne,el)),Ve.mathMl===!0&&(ht(me,fd),ht(Ne,E1),ht(Ne,el))),Re.tagCheck=null,Re.attributeCheck=null,tn(U,"ADD_TAGS")&&(typeof U.ADD_TAGS=="function"?Re.tagCheck=U.ADD_TAGS:$r(U.ADD_TAGS)&&(me===he&&(me=yn(me)),ht(me,U.ADD_TAGS,Ut))),tn(U,"ADD_ATTR")&&(typeof U.ADD_ATTR=="function"?Re.attributeCheck=U.ADD_ATTR:$r(U.ADD_ATTR)&&(Ne===Ge&&(Ne=yn(Ne)),ht(Ne,U.ADD_ATTR,Ut))),tn(U,"ADD_URI_SAFE_ATTR")&&$r(U.ADD_URI_SAFE_ATTR)&&ht(Qe,U.ADD_URI_SAFE_ATTR,Ut),tn(U,"FORBID_CONTENTS")&&$r(U.FORBID_CONTENTS)&&(Pe===Je&&(Pe=yn(Pe)),ht(Pe,U.FORBID_CONTENTS,Ut)),tn(U,"ADD_FORBID_CONTENTS")&&$r(U.ADD_FORBID_CONTENTS)&&(Pe===Je&&(Pe=yn(Pe)),ht(Pe,U.ADD_FORBID_CONTENTS,Ut)),de&&(me["#text"]=!0),ot&&ht(me,["html","head","body"]),me.table&&(ht(me,["tbody"]),delete ke.tbody),U.TRUSTED_TYPES_POLICY){if(typeof U.TRUSTED_TYPES_POLICY.createHTML!="function")throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof U.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const Te=k;k=U.TRUSTED_TYPES_POLICY;try{S=B("")}catch($e){throw k=Te,$e}}else U.TRUSTED_TYPES_POLICY===null?(k=void 0,S=""):(k===void 0&&(k=z()),k&&typeof S=="string"&&(S=B("")));cn&&cn(U),Fs=U},p0=ht({},[...dd,...pd,...oq]),f0=ht({},[...fd,...lq]),iC=function(U,ie,Te){return ie.namespaceURI===Ee?U==="svg":ie.namespaceURI===St?U==="svg"&&(Te==="annotation-xml"||bt[Te]):!!p0[U]},oC=function(U,ie,Te){return ie.namespaceURI===Ee?U==="math":ie.namespaceURI===ce?U==="math"&&xr[Te]:!!f0[U]},lC=function(U,ie,Te){return ie.namespaceURI===ce&&!xr[Te]||ie.namespaceURI===St&&!bt[Te]?!1:!f0[U]&&(nr[U]||!p0[U])},cC=function(U){let ie=E(U);(!ie||!ie.tagName)&&(ie={namespaceURI:Ye,tagName:"template"});const Te=hi(U.tagName),$e=hi(ie.tagName);return ee[U.namespaceURI]?U.namespaceURI===ce?iC(Te,ie,$e):U.namespaceURI===St?oC(Te,ie,$e):U.namespaceURI===Ee?lC(Te,ie,$e):!!(Hn==="application/xhtml+xml"&&ee[U.namespaceURI]):!1},Dr=function(U){Hs(t.removed,{element:U});try{E(U).removeChild(U)}catch{if(b(U),!E(U))throw ss("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},m0=function(U){const ie=y(U);if(ie){const $e=[];ii(ie,ct=>{Hs($e,ct)}),ii($e,ct=>{try{b(ct)}catch{}})}const Te=w(U);if(Te)for(let $e=Te.length-1;$e>=0;--$e){const ct=Te[$e],gt=ct&&ct.name;if(typeof gt=="string")try{U.removeAttribute(gt)}catch{}}},ts=function(U,ie){try{Hs(t.removed,{attribute:ie.getAttributeNode(U),from:ie})}catch{Hs(t.removed,{attribute:null,from:ie})}if(ie.removeAttribute(U),U==="is")if(Y||He)try{Dr(ie)}catch{}else try{ie.setAttribute(U,"")}catch{}},uC=function(U){const ie=w(U);if(ie)for(let Te=ie.length-1;Te>=0;--Te){const $e=ie[Te],ct=$e&&$e.name;if(!(typeof ct!="string"||Ne[Ut(ct)]))try{U.removeAttribute(ct)}catch{}}},dC=function(U){const ie=[U];for(;ie.length>0;){const Te=ie.pop();(N?N(Te):Te.nodeType)===sr.element&&uC(Te);const ct=y(Te);if(ct)for(let gt=ct.length-1;gt>=0;--gt)ie.push(ct[gt])}},h0=function(U){let ie=null,Te=null;if(je)U="<remove></remove>"+U;else{const gt=f1(U,/^[\r\n\t ]+/);Te=gt&&gt[0]}Hn==="application/xhtml+xml"&&Ye===Ee&&(U='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+U+"</body></html>");const $e=k?B(U):U;if(Ye===Ee)try{ie=new d().parseFromString($e,Hn)}catch{}if(!ie||!ie.documentElement){ie=F.createDocument(Ye,"template",null);try{ie.documentElement.innerHTML=Dt?S:$e}catch{}}const ct=ie.body||ie.documentElement;return U&&Te&&ct.insertBefore(n.createTextNode(Te),ct.childNodes[0]||null),Ye===Ee?X.call(ie,ot?"html":"body")[0]:ot?ie.documentElement:ct},g0=function(U){return J.call(U.ownerDocument||U,U,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ko=function(U){return U=oi(U,te," "),U=oi(U,L," "),U=oi(U,ye," "),U},wu=function(U){var ie;U.normalize();const Te=J.call(U.ownerDocument||U,U,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let $e=Te.nextNode();for(;$e;)$e.data=ko($e.data),$e=Te.nextNode();const ct=(ie=U.querySelectorAll)===null||ie===void 0?void 0:ie.call(U,"template");ct&&ii(ct,gt=>{Ps(gt.content)&&wu(gt.content)})},Ao=function(U){const ie=_?_(U):null;return typeof ie!="string"||Ut(ie)!=="form"?!1:typeof U.nodeName!="string"||typeof U.textContent!="string"||typeof U.removeChild!="function"||U.attributes!==w(U)||typeof U.removeAttribute!="function"||typeof U.setAttribute!="function"||typeof U.namespaceURI!="string"||typeof U.insertBefore!="function"||typeof U.hasChildNodes!="function"||U.nodeType!==N(U)||U.childNodes!==y(U)},Ps=function(U){if(!N||typeof U!="object"||U===null)return!1;try{return N(U)===sr.documentFragment}catch{return!1}},Za=function(U){if(!N||typeof U!="object"||U===null)return!1;try{return typeof N(U)=="number"}catch{return!1}};function yr(Ae,U,ie){Ae.length!==0&&ii(Ae,Te=>{Te.call(t,U,ie,Fs)})}const pC=function(U,ie){return!!(Le&&U.hasChildNodes()&&!Za(U.firstElementChild)&&on(w1,U.textContent)&&on(w1,U.innerHTML)||Le&&U.namespaceURI===Ee&&ie==="style"&&Za(U.firstElementChild)||U.nodeType===sr.processingInstruction||Le&&U.nodeType===sr.comment&&on(xq,U.data))},fC=function(U,ie){if(!ke[ie]&&y0(ie)&&(Z.tagNameCheck instanceof RegExp&&on(Z.tagNameCheck,ie)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(ie)))return!1;if(de&&!Pe[ie]){const Te=E(U),$e=y(U);if($e&&Te){const ct=$e.length;for(let gt=ct-1;gt>=0;--gt){const Qt=_e?$e[gt]:m($e[gt],!0);Te.insertBefore(Qt,x(U))}}}return Dr(U),!0},b0=function(U){if(yr(V.beforeSanitizeElements,U,null),Ao(U))return Dr(U),!0;const ie=Ut(_?_(U):U.nodeName);if(yr(V.uponSanitizeElement,U,{tagName:ie,allowedTags:me}),pC(U,ie))return Dr(U),!0;if(ke[ie]||!(Re.tagCheck instanceof Function&&Re.tagCheck(ie))&&!me[ie])return fC(U,ie);if((N?N(U):U.nodeType)===sr.element&&!cC(U)||(ie==="noscript"||ie==="noembed"||ie==="noframes")&&on(yq,U.innerHTML))return Dr(U),!0;if(Me&&U.nodeType===sr.text){const $e=ko(U.textContent);U.textContent!==$e&&(Hs(t.removed,{element:U.cloneNode()}),U.textContent=$e)}return yr(V.afterSanitizeElements,U,null),!1},x0=function(U,ie,Te){if(Fe[ie]||at&&(ie==="id"||ie==="name")&&(Te in n||Te in aC))return!1;const $e=Ne[ie]||Re.attributeCheck instanceof Function&&Re.attributeCheck(ie,U);if(!(ae&&on(xe,ie))){if(!(rt&&on(P,ie))){if($e){if(!Qe[ie]){if(!on(Ce,oi(Te,re,""))){if(!((ie==="src"||ie==="xlink:href"||ie==="href")&&U!=="script"&&m1(Te,"data:")===0&&Ct[U])){if(!(pe&&!on(oe,oi(Te,re,"")))){if(Te)return!1}}}}}else if(!(y0(U)&&(Z.tagNameCheck instanceof RegExp&&on(Z.tagNameCheck,U)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(U))&&(Z.attributeNameCheck instanceof RegExp&&on(Z.attributeNameCheck,ie)||Z.attributeNameCheck instanceof Function&&Z.attributeNameCheck(ie,U))||ie==="is"&&Z.allowCustomizedBuiltInElements&&(Z.tagNameCheck instanceof RegExp&&on(Z.tagNameCheck,Te)||Z.tagNameCheck instanceof Function&&Z.tagNameCheck(Te))))return!1}}return!0},mC=ht({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),y0=function(U){return!mC[hi(U)]&&on(H,U)},hC=function(U,ie,Te,$e){if(k&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!Te)switch(p.getAttributeType(U,ie)){case"TrustedHTML":return B($e);case"TrustedScriptURL":return R($e)}return $e},gC=function(U,ie,Te,$e){try{Te?U.setAttributeNS(Te,ie,$e):U.setAttribute(ie,$e),Ao(U)?Dr(U):p1(t.removed)}catch{ts(ie,U)}},E0=function(U){yr(V.beforeSanitizeAttributes,U,null);const ie=U.attributes;if(!ie||Ao(U))return;const Te={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ne,forceKeepAttr:void 0};let $e=ie.length;const ct=Ut(U.nodeName);for(;$e--;){const gt=ie[$e],Qt=gt.name,qt=gt.namespaceURI,On=gt.value,Gn=Ut(Qt),Nu=On;let bn=Qt==="value"?Nu:eq(Nu);if(Te.attrName=Gn,Te.attrValue=bn,Te.keepAttr=!0,Te.forceKeepAttr=void 0,yr(V.uponSanitizeAttribute,U,Te),bn=Te.attrValue,Nt&&(Gn==="id"||Gn==="name")&&m1(bn,At)!==0&&(ts(Qt,U),bn=At+bn),Le&&on(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,bn)){ts(Qt,U);continue}if(Gn==="attributename"&&f1(bn,"href")){ts(Qt,U);continue}if(!Te.forceKeepAttr){if(!Te.keepAttr){ts(Qt,U);continue}if(!De&&on(Eq,bn)){ts(Qt,U);continue}if(Me&&(bn=ko(bn)),!x0(ct,Gn,bn)){ts(Qt,U);continue}bn=hC(ct,Gn,qt,bn),bn!==Nu&&gC(U,Qt,qt,bn)}}yr(V.afterSanitizeAttributes,U,null)},Co=function(U){let ie=null;const Te=g0(U);for(yr(V.beforeSanitizeShadowDOM,U,null);ie=Te.nextNode();)if(yr(V.uponSanitizeShadowNode,ie,null),b0(ie),E0(ie),Ps(ie.content)&&Co(ie.content),(N?N(ie):ie.nodeType)===sr.element){const ct=A(ie);Ps(ct)&&(vu(ct),Co(ct))}yr(V.afterSanitizeShadowDOM,U,null)},vu=function(U){const ie=[{node:U,shadow:null}];for(;ie.length>0;){const Te=ie.pop();if(Te.shadow){Co(Te.shadow);continue}const $e=Te.node,gt=(N?N($e):$e.nodeType)===sr.element,Qt=y($e);if(Qt)for(let qt=Qt.length-1;qt>=0;--qt)ie.push({node:Qt[qt],shadow:null});if(gt){const qt=_?_($e):null;if(typeof qt=="string"&&Ut(qt)==="template"){const On=$e.content;Ps(On)&&ie.push({node:On,shadow:null})}}if(gt){const qt=A($e);Ps(qt)&&ie.push({node:null,shadow:qt},{node:qt,shadow:null})}}};return t.sanitize=function(Ae){let U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ie=null,Te=null,$e=null,ct=null;if(Dt=!Ae,Dt&&(Ae="<!-->"),typeof Ae!="string"&&!Za(Ae)&&(Ae=aq(Ae),typeof Ae!="string"))throw ss("dirty is not a string, aborting");if(!t.isSupported)return Ae;dt?(me=se,Ne=fe):Su(U),(V.uponSanitizeElement.length>0||V.uponSanitizeAttribute.length>0)&&(me=yn(me)),V.uponSanitizeAttribute.length>0&&(Ne=yn(Ne)),t.removed=[];const gt=_e&&typeof Ae!="string"&&Za(Ae);if(gt){const On=_?_(Ae):Ae.nodeName;if(typeof On=="string"){const Gn=Ut(On);if(!me[Gn]||ke[Gn])throw ss("root node is forbidden and cannot be sanitized in-place")}if(Ao(Ae))throw ss("root node is clobbered and cannot be sanitized in-place");try{vu(Ae)}catch(Gn){throw m0(Ae),Gn}}else if(Za(Ae))ie=h0("<!---->"),Te=ie.ownerDocument.importNode(Ae,!0),Te.nodeType===sr.element&&Te.nodeName==="BODY"||Te.nodeName==="HTML"?ie=Te:ie.appendChild(Te),vu(Te);else{if(!Y&&!Me&&!ot&&Ae.indexOf("<")===-1)return k&&Ue?B(Ae):Ae;if(ie=h0(Ae),!ie)return Y?null:Ue?S:""}ie&&je&&Dr(ie.firstChild);const Qt=g0(gt?Ae:ie);try{for(;$e=Qt.nextNode();)b0($e),E0($e),Ps($e.content)&&Co($e.content)}catch(On){throw gt&&m0(Ae),On}if(gt)return ii(t.removed,On=>{On.element&&dC(On.element)}),Me&&wu(Ae),Ae;if(Y){if(Me&&wu(ie),He)for(ct=K.call(ie.ownerDocument);ie.firstChild;)ct.appendChild(ie.firstChild);else ct=ie;return(Ne.shadowroot||Ne.shadowrootmode)&&(ct=I.call(r,ct,!0)),ct}let qt=ot?ie.outerHTML:ie.innerHTML;return ot&&me["!doctype"]&&ie.ownerDocument&&ie.ownerDocument.doctype&&ie.ownerDocument.doctype.name&&on(gq,ie.ownerDocument.doctype.name)&&(qt="<!DOCTYPE "+ie.ownerDocument.doctype.name+`>
297
- `+qt),Me&&(qt=ko(qt)),k&&Ue?B(qt):qt},t.setConfig=function(){let Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Su(Ae),dt=!0,se=me,fe=Ne},t.clearConfig=function(){Fs=null,dt=!1,se=null,fe=null,k=v,S=""},t.isValidAttribute=function(Ae,U,ie){Fs||Su({});const Te=Ut(Ae),$e=Ut(U);return x0(Te,$e,ie)},t.addHook=function(Ae,U){typeof U=="function"&&tn(V,Ae)&&Hs(V[Ae],U)},t.removeHook=function(Ae,U){if(tn(V,Ae)){if(U!==void 0){const ie=QW(V[Ae],U);return ie===-1?void 0:JW(V[Ae],ie,1)[0]}return p1(V[Ae])}},t.removeHooks=function(Ae){tn(V,Ae)&&(V[Ae]=[])},t.removeAllHooks=function(){V=v1()},t}var kk=Tk();const vq=()=>e=>{const t=e,n=kk(window).sanitize(gT(e),{USE_PROFILES:{html:!0},FORBID_TAGS:["style"],FORBID_ATTR:["style"]});t.children=uT(n,{fragment:!0}).children},Ta={pluginsFilter:(e,t)=>e==="rehype"?[...t,vq]:t},Nq=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Tq=function(e){return"/"+e},N1={},Ak=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");s=c(n.map(u=>{if(u=Tq(u),u in N1)return;N1[u]=!0;const d=u.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":Nq,d||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((m,b)=>{f.addEventListener("load",m),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return s.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},kq={USE_PROFILES:{svg:!0,svgFilters:!0,html:!0},ADD_TAGS:["foreignObject"],HTML_INTEGRATION_POINTS:{foreignobject:!0}};function Aq(e){return kk(window).sanitize(e,kq)}function Cq({code:e}){const t=h.useId().replace(/:/g,""),n=h.useRef(null),[r,s]=h.useState(null),[i,o]=h.useState(!1),[l,c]=h.useState("light");return h.useEffect(()=>{if(typeof document>"u")return;const u=document.documentElement.getAttribute("data-theme");(u==="dark"||u==="light")&&c(u)},[]),h.useEffect(()=>{if(typeof MutationObserver>"u"||typeof document>"u")return;const u=new MutationObserver(()=>{const d=document.documentElement.getAttribute("data-theme")||"light";c(d)});return u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>u.disconnect()},[]),h.useEffect(()=>{let u=!1;return(async()=>{try{const d=(await Ak(async()=>{const{default:m}=await import("./mermaid.core.Dixrjrnj.js").then(b=>b.bn);return{default:m}},__vite__mapDeps([0,1]))).default;d.initialize({startOnLoad:!1,securityLevel:"loose",theme:l==="dark"?"dark":"default",fontFamily:"ui-sans-serif, system-ui, -apple-system, sans-serif",flowchart:{htmlLabels:!1,useMaxWidth:!1}});const p=await d.render(`mermaid-${t}`,e),f=Aq(p.svg).replace(/(<svg[^>]*?)\s+width="[^"]*"/,'$1 width="100%"').replace(/(<svg[^>]*?)\s+height="[^"]*"/,'$1 height="auto"');u||s(f)}catch{u||o(!0)}})(),()=>{u=!0}},[e,t,l]),h.useEffect(()=>{n.current&&(n.current.innerHTML=r??"")},[r]),i?a.jsx("pre",{className:"text-xs font-mono p-3 bg-spur-surface-2 rounded border border-spur-border overflow-x-auto",children:a.jsx("code",{children:e})}):a.jsx("div",{ref:n,className:"mermaid-diagram","data-testid":"mermaid-diagram"})}function _q(e){return(e??"").match(/language-(\w+)/)?.[1]??null}function Vi(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Vi).join(""):typeof e=="object"&&"props"in e?Vi(e.props.children):""}function Bx({className:e,children:t,...n}){return _q(e)==="mermaid"?a.jsx(Cq,{code:Vi(t).trim()}):a.jsx("code",{className:e,...n,children:t})}function Ck({source:e,className:t,style:n}){return a.jsx(wa.Markdown,{source:e,className:t,style:n,wrapperElement:{"data-color-mode":"light"},...Ta,components:{code:Bx}})}function Iq(e){if(!e)return[];const t=e.split(/\r?\n/),n=[],r=new Map;let s=!1;for(const i of t){if(i.trim().startsWith("```")){s=!s;continue}if(s)continue;const l=i.match(/^(#{1,6})\s+(.+)$/);if(l?.[1]&&l[2]){const c=l[1].length,d=l[2].trim().replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim(),f=d.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")||`heading-${n.length+1}`,m=r.get(f)??0;r.set(f,m+1);const b=m===0?f:`${f}-${m}`;n.push({id:b,text:d,level:c})}}return n}function Rq(){const e=new Map;return{nextId(t){const r=t.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")||"heading",s=e.get(r)??0;return e.set(r,s+1),s===0?r:`${r}-${s}`}}}function Dq({markdown:e,scrollContainerRef:t,onClose:n}){const r=h.useMemo(()=>Iq(e),[e]),[s,i]=h.useState(null);h.useEffect(()=>{const l=t?.current;if(!l||r.length===0)return;const c=()=>{const u=l.getBoundingClientRect().top;let d=null;for(const p of r){const f=document.getElementById(p.id);f&&f.getBoundingClientRect().top-u<=100&&(d=p.id)}d&&i(d)};return l.addEventListener("scroll",c,{passive:!0}),c(),()=>l.removeEventListener("scroll",c)},[r,t]);const o=l=>{i(l);const c=document.getElementById(l);c&&c.scrollIntoView({behavior:"smooth",block:"start"})};return a.jsxs("aside",{id:"design-toc-dock","aria-label":"Table of Contents",className:"w-64 lg:w-72 shrink-0 rounded-lg border border-spur-border bg-base-200 shadow-xs flex flex-col overflow-hidden 3xl:absolute 3xl:top-0 3xl:bottom-0 3xl:left-[calc(100%_+_12px)] 3xl:z-20 3xl:w-72 4xl:w-80 3xl:shadow-xl","data-testid":"design-toc-dock",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-spur-border bg-base-300/60 shrink-0",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text flex items-center gap-1.5",children:[a.jsx("span",{children:"📑"})," Table of Contents"]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[r.length>0&&a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-spur-accent/15 text-spur-accent font-semibold",children:r.length}),n&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent h-5 w-5 p-0 text-xs flex items-center justify-center cursor-pointer",onClick:n,"aria-label":"Close table of contents",title:"Close table of contents",children:"✕"})]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-1.5 space-y-0.5",children:r.length===0?a.jsx("div",{className:"p-3 text-xs text-spur-text-muted italic",children:"No headings in document."}):r.map(l=>{const c=s===l.id;let u="pl-2 text-xs font-semibold";return l.level===2?u="pl-4 text-xs font-medium":l.level===3?u="pl-6 text-xs text-spur-text-muted":l.level>=4&&(u="pl-8 text-[11px] text-spur-text-muted"),a.jsx("button",{type:"button",onClick:()=>o(l.id),title:l.text,className:`w-full text-left py-1 pr-2 rounded transition-colors truncate block cursor-pointer ${u} ${c?"bg-spur-accent/15 text-spur-accent font-semibold":"hover:bg-base-300 hover:text-spur-text text-spur-text/80"}`,children:l.text},l.id)})})]})}function Oq({source:e,className:t}){const n=Px(e),r=Rq(),s=o=>{const l=`h${o}`;return({children:c,...u})=>{const p=Vi(c).trim().replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim(),f=r.nextId(p);return a.jsx(l,{id:f,className:"scroll-mt-6 group",...u,children:c})}},i={code:Bx,h1:s(1),h2:s(2),h3:s(3),h4:s(4),h5:s(5),h6:s(6)};return a.jsx("div",{className:`design-markdown-container ${t??""}`,"data-testid":"design-markdown-body",children:a.jsx(wa.Markdown,{source:n,wrapperElement:{"data-color-mode":"light"},...Ta,components:i})})}function Lq(){const[e,t]=Ca(),[n,r]=h.useState(null),[s,i]=h.useState(()=>e.get("file")),o=h.useRef({}),[l,c]=h.useState({}),[u,d]=h.useState(!0),[p,f]=h.useState(!0),[m,b]=h.useState(!1),[x,y]=h.useState(!0),[E,A]=h.useState(!1),[w,N]=h.useState(null),[_,k]=h.useState(null),[S,v]=h.useState(!1),O=h.useRef(null),C=h.useRef(null),M=h.useCallback(async I=>{try{y(!0);const V=await IG(I);return r(V),N(null),V}catch(V){return I?.aborted||N(V instanceof Error?V.message:String(V)),null}finally{y(!1)}},[]),B=h.useCallback(async(I,V)=>{if(!o.current[I])try{A(!0),k(null);const te=await RG(I,V);o.current[I]=te,c(L=>({...L,[I]:te}))}catch(te){if(V?.aborted)return;k(te instanceof Error?te.message:String(te))}finally{A(!1)}},[]),R=e.get("file");h.useEffect(()=>{const I=new AbortController;return(async()=>{const V=await M(I.signal);if(V&&V.length>0){if(R&&V.some(L=>L.path===R))i(R);else if(!R){const L=V[0]?.path;L&&i(L)}}})(),()=>I.abort()},[M,R]),h.useEffect(()=>{R&&R!==s&&i(R)},[R,s]),h.useEffect(()=>{if(!s)return;const I=new AbortController;return B(s,I.signal),()=>I.abort()},[s,B]);const z=I=>{i(I),f(!0),t({file:I},{replace:!0}),O.current&&(O.current.scrollTop=0)},W=()=>{s&&(navigator.clipboard.writeText(s),v(!0),setTimeout(()=>v(!1),2e3))},F=s?l[s]:null,{frontmatterRaw:J,frontmatter:K,body:X}=h.useMemo(()=>F?.content?wk(F.content):{frontmatterRaw:null,frontmatter:null,body:""},[F?.content]);return w?a.jsxs("div",{className:"p-4 text-sm text-error",role:"alert",children:["Failed to load design documents: ",w]}):x&&n===null?a.jsx("div",{className:"flex items-center justify-center h-full text-spur-text-muted text-sm",children:"Loading design documents…"}):a.jsxs("div",{className:"relative h-full w-full p-4 overflow-hidden","data-designs-shell":!0,children:[a.jsxs("div",{className:"flex flex-col h-full w-full max-w-full 3xl:max-w-[1200px] 4xl:max-w-[1600px] mx-auto gap-3","data-designs-workspace":!0,children:[a.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-spur-border pb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Rr,{id:"designs",size:"lg",className:"h-7 w-7 text-spur-accent","aria-hidden":"true"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-bold tracking-tight text-spur-text",children:"Designs"}),a.jsx("p",{className:"text-xs text-spur-text-muted",children:"Design documents, architecture specifications, and surface contracts"})]})]}),a.jsxs("div",{className:"flex items-center gap-1","data-designs-actions":!0,children:[a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>d(I=>!I),"aria-label":u?"Collapse design file list":"Expand design file list","aria-expanded":u,"aria-controls":"design-files-dock",title:u?"Collapse design file list":"Expand design file list",children:u?"◧":"▶"}),s&&F?.content&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>f(I=>!I),"aria-label":p?"Collapse table of contents":"Expand table of contents","aria-expanded":p,"aria-controls":"design-toc-dock",title:p?"Collapse table of contents":"Expand table of contents",children:p?"📑":"📖"}),a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>{(async()=>(await M(),s&&(c(I=>{const V={...I};return delete V[s],V}),B(s))))()},"aria-label":"Refresh design documents",title:"Refresh design documents",children:"🔄"})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-stretch gap-3 overflow-hidden 3xl:relative 3xl:block 3xl:overflow-visible",ref:C,children:[a.jsxs("div",{id:"design-files-dock",hidden:!u,className:`${u?"flex":"hidden"} w-64 lg:w-72 shrink-0 flex-col overflow-hidden rounded-lg border border-spur-border bg-base-200 shadow-xs 3xl:absolute 3xl:right-[calc(100%_+_12px)] 3xl:top-0 3xl:bottom-0 3xl:z-20 3xl:w-72 4xl:w-80 3xl:shadow-xl`,"data-testid":"design-files-dock",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-spur-border bg-base-300/60 shrink-0",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text flex items-center gap-1.5",children:[a.jsx("span",{children:"📐"})," Design Docs"]}),n&&n.length>0&&a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-spur-accent/15 text-spur-accent font-semibold",children:n.length})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:n&&n.length>0?a.jsx(HW,{files:n,selectedPath:s,onSelect:z}):a.jsx("div",{className:"p-3 text-xs text-spur-text-muted italic",children:"No design documents found."})})]}),a.jsx("div",{className:"flex-1 min-w-0 h-full overflow-hidden rounded-lg border border-spur-border bg-base-100 relative 3xl:w-full 3xl:flex-none","data-testid":"design-workspace",children:a.jsx("div",{className:"w-full h-full overflow-y-auto",ref:O,children:s?a.jsxs("div",{className:"flex flex-col min-h-full",children:[a.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-3 border-b border-spur-border bg-base-100/90 backdrop-blur-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-base-200 text-spur-text-muted border border-spur-border shrink-0",children:s}),F?.title&&a.jsx("h2",{className:"text-sm font-semibold text-spur-text truncate",children:F.title})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent flex items-center gap-1 shrink-0",onClick:()=>b(!0),"aria-label":"View document metadata",title:"View document metadata","data-testid":"metadata-toggle",children:"ℹ Metadata"}),a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-text shrink-0",onClick:W,"aria-label":"Copy file path",title:"Copy file path",children:S?"✓ Copied":"📋 Copy Path"})]})]}),a.jsx("div",{className:"p-6 md:p-8 flex-1","data-testid":"design-body-container",children:E&&!F?a.jsx("div",{className:"flex items-center justify-center py-20 text-spur-text-muted text-sm",children:"Loading document content…"}):_?a.jsxs("div",{className:"p-4 text-sm text-error bg-error/10 rounded-md border border-error/20",children:["Failed to load document: ",_]}):F?a.jsx(Oq,{source:X}):null})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-spur-text-muted gap-2",children:[a.jsx("span",{className:"text-3xl","aria-hidden":"true",children:"📐"}),a.jsx("span",{className:"text-sm font-medium",children:"Select a design document to view"})]})})}),s&&F?.content&&p&&a.jsx(Dq,{markdown:X,scrollContainerRef:O,onClose:()=>f(!1)})]})]}),a.jsx(NT,{open:m,onClose:()=>b(!1),title:F?.title,filePath:s,frontmatterRaw:J,frontmatter:K})]})}const jq={id:"designs",name:"Designs",icon:"📐",route:"designs",component:Lq,sidebarLabel:"Designs",description:"Design documents, architecture specifications, and surface contracts",order:25},Mq=Object.freeze(Object.defineProperty({__proto__:null,module:jq},Symbol.toStringTag,{value:"Module"})),br=()=>`${it()}/features`;async function Fq(e){const t=await Xe(new Request(br(),{signal:e}));if(!t.ok)throw new Error(`feature list fetch failed: ${t.status}`);const r=await t.json();if(!r.ok||!Array.isArray(r.data))throw new Error("feature list: invalid response shape");return r.data}async function T1(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e)}`,{signal:t}));if(!n.ok)throw new Error(`feature show fetch failed: ${n.status}`);const s=await n.json();if(!s.ok||!s.data)throw new Error("feature show: invalid response shape");return s.data}async function Pq(e,t,n){const r=await Xe(new Request(`${br()}/${encodeURIComponent(e)}/status`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,toStatus:t}),signal:n})),s=await r.json();if(!r.ok){const o=s;throw new Error(o.error?.message??`transition failed: ${r.status}`)}return s.data?.status??t}async function Bq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/body`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const s=await n.json();throw new Error(s.error?.message??`body update failed: ${n.status}`)}}async function $q(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/action`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`action dispatch failed: ${n.status}`)}return await n.json()}async function _k(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/children`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`create child failed: ${n.status}`)}return await n.json()}async function Uq(e,t){const n=await Xe(new Request(br(),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:e}),signal:t}));if(!n.ok){const o=await n.json();throw new Error(o.error?.message??`create feature failed: ${n.status}`)}const s=await n.json();if(!s.ok||!s.data)throw new Error("create feature: invalid response shape");return s.data}async function zq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/tasks`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`create task failed: ${n.status}`)}return await n.json()}async function Hq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/link`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`link task failed: ${n.status}`)}return await n.json()}async function Gq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/sync`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`sync failed: ${n.status}`)}return await n.json()}const nc=new Set,rc=new Set;let ls,$x=!1;function k1(e){$x=e;for(const t of rc)t(e)}function Ik(){if(ls||typeof window>"u"||typeof EventSource>"u")return;const e=new EventSource(`${it()}/events/planning`);ls=e,e.onopen=()=>{ls===e&&k1(!0)},e.onerror=()=>{ls===e&&k1(!1)},e.onmessage=t=>{if(ls!==e)return;let n;try{n=JSON.parse(t.data)}catch{return}if(!n||typeof n!="object"||Array.isArray(n))return;const{eventName:r,payload:s}=n;if(typeof r!="string"||!["task.","feature.","queue.job."].some(o=>r.startsWith(o)))return;const i={eventName:r,payload:s};for(const o of nc)o(i)}}function Rk(){if(nc.size||rc.size)return;const e=ls;ls=void 0,$x=!1,e&&(e.onmessage=null,e.onopen=null,e.onerror=null,e.close())}function mu(e){const t=n=>e(n);return nc.add(t),Ik(),()=>{nc.delete(t),Rk()}}function Dk(e){const t=n=>e(n);return rc.add(t),e($x),Ik(),()=>{rc.delete(t),Rk()}}function ka({targetVar:e,onResizeEnd:t,direction:n="horizontal",invert:r=!1}){const s=h.useRef(null),i=h.useCallback(l=>{l.preventDefault();const c=document.documentElement,d=getComputedStyle(c).getPropertyValue(e).trim(),p=parseFloat(d)||0;s.current={x:l.clientX,y:l.clientY,w:p},l.target.setPointerCapture(l.pointerId);const f=b=>{if(!s.current)return;const x=n==="horizontal"?b.clientX-s.current.x:b.clientY-s.current.y,y=r?-x:x,E=Math.max(0,s.current.w+y);c.style.setProperty(e,`${E}px`)},m=()=>{if(!s.current)return;const b=getComputedStyle(c).getPropertyValue(e).trim(),x=parseFloat(b)||s.current.w;t(Math.round(x)),s.current=null,window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",m)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",m,{once:!0})},[e,t,n,r]),o=n==="horizontal";return a.jsx("hr",{"data-testid":`resize-handle-${o?"h":"v"}`,"aria-orientation":o?"vertical":"horizontal","aria-label":o?"Resize sidebar":"Resize panel",tabIndex:0,className:"resize-handle shrink-0 bg-spur-border hover:bg-spur-accent cursor-col-resize transition-colors border-0",style:{width:o?4:"100%",height:o?"100%":4,margin:0},onPointerDown:i})}const A1="spur:new-task-panel-width",C1=384,hd=384;function _1({id:e,label:t,placeholder:n,value:r,mode:s,onChange:i,onModeChange:o,disabled:l}){return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[a.jsxs("label",{htmlFor:e,className:"text-xs font-semibold text-spur-text-muted uppercase tracking-wide",children:[t," ",a.jsx("span",{className:"text-spur-text-muted font-normal",children:"(optional, markdown)"})]}),a.jsxs("fieldset",{className:"flex items-center gap-1",children:[a.jsxs("legend",{className:"sr-only",children:[t," mode"]}),a.jsx(Ie,{type:"button",variant:s==="edit"?"primary":"ghost",size:"xs",onClick:()=>o("edit"),disabled:l,"aria-pressed":s==="edit",children:"Edit"}),a.jsx(Ie,{type:"button",variant:s==="preview"?"primary":"ghost",size:"xs",onClick:()=>o("preview"),disabled:l,"aria-pressed":s==="preview",children:"Preview"})]})]}),s==="edit"?a.jsx("div",{className:"min-h-40","data-testid":`${e}-editor`,children:a.jsx(wa,{value:r,onChange:c=>i(c??""),height:160,textareaProps:{id:e,placeholder:n,disabled:l,"aria-label":t},"data-color-mode":"dark",previewOptions:Ta})}):a.jsx("div",{className:"min-h-40 rounded border border-spur-border bg-spur-bg p-3 text-sm text-spur-text overflow-y-auto","data-testid":`${e}-preview`,children:r.trim()?a.jsx(wa.Markdown,{source:r,"data-color-mode":"dark",...Ta}):a.jsx("p",{className:"text-xs text-spur-text-muted",children:n})})]})}function Ok({open:e,onClose:t,onCreated:n,folder:r,featureId:s}){const[i,o]=h.useState(""),[l,c]=h.useState(""),[u,d]=h.useState(""),[p,f]=h.useState("edit"),[m,b]=h.useState("edit"),[x,y]=h.useState("standard"),[E,A]=h.useState(!1),[w,N]=h.useState(""),[_,k]=h.useState(!1),[S,v]=h.useState(()=>{if(typeof window>"u")return C1;try{const B=Number.parseFloat(window.localStorage.getItem(A1)??"");if(Number.isFinite(B)&&B>0)return Math.max(hd,Math.min(B,window.innerWidth*.9))}catch{}return C1}),O=_&&i.trim()===""?"Name is required":"";h.useEffect(()=>{document.documentElement.style.setProperty("--new-task-panel-w",`${S}px`)},[S]);const C=()=>{E||(o(""),c(""),d(""),f("edit"),b("edit"),y("standard"),N(""),k(!1),t())},M=async()=>{k(!0);const B=i.trim();if(B!==""){A(!0),N("");try{const z=(await xt.task.create({title:B,folder:r,template:x,featureId:s})).data.wbs,W=[];if(l.trim()&&W.push(`### Background
297
+ `+qt),Me&&(qt=ko(qt)),k&&Ue?B(qt):qt},t.setConfig=function(){let Ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Su(Ae),dt=!0,se=me,fe=Ne},t.clearConfig=function(){Fs=null,dt=!1,se=null,fe=null,k=v,S=""},t.isValidAttribute=function(Ae,U,ie){Fs||Su({});const Te=Ut(Ae),$e=Ut(U);return x0(Te,$e,ie)},t.addHook=function(Ae,U){typeof U=="function"&&tn(V,Ae)&&Hs(V[Ae],U)},t.removeHook=function(Ae,U){if(tn(V,Ae)){if(U!==void 0){const ie=QW(V[Ae],U);return ie===-1?void 0:JW(V[Ae],ie,1)[0]}return p1(V[Ae])}},t.removeHooks=function(Ae){tn(V,Ae)&&(V[Ae]=[])},t.removeAllHooks=function(){V=v1()},t}var kk=Tk();const vq=()=>e=>{const t=e,n=kk(window).sanitize(gT(e),{USE_PROFILES:{html:!0},FORBID_TAGS:["style"],FORBID_ATTR:["style"]});t.children=uT(n,{fragment:!0}).children},Ta={pluginsFilter:(e,t)=>e==="rehype"?[...t,vq]:t},Nq=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Tq=function(e){return"/"+e},N1={},Ak=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let c=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");s=c(n.map(u=>{if(u=Tq(u),u in N1)return;N1[u]=!0;const d=u.endsWith(".css"),p=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${p}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":Nq,d||(f.as="script"),f.crossOrigin="",f.href=u,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((m,b)=>{f.addEventListener("load",m),f.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return s.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},kq={USE_PROFILES:{svg:!0,svgFilters:!0,html:!0},ADD_TAGS:["foreignObject"],HTML_INTEGRATION_POINTS:{foreignobject:!0}};function Aq(e){return kk(window).sanitize(e,kq)}function Cq({code:e}){const t=h.useId().replace(/:/g,""),n=h.useRef(null),[r,s]=h.useState(null),[i,o]=h.useState(!1),[l,c]=h.useState("light");return h.useEffect(()=>{if(typeof document>"u")return;const u=document.documentElement.getAttribute("data-theme");(u==="dark"||u==="light")&&c(u)},[]),h.useEffect(()=>{if(typeof MutationObserver>"u"||typeof document>"u")return;const u=new MutationObserver(()=>{const d=document.documentElement.getAttribute("data-theme")||"light";c(d)});return u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>u.disconnect()},[]),h.useEffect(()=>{let u=!1;return(async()=>{try{const d=(await Ak(async()=>{const{default:m}=await import("./mermaid.core.DO9lF20B.js").then(b=>b.bn);return{default:m}},__vite__mapDeps([0,1]))).default;d.initialize({startOnLoad:!1,securityLevel:"loose",theme:l==="dark"?"dark":"default",fontFamily:"ui-sans-serif, system-ui, -apple-system, sans-serif",flowchart:{htmlLabels:!1,useMaxWidth:!1}});const p=await d.render(`mermaid-${t}`,e),f=Aq(p.svg).replace(/(<svg[^>]*?)\s+width="[^"]*"/,'$1 width="100%"').replace(/(<svg[^>]*?)\s+height="[^"]*"/,'$1 height="auto"');u||s(f)}catch{u||o(!0)}})(),()=>{u=!0}},[e,t,l]),h.useEffect(()=>{n.current&&(n.current.innerHTML=r??"")},[r]),i?a.jsx("pre",{className:"text-xs font-mono p-3 bg-spur-surface-2 rounded border border-spur-border overflow-x-auto",children:a.jsx("code",{children:e})}):a.jsx("div",{ref:n,className:"mermaid-diagram","data-testid":"mermaid-diagram"})}function _q(e){return(e??"").match(/language-(\w+)/)?.[1]??null}function Vi(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Vi).join(""):typeof e=="object"&&"props"in e?Vi(e.props.children):""}function Bx({className:e,children:t,...n}){return _q(e)==="mermaid"?a.jsx(Cq,{code:Vi(t).trim()}):a.jsx("code",{className:e,...n,children:t})}function Ck({source:e,className:t,style:n}){return a.jsx(wa.Markdown,{source:e,className:t,style:n,wrapperElement:{"data-color-mode":"light"},...Ta,components:{code:Bx}})}function Iq(e){if(!e)return[];const t=e.split(/\r?\n/),n=[],r=new Map;let s=!1;for(const i of t){if(i.trim().startsWith("```")){s=!s;continue}if(s)continue;const l=i.match(/^(#{1,6})\s+(.+)$/);if(l?.[1]&&l[2]){const c=l[1].length,d=l[2].trim().replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim(),f=d.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")||`heading-${n.length+1}`,m=r.get(f)??0;r.set(f,m+1);const b=m===0?f:`${f}-${m}`;n.push({id:b,text:d,level:c})}}return n}function Rq(){const e=new Map;return{nextId(t){const r=t.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")||"heading",s=e.get(r)??0;return e.set(r,s+1),s===0?r:`${r}-${s}`}}}function Dq({markdown:e,scrollContainerRef:t,onClose:n}){const r=h.useMemo(()=>Iq(e),[e]),[s,i]=h.useState(null);h.useEffect(()=>{const l=t?.current;if(!l||r.length===0)return;const c=()=>{const u=l.getBoundingClientRect().top;let d=null;for(const p of r){const f=document.getElementById(p.id);f&&f.getBoundingClientRect().top-u<=100&&(d=p.id)}d&&i(d)};return l.addEventListener("scroll",c,{passive:!0}),c(),()=>l.removeEventListener("scroll",c)},[r,t]);const o=l=>{i(l);const c=document.getElementById(l);c&&c.scrollIntoView({behavior:"smooth",block:"start"})};return a.jsxs("aside",{id:"design-toc-dock","aria-label":"Table of Contents",className:"w-64 lg:w-72 shrink-0 rounded-lg border border-spur-border bg-base-200 shadow-xs flex flex-col overflow-hidden 3xl:absolute 3xl:top-0 3xl:bottom-0 3xl:left-[calc(100%_+_12px)] 3xl:z-20 3xl:w-72 4xl:w-80 3xl:shadow-xl","data-testid":"design-toc-dock",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-spur-border bg-base-300/60 shrink-0",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text flex items-center gap-1.5",children:[a.jsx("span",{children:"📑"})," Table of Contents"]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[r.length>0&&a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-spur-accent/15 text-spur-accent font-semibold",children:r.length}),n&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent h-5 w-5 p-0 text-xs flex items-center justify-center cursor-pointer",onClick:n,"aria-label":"Close table of contents",title:"Close table of contents",children:"✕"})]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-1.5 space-y-0.5",children:r.length===0?a.jsx("div",{className:"p-3 text-xs text-spur-text-muted italic",children:"No headings in document."}):r.map(l=>{const c=s===l.id;let u="pl-2 text-xs font-semibold";return l.level===2?u="pl-4 text-xs font-medium":l.level===3?u="pl-6 text-xs text-spur-text-muted":l.level>=4&&(u="pl-8 text-[11px] text-spur-text-muted"),a.jsx("button",{type:"button",onClick:()=>o(l.id),title:l.text,className:`w-full text-left py-1 pr-2 rounded transition-colors truncate block cursor-pointer ${u} ${c?"bg-spur-accent/15 text-spur-accent font-semibold":"hover:bg-base-300 hover:text-spur-text text-spur-text/80"}`,children:l.text},l.id)})})]})}function Oq({source:e,className:t}){const n=Px(e),r=Rq(),s=o=>{const l=`h${o}`;return({children:c,...u})=>{const p=Vi(c).trim().replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").trim(),f=r.nextId(p);return a.jsx(l,{id:f,className:"scroll-mt-6 group",...u,children:c})}},i={code:Bx,h1:s(1),h2:s(2),h3:s(3),h4:s(4),h5:s(5),h6:s(6)};return a.jsx("div",{className:`design-markdown-container ${t??""}`,"data-testid":"design-markdown-body",children:a.jsx(wa.Markdown,{source:n,wrapperElement:{"data-color-mode":"light"},...Ta,components:i})})}function Lq(){const[e,t]=Ca(),[n,r]=h.useState(null),[s,i]=h.useState(()=>e.get("file")),o=h.useRef({}),[l,c]=h.useState({}),[u,d]=h.useState(!0),[p,f]=h.useState(!0),[m,b]=h.useState(!1),[x,y]=h.useState(!0),[E,A]=h.useState(!1),[w,N]=h.useState(null),[_,k]=h.useState(null),[S,v]=h.useState(!1),O=h.useRef(null),C=h.useRef(null),M=h.useCallback(async I=>{try{y(!0);const V=await IG(I);return r(V),N(null),V}catch(V){return I?.aborted||N(V instanceof Error?V.message:String(V)),null}finally{y(!1)}},[]),B=h.useCallback(async(I,V)=>{if(!o.current[I])try{A(!0),k(null);const te=await RG(I,V);o.current[I]=te,c(L=>({...L,[I]:te}))}catch(te){if(V?.aborted)return;k(te instanceof Error?te.message:String(te))}finally{A(!1)}},[]),R=e.get("file");h.useEffect(()=>{const I=new AbortController;return(async()=>{const V=await M(I.signal);if(V&&V.length>0){if(R&&V.some(L=>L.path===R))i(R);else if(!R){const L=V[0]?.path;L&&i(L)}}})(),()=>I.abort()},[M,R]),h.useEffect(()=>{R&&R!==s&&i(R)},[R,s]),h.useEffect(()=>{if(!s)return;const I=new AbortController;return B(s,I.signal),()=>I.abort()},[s,B]);const z=I=>{i(I),f(!0),t({file:I},{replace:!0}),O.current&&(O.current.scrollTop=0)},W=()=>{s&&(navigator.clipboard.writeText(s),v(!0),setTimeout(()=>v(!1),2e3))},F=s?l[s]:null,{frontmatterRaw:J,frontmatter:K,body:X}=h.useMemo(()=>F?.content?wk(F.content):{frontmatterRaw:null,frontmatter:null,body:""},[F?.content]);return w?a.jsxs("div",{className:"p-4 text-sm text-error",role:"alert",children:["Failed to load design documents: ",w]}):x&&n===null?a.jsx("div",{className:"flex items-center justify-center h-full text-spur-text-muted text-sm",children:"Loading design documents…"}):a.jsxs("div",{className:"relative h-full w-full p-4 overflow-hidden","data-designs-shell":!0,children:[a.jsxs("div",{className:"flex flex-col h-full w-full max-w-full 3xl:max-w-[1200px] 4xl:max-w-[1600px] mx-auto gap-3","data-designs-workspace":!0,children:[a.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-4 border-b border-spur-border pb-3 shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Rr,{id:"designs",size:"lg",className:"h-7 w-7 text-spur-accent","aria-hidden":"true"}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-bold tracking-tight text-spur-text",children:"Designs"}),a.jsx("p",{className:"text-xs text-spur-text-muted",children:"Design documents, architecture specifications, and surface contracts"})]})]}),a.jsxs("div",{className:"flex items-center gap-1","data-designs-actions":!0,children:[a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>d(I=>!I),"aria-label":u?"Collapse design file list":"Expand design file list","aria-expanded":u,"aria-controls":"design-files-dock",title:u?"Collapse design file list":"Expand design file list",children:u?"◧":"▶"}),s&&F?.content&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>f(I=>!I),"aria-label":p?"Collapse table of contents":"Expand table of contents","aria-expanded":p,"aria-controls":"design-toc-dock",title:p?"Collapse table of contents":"Expand table of contents",children:p?"📑":"📖"}),a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent",onClick:()=>{(async()=>(await M(),s&&(c(I=>{const V={...I};return delete V[s],V}),B(s))))()},"aria-label":"Refresh design documents",title:"Refresh design documents",children:"🔄"})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex items-stretch gap-3 overflow-hidden 3xl:relative 3xl:block 3xl:overflow-visible",ref:C,children:[a.jsxs("div",{id:"design-files-dock",hidden:!u,className:`${u?"flex":"hidden"} w-64 lg:w-72 shrink-0 flex-col overflow-hidden rounded-lg border border-spur-border bg-base-200 shadow-xs 3xl:absolute 3xl:right-[calc(100%_+_12px)] 3xl:top-0 3xl:bottom-0 3xl:z-20 3xl:w-72 4xl:w-80 3xl:shadow-xl`,"data-testid":"design-files-dock",children:[a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-spur-border bg-base-300/60 shrink-0",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text flex items-center gap-1.5",children:[a.jsx("span",{children:"📐"})," Design Docs"]}),n&&n.length>0&&a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-spur-accent/15 text-spur-accent font-semibold",children:n.length})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:n&&n.length>0?a.jsx(HW,{files:n,selectedPath:s,onSelect:z}):a.jsx("div",{className:"p-3 text-xs text-spur-text-muted italic",children:"No design documents found."})})]}),a.jsx("div",{className:"flex-1 min-w-0 h-full overflow-hidden rounded-lg border border-spur-border bg-base-100 relative 3xl:w-full 3xl:flex-none","data-testid":"design-workspace",children:a.jsx("div",{className:"w-full h-full overflow-y-auto",ref:O,children:s?a.jsxs("div",{className:"flex flex-col min-h-full",children:[a.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-6 py-3 border-b border-spur-border bg-base-100/90 backdrop-blur-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"text-xs font-mono px-2 py-0.5 rounded bg-base-200 text-spur-text-muted border border-spur-border shrink-0",children:s}),F?.title&&a.jsx("h2",{className:"text-sm font-semibold text-spur-text truncate",children:F.title})]}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-accent flex items-center gap-1 shrink-0",onClick:()=>b(!0),"aria-label":"View document metadata",title:"View document metadata","data-testid":"metadata-toggle",children:"ℹ Metadata"}),a.jsx(Ie,{variant:"ghost",size:"xs",className:"text-spur-text-muted hover:text-spur-text shrink-0",onClick:W,"aria-label":"Copy file path",title:"Copy file path",children:S?"✓ Copied":"📋 Copy Path"})]})]}),a.jsx("div",{className:"p-6 md:p-8 flex-1","data-testid":"design-body-container",children:E&&!F?a.jsx("div",{className:"flex items-center justify-center py-20 text-spur-text-muted text-sm",children:"Loading document content…"}):_?a.jsxs("div",{className:"p-4 text-sm text-error bg-error/10 rounded-md border border-error/20",children:["Failed to load document: ",_]}):F?a.jsx(Oq,{source:X}):null})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-spur-text-muted gap-2",children:[a.jsx("span",{className:"text-3xl","aria-hidden":"true",children:"📐"}),a.jsx("span",{className:"text-sm font-medium",children:"Select a design document to view"})]})})}),s&&F?.content&&p&&a.jsx(Dq,{markdown:X,scrollContainerRef:O,onClose:()=>f(!1)})]})]}),a.jsx(NT,{open:m,onClose:()=>b(!1),title:F?.title,filePath:s,frontmatterRaw:J,frontmatter:K})]})}const jq={id:"designs",name:"Designs",icon:"📐",route:"designs",component:Lq,sidebarLabel:"Designs",description:"Design documents, architecture specifications, and surface contracts",order:25},Mq=Object.freeze(Object.defineProperty({__proto__:null,module:jq},Symbol.toStringTag,{value:"Module"})),br=()=>`${it()}/features`;async function Fq(e){const t=await Xe(new Request(br(),{signal:e}));if(!t.ok)throw new Error(`feature list fetch failed: ${t.status}`);const r=await t.json();if(!r.ok||!Array.isArray(r.data))throw new Error("feature list: invalid response shape");return r.data}async function T1(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e)}`,{signal:t}));if(!n.ok)throw new Error(`feature show fetch failed: ${n.status}`);const s=await n.json();if(!s.ok||!s.data)throw new Error("feature show: invalid response shape");return s.data}async function Pq(e,t,n){const r=await Xe(new Request(`${br()}/${encodeURIComponent(e)}/status`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,toStatus:t}),signal:n})),s=await r.json();if(!r.ok){const o=s;throw new Error(o.error?.message??`transition failed: ${r.status}`)}return s.data?.status??t}async function Bq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/body`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const s=await n.json();throw new Error(s.error?.message??`body update failed: ${n.status}`)}}async function $q(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/action`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`action dispatch failed: ${n.status}`)}return await n.json()}async function _k(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/children`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`create child failed: ${n.status}`)}return await n.json()}async function Uq(e,t){const n=await Xe(new Request(br(),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:e}),signal:t}));if(!n.ok){const o=await n.json();throw new Error(o.error?.message??`create feature failed: ${n.status}`)}const s=await n.json();if(!s.ok||!s.data)throw new Error("create feature: invalid response shape");return s.data}async function zq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/tasks`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`create task failed: ${n.status}`)}return await n.json()}async function Hq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/link`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`link task failed: ${n.status}`)}return await n.json()}async function Gq(e,t){const n=await Xe(new Request(`${br()}/${encodeURIComponent(e.id)}/sync`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),signal:t}));if(!n.ok){const i=await n.json();throw new Error(i.error?.message??`sync failed: ${n.status}`)}return await n.json()}const nc=new Set,rc=new Set;let ls,$x=!1;function k1(e){$x=e;for(const t of rc)t(e)}function Ik(){if(ls||typeof window>"u"||typeof EventSource>"u")return;const e=new EventSource(`${it()}/events/planning`);ls=e,e.onopen=()=>{ls===e&&k1(!0)},e.onerror=()=>{ls===e&&k1(!1)},e.onmessage=t=>{if(ls!==e)return;let n;try{n=JSON.parse(t.data)}catch{return}if(!n||typeof n!="object"||Array.isArray(n))return;const{eventName:r,payload:s}=n;if(typeof r!="string"||!["task.","feature.","queue.job."].some(o=>r.startsWith(o)))return;const i={eventName:r,payload:s};for(const o of nc)o(i)}}function Rk(){if(nc.size||rc.size)return;const e=ls;ls=void 0,$x=!1,e&&(e.onmessage=null,e.onopen=null,e.onerror=null,e.close())}function mu(e){const t=n=>e(n);return nc.add(t),Ik(),()=>{nc.delete(t),Rk()}}function Dk(e){const t=n=>e(n);return rc.add(t),e($x),Ik(),()=>{rc.delete(t),Rk()}}function ka({targetVar:e,onResizeEnd:t,direction:n="horizontal",invert:r=!1}){const s=h.useRef(null),i=h.useCallback(l=>{l.preventDefault();const c=document.documentElement,d=getComputedStyle(c).getPropertyValue(e).trim(),p=parseFloat(d)||0;s.current={x:l.clientX,y:l.clientY,w:p},l.target.setPointerCapture(l.pointerId);const f=b=>{if(!s.current)return;const x=n==="horizontal"?b.clientX-s.current.x:b.clientY-s.current.y,y=r?-x:x,E=Math.max(0,s.current.w+y);c.style.setProperty(e,`${E}px`)},m=()=>{if(!s.current)return;const b=getComputedStyle(c).getPropertyValue(e).trim(),x=parseFloat(b)||s.current.w;t(Math.round(x)),s.current=null,window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",m)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",m,{once:!0})},[e,t,n,r]),o=n==="horizontal";return a.jsx("hr",{"data-testid":`resize-handle-${o?"h":"v"}`,"aria-orientation":o?"vertical":"horizontal","aria-label":o?"Resize sidebar":"Resize panel",tabIndex:0,className:"resize-handle shrink-0 bg-spur-border hover:bg-spur-accent cursor-col-resize transition-colors border-0",style:{width:o?4:"100%",height:o?"100%":4,margin:0},onPointerDown:i})}const A1="spur:new-task-panel-width",C1=384,hd=384;function _1({id:e,label:t,placeholder:n,value:r,mode:s,onChange:i,onModeChange:o,disabled:l}){return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[a.jsxs("label",{htmlFor:e,className:"text-xs font-semibold text-spur-text-muted uppercase tracking-wide",children:[t," ",a.jsx("span",{className:"text-spur-text-muted font-normal",children:"(optional, markdown)"})]}),a.jsxs("fieldset",{className:"flex items-center gap-1",children:[a.jsxs("legend",{className:"sr-only",children:[t," mode"]}),a.jsx(Ie,{type:"button",variant:s==="edit"?"primary":"ghost",size:"xs",onClick:()=>o("edit"),disabled:l,"aria-pressed":s==="edit",children:"Edit"}),a.jsx(Ie,{type:"button",variant:s==="preview"?"primary":"ghost",size:"xs",onClick:()=>o("preview"),disabled:l,"aria-pressed":s==="preview",children:"Preview"})]})]}),s==="edit"?a.jsx("div",{className:"min-h-40","data-testid":`${e}-editor`,children:a.jsx(wa,{value:r,onChange:c=>i(c??""),height:160,textareaProps:{id:e,placeholder:n,disabled:l,"aria-label":t},"data-color-mode":"dark",previewOptions:Ta})}):a.jsx("div",{className:"min-h-40 rounded border border-spur-border bg-spur-bg p-3 text-sm text-spur-text overflow-y-auto","data-testid":`${e}-preview`,children:r.trim()?a.jsx(wa.Markdown,{source:r,"data-color-mode":"dark",...Ta}):a.jsx("p",{className:"text-xs text-spur-text-muted",children:n})})]})}function Ok({open:e,onClose:t,onCreated:n,folder:r,featureId:s}){const[i,o]=h.useState(""),[l,c]=h.useState(""),[u,d]=h.useState(""),[p,f]=h.useState("edit"),[m,b]=h.useState("edit"),[x,y]=h.useState("standard"),[E,A]=h.useState(!1),[w,N]=h.useState(""),[_,k]=h.useState(!1),[S,v]=h.useState(()=>{if(typeof window>"u")return C1;try{const B=Number.parseFloat(window.localStorage.getItem(A1)??"");if(Number.isFinite(B)&&B>0)return Math.max(hd,Math.min(B,window.innerWidth*.9))}catch{}return C1}),O=_&&i.trim()===""?"Name is required":"";h.useEffect(()=>{document.documentElement.style.setProperty("--new-task-panel-w",`${S}px`)},[S]);const C=()=>{E||(o(""),c(""),d(""),f("edit"),b("edit"),y("standard"),N(""),k(!1),t())},M=async()=>{k(!0);const B=i.trim();if(B!==""){A(!0),N("");try{const z=(await xt.task.create({title:B,folder:r,template:x,featureId:s})).data.wbs,W=[];if(l.trim()&&W.push(`### Background
298
298
  ${l.trim()}`),u.trim()&&W.push(`### Requirements
299
299
  ${u.trim()}`),W.length>0)try{await xt.task.body({wbs:z,body:W.join(`
300
300
 
@@ -316,5 +316,5 @@ ${S}
316
316
  To pick up a draggable item, press the space bar.
317
317
  While dragging, use the arrow keys to move the item.
318
318
  Press space again to drop the item in its new position, or press escape to cancel.
319
- `},LX={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function jX(e){let{announcements:t=LX,container:n,hiddenTextDescribedById:r,screenReaderInstructions:s=OX}=e;const{announce:i,announcement:o}=IX(),l=xu("DndLiveRegion"),[c,u]=h.useState(!1);if(h.useEffect(()=>{u(!0)},[]),RX(h.useMemo(()=>({onDragStart(p){let{active:f}=p;i(t.onDragStart({active:f}))},onDragMove(p){let{active:f,over:m}=p;t.onDragMove&&i(t.onDragMove({active:f,over:m}))},onDragOver(p){let{active:f,over:m}=p;i(t.onDragOver({active:f,over:m}))},onDragEnd(p){let{active:f,over:m}=p;i(t.onDragEnd({active:f,over:m}))},onDragCancel(p){let{active:f,over:m}=p;i(t.onDragCancel({active:f,over:m}))}}),[i,t])),!c)return null;const d=st.createElement(st.Fragment,null,st.createElement(CX,{id:r,value:s.draggable}),st.createElement(_X,{id:l,announcement:o}));return n?Ur.createPortal(d,n):d}var Zt;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Zt||(Zt={}));function pc(){}function hS(e,t){return h.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function MX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Zn=Object.freeze({x:0,y:0});function FX(e,t){const n=dc(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function PX(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function BX(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function $X(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,l=i-n;if(r<s&&n<i){const c=t.width*t.height,u=e.width*e.height,d=o*l,p=d/(c+u-d);return Number(p.toFixed(4))}return 0}const UX=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=[];for(const i of r){const{id:o}=i,l=n.get(o);if(l){const c=$X(l,t);c>0&&s.push({id:o,data:{droppableContainer:i,value:c}})}}return s.sort(PX)};function zX(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function IA(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Zn}function HX(e){return function(n){for(var r=arguments.length,s=new Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((o,l)=>({...o,top:o.top+e*l.y,bottom:o.bottom+e*l.y,left:o.left+e*l.x,right:o.right+e*l.x}),{...n})}}const GX=HX(1);function RA(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function WX(e,t,n){const r=RA(t);if(!r)return e;const{scaleX:s,scaleY:i,x:o,y:l}=r,c=e.left-o-(1-s)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,p=i?e.height/i:e.height;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c}}const qX={ignoreTransform:!1};function No(e,t){t===void 0&&(t=qX);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:d}=Nn(e).getComputedStyle(e);u&&(n=WX(n,u,d))}const{top:r,left:s,width:i,height:o,bottom:l,right:c}=n;return{top:r,left:s,width:i,height:o,bottom:l,right:c}}function gS(e){return No(e,{ignoreTransform:!0})}function VX(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function YX(e,t){return t===void 0&&(t=Nn(e).getComputedStyle(e)),t.position==="fixed"}function KX(e,t){t===void 0&&(t=Nn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=t[s];return typeof i=="string"?n.test(i):!1})}function r0(e,t){const n=[];function r(s){if(t!=null&&n.length>=t||!s)return n;if(t0(s)&&s.scrollingElement!=null&&!n.includes(s.scrollingElement))return n.push(s.scrollingElement),n;if(!wo(s)||AA(s)||n.includes(s))return n;const i=Nn(e).getComputedStyle(s);return s!==e&&KX(s,i)&&n.push(s),YX(s,i)?n:r(s.parentNode)}return e?r(e):n}function DA(e){const[t]=r0(e,1);return t??null}function Od(e){return!gu||!e?null:Va(e)?e:e0(e)?t0(e)||e===Ya(e).scrollingElement?window:wo(e)?e:null:null}function OA(e){return Va(e)?e.scrollX:e.scrollLeft}function LA(e){return Va(e)?e.scrollY:e.scrollTop}function Pp(e){return{x:OA(e),y:LA(e)}}var rn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(rn||(rn={}));function jA(e){return!gu||!e?!1:e===document.scrollingElement}function MA(e){const t={x:0,y:0},n=jA(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},s=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,o=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:s,isLeft:i,isBottom:o,isRight:l,maxScroll:r,minScroll:t}}const ZX={x:.2,y:.2};function XX(e,t,n,r,s){let{top:i,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),s===void 0&&(s=ZX);const{isTop:u,isBottom:d,isLeft:p,isRight:f}=MA(e),m={x:0,y:0},b={x:0,y:0},x={height:t.height*s.y,width:t.width*s.x};return!u&&i<=t.top+x.height?(m.y=rn.Backward,b.y=r*Math.abs((t.top+x.height-i)/x.height)):!d&&c>=t.bottom-x.height&&(m.y=rn.Forward,b.y=r*Math.abs((t.bottom-x.height-c)/x.height)),!f&&l>=t.right-x.width?(m.x=rn.Forward,b.x=r*Math.abs((t.right-x.width-l)/x.width)):!p&&o<=t.left+x.width&&(m.x=rn.Backward,b.x=r*Math.abs((t.left+x.width-o)/x.width)),{direction:m,speed:b}}function QX(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:t,left:n,right:r,bottom:s}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:s,width:e.clientWidth,height:e.clientHeight}}function FA(e){return e.reduce((t,n)=>ha(t,Pp(n)),Zn)}function JX(e){return e.reduce((t,n)=>t+OA(n),0)}function eQ(e){return e.reduce((t,n)=>t+LA(n),0)}function PA(e,t){if(t===void 0&&(t=No),!e)return;const{top:n,left:r,bottom:s,right:i}=t(e);DA(e)&&(s<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const tQ=[["x",["left","right"],JX],["y",["top","bottom"],eQ]];class s0{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=r0(n),s=FA(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,o,l]of tQ)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=s[i]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ri{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var s;(s=this.target)==null||s.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function nQ(e){const{EventTarget:t}=Nn(e);return e instanceof t?e:Ya(e)}function Ld(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var jn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(jn||(jn={}));function bS(e){e.preventDefault()}function rQ(e){e.stopPropagation()}var It;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(It||(It={}));const BA={start:[It.Space,It.Enter],cancel:[It.Esc],end:[It.Space,It.Enter,It.Tab]},sQ=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case It.Right:return{...n,x:n.x+25};case It.Left:return{...n,x:n.x-25};case It.Down:return{...n,y:n.y+25};case It.Up:return{...n,y:n.y-25}}};class a0{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ri(Ya(n)),this.windowListeners=new Ri(Nn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(jn.Resize,this.handleCancel),this.windowListeners.add(jn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(jn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&PA(r),n(Zn)}handleKeyDown(t){if(n0(t)){const{active:n,context:r,options:s}=this.props,{keyboardCodes:i=BA,coordinateGetter:o=sQ,scrollBehavior:l="smooth"}=s,{code:c}=t;if(i.end.includes(c)){this.handleEnd(t);return}if(i.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Zn;this.referenceCoordinates||(this.referenceCoordinates=d);const p=o(t,{active:n,context:r.current,currentCoordinates:d});if(p){const f=uc(p,d),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const x of b){const y=t.code,{isTop:E,isRight:A,isLeft:w,isBottom:N,maxScroll:_,minScroll:k}=MA(x),S=QX(x),v={x:Math.min(y===It.Right?S.right-S.width/2:S.right,Math.max(y===It.Right?S.left:S.left+S.width/2,p.x)),y:Math.min(y===It.Down?S.bottom-S.height/2:S.bottom,Math.max(y===It.Down?S.top:S.top+S.height/2,p.y))},O=y===It.Right&&!A||y===It.Left&&!w,C=y===It.Down&&!N||y===It.Up&&!E;if(O&&v.x!==p.x){const M=x.scrollLeft+f.x,B=y===It.Right&&M<=_.x||y===It.Left&&M>=k.x;if(B&&!f.y){x.scrollTo({left:M,behavior:l});return}B?m.x=x.scrollLeft-M:m.x=y===It.Right?x.scrollLeft-_.x:x.scrollLeft-k.x,m.x&&x.scrollBy({left:-m.x,behavior:l});break}else if(C&&v.y!==p.y){const M=x.scrollTop+f.y,B=y===It.Down&&M<=_.y||y===It.Up&&M>=k.y;if(B&&!f.x){x.scrollTo({top:M,behavior:l});return}B?m.y=x.scrollTop-M:m.y=y===It.Down?x.scrollTop-_.y:x.scrollTop-k.y,m.y&&x.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(t,ha(uc(p,this.referenceCoordinates),m))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}a0.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=BA,onActivation:s}=t,{active:i}=n;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),s?.({event:e.nativeEvent}),!0)}return!1}}];function xS(e){return!!(e&&"distance"in e)}function yS(e){return!!(e&&"delay"in e)}class i0{constructor(t,n,r){var s;r===void 0&&(r=nQ(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:o}=i;this.props=t,this.events=n,this.document=Ya(o),this.documentListeners=new Ri(this.document),this.listeners=new Ri(r),this.windowListeners=new Ri(Nn(o)),this.initialCoordinates=(s=dc(i))!=null?s:Zn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(jn.Resize,this.handleCancel),this.windowListeners.add(jn.DragStart,bS),this.windowListeners.add(jn.VisibilityChange,this.handleCancel),this.windowListeners.add(jn.ContextMenu,bS),this.documentListeners.add(jn.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(yS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(xS(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:s}=this.props;s(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(jn.Click,rQ,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(jn.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:s,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!s)return;const c=(n=dc(t))!=null?n:Zn,u=uc(s,c);if(!r&&l){if(xS(l)){if(l.tolerance!=null&&Ld(u,l.tolerance))return this.handleCancel();if(Ld(u,l.distance))return this.handleStart()}if(yS(l)&&Ld(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),o(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===It.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const aQ={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class o0 extends i0{constructor(t){const{event:n}=t,r=Ya(n.target);super(t,aQ,r)}}o0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const iQ={move:{name:"mousemove"},end:{name:"mouseup"}};var Bp;(function(e){e[e.RightClick=2]="RightClick"})(Bp||(Bp={}));class oQ extends i0{constructor(t){super(t,iQ,Ya(t.event.target))}}oQ.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Bp.RightClick?!1:(r?.({event:n}),!0)}}];const jd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class lQ extends i0{constructor(t){super(t,jd)}static setup(){return window.addEventListener(jd.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(jd.move.name,t)};function t(){}}}lQ.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:s}=n;return s.length>1?!1:(r?.({event:n}),!0)}}];var Di;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Di||(Di={}));var fc;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(fc||(fc={}));function cQ(e){let{acceleration:t,activator:n=Di.Pointer,canScroll:r,draggingRect:s,enabled:i,interval:o=5,order:l=fc.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:p,threshold:f}=e;const m=dQ({delta:p,disabled:!i}),[b,x]=vX(),y=h.useRef({x:0,y:0}),E=h.useRef({x:0,y:0}),A=h.useMemo(()=>{switch(n){case Di.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Di.DraggableRect:return s}},[n,s,c]),w=h.useRef(null),N=h.useCallback(()=>{const k=w.current;if(!k)return;const S=y.current.x*E.current.x,v=y.current.y*E.current.y;k.scrollBy(S,v)},[]),_=h.useMemo(()=>l===fc.TreeOrder?[...u].reverse():u,[l,u]);h.useEffect(()=>{if(!i||!u.length||!A){x();return}for(const k of _){if(r?.(k)===!1)continue;const S=u.indexOf(k),v=d[S];if(!v)continue;const{direction:O,speed:C}=XX(k,v,A,t,f);for(const M of["x","y"])m[M][O[M]]||(C[M]=0,O[M]=0);if(C.x>0||C.y>0){x(),w.current=k,b(N,o),y.current=C,E.current=O;return}}y.current={x:0,y:0},E.current={x:0,y:0},x()},[t,N,r,x,i,o,JSON.stringify(A),JSON.stringify(m),b,u,_,d,JSON.stringify(f)])}const uQ={x:{[rn.Backward]:!1,[rn.Forward]:!1},y:{[rn.Backward]:!1,[rn.Forward]:!1}};function dQ(e){let{delta:t,disabled:n}=e;const r=cc(t);return vo(s=>{if(n||!r||!s)return uQ;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[rn.Backward]:s.x[rn.Backward]||i.x===-1,[rn.Forward]:s.x[rn.Forward]||i.x===1},y:{[rn.Backward]:s.y[rn.Backward]||i.y===-1,[rn.Forward]:s.y[rn.Forward]||i.y===1}}},[n,t,r])}function pQ(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return vo(s=>{var i;return t==null?null:(i=r??s)!=null?i:null},[r,t])}function fQ(e,t){return h.useMemo(()=>e.reduce((n,r)=>{const{sensor:s}=r,i=s.activators.map(o=>({eventName:o.eventName,handler:t(o.handler,r)}));return[...n,...i]},[]),[e,t])}var Xi;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Xi||(Xi={}));var $p;(function(e){e.Optimized="optimized"})($p||($p={}));const ES=new Map;function mQ(e,t){let{dragging:n,dependencies:r,config:s}=t;const[i,o]=h.useState(null),{frequency:l,measure:c,strategy:u}=s,d=h.useRef(e),p=y(),f=Zi(p),m=h.useCallback(function(E){E===void 0&&(E=[]),!f.current&&o(A=>A===null?E:A.concat(E.filter(w=>!A.includes(w))))},[f]),b=h.useRef(null),x=vo(E=>{if(p&&!n)return ES;if(!E||E===ES||d.current!==e||i!=null){const A=new Map;for(let w of e){if(!w)continue;if(i&&i.length>0&&!i.includes(w.id)&&w.rect.current){A.set(w.id,w.rect.current);continue}const N=w.node.current,_=N?new s0(c(N),N):null;w.rect.current=_,_&&A.set(w.id,_)}return A}return E},[e,i,n,p,c]);return h.useEffect(()=>{d.current=e},[e]),h.useEffect(()=>{p||m()},[n,p]),h.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),h.useEffect(()=>{p||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},l))},[l,p,m,...r]),{droppableRects:x,measureDroppableContainers:m,measuringScheduled:i!=null};function y(){switch(u){case Xi.Always:return!1;case Xi.BeforeDragging:return n;default:return!n}}}function l0(e,t){return vo(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function hQ(e,t){return l0(e,t)}function gQ(e){let{callback:t,disabled:n}=e;const r=bu(t),s=h.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return h.useEffect(()=>()=>s?.disconnect(),[s]),s}function yu(e){let{callback:t,disabled:n}=e;const r=bu(t),s=h.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return h.useEffect(()=>()=>s?.disconnect(),[s]),s}function bQ(e){return new s0(No(e),e)}function SS(e,t,n){t===void 0&&(t=bQ);const[r,s]=h.useState(null);function i(){s(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=t(e);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=gQ({callback(c){if(e)for(const u of c){const{type:d,target:p}=u;if(d==="childList"&&p instanceof HTMLElement&&p.contains(e)){i();break}}}}),l=yu({callback:i});return _r(()=>{i(),e?(l?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[e]),r}function xQ(e){const t=l0(e);return IA(e,t)}const wS=[];function yQ(e){const t=h.useRef(e),n=vo(r=>e?r&&r!==wS&&e&&t.current&&e.parentNode===t.current.parentNode?r:r0(e):wS,[e]);return h.useEffect(()=>{t.current=e},[e]),n}function EQ(e){const[t,n]=h.useState(null),r=h.useRef(e),s=h.useCallback(i=>{const o=Od(i.target);o&&n(l=>l?(l.set(o,Pp(o)),new Map(l)):null)},[]);return h.useEffect(()=>{const i=r.current;if(e!==i){o(i);const l=e.map(c=>{const u=Od(c);return u?(u.addEventListener("scroll",s,{passive:!0}),[u,Pp(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=e}return()=>{o(e),o(i)};function o(l){l.forEach(c=>{const u=Od(c);u?.removeEventListener("scroll",s)})}},[s,e]),h.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,o)=>ha(i,o),Zn):FA(e):Zn,[e,t])}function vS(e,t){t===void 0&&(t=[]);const n=h.useRef(null);return h.useEffect(()=>{n.current=null},t),h.useEffect(()=>{const r=e!==Zn;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?uc(e,n.current):Zn}function SQ(e){h.useEffect(()=>{if(!gu)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function wQ(e,t){return h.useMemo(()=>e.reduce((n,r)=>{let{eventName:s,handler:i}=r;return n[s]=o=>{i(o,t)},n},{}),[e,t])}function $A(e){return h.useMemo(()=>e?VX(e):null,[e])}const NS=[];function vQ(e,t){t===void 0&&(t=No);const[n]=e,r=$A(n?Nn(n):null),[s,i]=h.useState(NS);function o(){i(()=>e.length?e.map(c=>jA(c)?r:new s0(t(c),c)):NS)}const l=yu({callback:o});return _r(()=>{l?.disconnect(),o(),e.forEach(c=>l?.observe(c))},[e]),s}function UA(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wo(t)?t:e}function NQ(e){let{measure:t}=e;const[n,r]=h.useState(null),s=h.useCallback(u=>{for(const{target:d}of u)if(wo(d)){r(p=>{const f=t(d);return p?{...p,width:f.width,height:f.height}:f});break}},[t]),i=yu({callback:s}),o=h.useCallback(u=>{const d=UA(u);i?.disconnect(),d&&i?.observe(d),r(d?t(d):null)},[t,i]),[l,c]=lc(o);return h.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const TQ=[{sensor:o0,options:{}},{sensor:a0,options:{}}],kQ={current:{}},Il={draggable:{measure:gS},droppable:{measure:gS,strategy:Xi.WhileDragging,frequency:$p.Optimized},dragOverlay:{measure:No}};class Oi extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const AQ={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Oi,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:pc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Il,measureDroppableContainers:pc,windowRect:null,measuringScheduled:!1},zA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:pc,draggableNodes:new Map,over:null,measureDroppableContainers:pc},To=h.createContext(zA),HA=h.createContext(AQ);function CQ(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Oi}}}function _Q(e,t){switch(t.type){case Zt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Zt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Zt.DragEnd:case Zt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Zt.RegisterDroppable:{const{element:n}=t,{id:r}=n,s=new Oi(e.droppable.containers);return s.set(r,n),{...e,droppable:{...e.droppable,containers:s}}}case Zt.SetDroppableDisabled:{const{id:n,key:r,disabled:s}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new Oi(e.droppable.containers);return o.set(n,{...i,disabled:s}),{...e,droppable:{...e.droppable,containers:o}}}case Zt.UnregisterDroppable:{const{id:n,key:r}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new Oi(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function IQ(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:s}=h.useContext(To),i=cc(r),o=cc(n?.id);return h.useEffect(()=>{if(!t&&!r&&i&&o!=null){if(!n0(i)||document.activeElement===i.target)return;const l=s.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const p=kX(d);if(p){p.focus();break}}})}},[r,t,s,o,i]),null}function GA(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((s,i)=>i({transform:s,...r}),n):n}function RQ(e){return h.useMemo(()=>({draggable:{...Il.draggable,...e?.draggable},droppable:{...Il.droppable,...e?.droppable},dragOverlay:{...Il.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function DQ(e){let{activeNode:t,measure:n,initialRect:r,config:s=!0}=e;const i=h.useRef(!1),{x:o,y:l}=typeof s=="boolean"?{x:s,y:s}:s;_r(()=>{if(!o&&!l||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),p=IA(d,r);if(o||(p.x=0),l||(p.y=0),i.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const f=DA(u);f&&f.scrollBy({top:p.y,left:p.x})}},[t,o,l,r,n])}const Eu=h.createContext({...Zn,scaleX:1,scaleY:1});var Br;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Br||(Br={}));const OQ=h.memo(function(t){var n,r,s,i;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=TQ,collisionDetection:p=UX,measuring:f,modifiers:m,...b}=t;const x=h.useReducer(_Q,void 0,CQ),[y,E]=x,[A,w]=DX(),[N,_]=h.useState(Br.Uninitialized),k=N===Br.Initialized,{draggable:{active:S,nodes:v,translate:O},droppable:{containers:C}}=y,M=S!=null?v.get(S):null,B=h.useRef({initial:null,translated:null}),R=h.useMemo(()=>{var Oe;return S!=null?{id:S,data:(Oe=M?.data)!=null?Oe:kQ,rect:B}:null},[S,M]),z=h.useRef(null),[W,F]=h.useState(null),[J,K]=h.useState(null),X=Zi(b,Object.values(b)),I=xu("DndDescribedBy",o),V=h.useMemo(()=>C.getEnabled(),[C]),te=RQ(f),{droppableRects:L,measureDroppableContainers:ye,measuringScheduled:xe}=mQ(V,{dragging:k,dependencies:[O.x,O.y],config:te.droppable}),P=pQ(v,S),oe=h.useMemo(()=>J?dc(J):null,[J]),re=Ct(),H=hQ(P,te.draggable.measure);DQ({activeNode:S!=null?v.get(S):null,config:re.layoutShiftCompensation,initialRect:H,measure:te.draggable.measure});const Ce=SS(P,te.draggable.measure,H),me=SS(P?P.parentElement:null),he=h.useRef({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:L,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:C,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ne=C.getNodeFor((n=he.current.over)==null?void 0:n.id),Ge=NQ({measure:te.dragOverlay.measure}),Z=(r=Ge.nodeRef.current)!=null?r:P,ke=k?(s=Ge.rect)!=null?s:Ce:null,Fe=!!(Ge.nodeRef.current&&Ge.rect),Re=xQ(Fe?null:Ce),rt=$A(Z?Nn(Z):null),ae=yQ(k?Ne??P:null),pe=vQ(ae),De=GA(m,{transform:{x:O.x-Re.x,y:O.y-Re.y,scaleX:1,scaleY:1},activatorEvent:J,active:R,activeNodeRect:Ce,containerNodeRect:me,draggingNodeRect:ke,over:he.current.over,overlayNodeRect:Ge.rect,scrollableAncestors:ae,scrollableAncestorRects:pe,windowRect:rt}),Me=oe?ha(oe,O):null,Le=EQ(ae),ot=vS(Le),dt=vS(Le,[Ce]),se=ha(De,ot),fe=ke?GX(ke,De):null,je=R&&fe?p({active:R,collisionRect:fe,droppableRects:L,droppableContainers:V,pointerCoordinates:Me}):null,Y=BX(je,"id"),[He,Ue]=h.useState(null),at=Fe?De:ha(De,dt),Nt=zX(at,(i=He?.rect)!=null?i:null,Ce),At=h.useRef(null),de=h.useCallback((Oe,Qe)=>{let{sensor:qe,options:St}=Qe;if(z.current==null)return;const ce=v.get(z.current);if(!ce)return;const Ee=Oe.nativeEvent,Ye=new qe({active:z.current,activeNode:ce,event:Ee,options:St,context:he,onAbort(ee){if(!v.get(ee))return;const{onDragAbort:lt}=X.current,bt={id:ee};lt?.(bt),A({type:"onDragAbort",event:bt})},onPending(ee,We,lt,bt){if(!v.get(ee))return;const{onDragPending:xr}=X.current,nr={id:ee,constraint:We,initialCoordinates:lt,offset:bt};xr?.(nr),A({type:"onDragPending",event:nr})},onStart(ee){const We=z.current;if(We==null)return;const lt=v.get(We);if(!lt)return;const{onDragStart:bt}=X.current,In={activatorEvent:Ee,active:{id:We,data:lt.data,rect:B}};Ur.unstable_batchedUpdates(()=>{bt?.(In),_(Br.Initializing),E({type:Zt.DragStart,initialCoordinates:ee,active:We}),A({type:"onDragStart",event:In}),F(At.current),K(Ee)})},onMove(ee){E({type:Zt.DragMove,coordinates:ee})},onEnd:Dt(Zt.DragEnd),onCancel:Dt(Zt.DragCancel)});At.current=Ye;function Dt(ee){return async function(){const{active:lt,collisions:bt,over:In,scrollAdjustedTranslate:xr}=he.current;let nr=null;if(lt&&xr){const{cancelDrop:Hn}=X.current;nr={activatorEvent:Ee,active:lt,collisions:bt,delta:xr,over:In},ee===Zt.DragEnd&&typeof Hn=="function"&&await Promise.resolve(Hn(nr))&&(ee=Zt.DragCancel)}z.current=null,Ur.unstable_batchedUpdates(()=>{E({type:ee}),_(Br.Uninitialized),Ue(null),F(null),K(null),At.current=null;const Hn=ee===Zt.DragEnd?"onDragEnd":"onDragCancel";if(nr){const Ka=X.current[Hn];Ka?.(nr),A({type:Hn,event:nr})}})}}},[v]),_e=h.useCallback((Oe,Qe)=>(qe,St)=>{const ce=qe.nativeEvent,Ee=v.get(St);if(z.current!==null||!Ee||ce.dndKit||ce.defaultPrevented)return;const Ye={active:Ee};Oe(qe,Qe.options,Ye)===!0&&(ce.dndKit={capturedBy:Qe.sensor},z.current=St,de(qe,Qe))},[v,de]),Ve=fQ(d,_e);SQ(d),_r(()=>{Ce&&N===Br.Initializing&&_(Br.Initialized)},[Ce,N]),h.useEffect(()=>{const{onDragMove:Oe}=X.current,{active:Qe,activatorEvent:qe,collisions:St,over:ce}=he.current;if(!Qe||!qe)return;const Ee={active:Qe,activatorEvent:qe,collisions:St,delta:{x:se.x,y:se.y},over:ce};Ur.unstable_batchedUpdates(()=>{Oe?.(Ee),A({type:"onDragMove",event:Ee})})},[se.x,se.y]),h.useEffect(()=>{const{active:Oe,activatorEvent:Qe,collisions:qe,droppableContainers:St,scrollAdjustedTranslate:ce}=he.current;if(!Oe||z.current==null||!Qe||!ce)return;const{onDragOver:Ee}=X.current,Ye=St.get(Y),Dt=Ye&&Ye.rect.current?{id:Ye.id,rect:Ye.rect.current,data:Ye.data,disabled:Ye.disabled}:null,ee={active:Oe,activatorEvent:Qe,collisions:qe,delta:{x:ce.x,y:ce.y},over:Dt};Ur.unstable_batchedUpdates(()=>{Ue(Dt),Ee?.(ee),A({type:"onDragOver",event:ee})})},[Y]),_r(()=>{he.current={activatorEvent:J,active:R,activeNode:P,collisionRect:fe,collisions:je,droppableRects:L,draggableNodes:v,draggingNode:Z,draggingNodeRect:ke,droppableContainers:C,over:He,scrollableAncestors:ae,scrollAdjustedTranslate:se},B.current={initial:ke,translated:fe}},[R,P,je,fe,v,Z,ke,L,C,He,ae,se]),cQ({...re,delta:O,draggingRect:fe,pointerCoordinates:Me,scrollableAncestors:ae,scrollableAncestorRects:pe});const Pe=h.useMemo(()=>({active:R,activeNode:P,activeNodeRect:Ce,activatorEvent:J,collisions:je,containerNodeRect:me,dragOverlay:Ge,draggableNodes:v,droppableContainers:C,droppableRects:L,over:He,measureDroppableContainers:ye,scrollableAncestors:ae,scrollableAncestorRects:pe,measuringConfiguration:te,measuringScheduled:xe,windowRect:rt}),[R,P,Ce,J,je,me,Ge,v,C,L,He,ye,ae,pe,te,xe,rt]),Je=h.useMemo(()=>({activatorEvent:J,activators:Ve,active:R,activeNodeRect:Ce,ariaDescribedById:{draggable:I},dispatch:E,draggableNodes:v,over:He,measureDroppableContainers:ye}),[J,Ve,R,Ce,E,I,v,He,ye]);return st.createElement(_A.Provider,{value:w},st.createElement(To.Provider,{value:Je},st.createElement(HA.Provider,{value:Pe},st.createElement(Eu.Provider,{value:Nt},u)),st.createElement(IQ,{disabled:l?.restoreFocus===!1})),st.createElement(jX,{...l,hiddenTextDescribedById:I}));function Ct(){const Oe=W?.autoScrollEnabled===!1,Qe=typeof c=="object"?c.enabled===!1:c===!1,qe=k&&!Oe&&!Qe;return typeof c=="object"?{...c,enabled:qe}:{enabled:qe}}}),LQ=h.createContext(null),TS="button",jQ="Draggable";function MQ(e){let{id:t,data:n,disabled:r=!1,attributes:s}=e;const i=xu(jQ),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:p,over:f}=h.useContext(To),{role:m=TS,roleDescription:b="draggable",tabIndex:x=0}=s??{},y=c?.id===t,E=h.useContext(y?Eu:LQ),[A,w]=lc(),[N,_]=lc(),k=wQ(o,t),S=Zi(n);_r(()=>(p.set(t,{id:t,key:i,node:A,activatorNode:N,data:S}),()=>{const O=p.get(t);O&&O.key===i&&p.delete(t)}),[p,t]);const v=h.useMemo(()=>({role:m,tabIndex:x,"aria-disabled":r,"aria-pressed":y&&m===TS?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,m,x,y,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:v,isDragging:y,listeners:r?void 0:k,node:A,over:f,setNodeRef:w,setActivatorNodeRef:_,transform:E}}function FQ(){return h.useContext(HA)}const PQ="Droppable",BQ={timeout:25};function $Q(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:s}=e;const i=xu(PQ),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=h.useContext(To),d=h.useRef({disabled:n}),p=h.useRef(!1),f=h.useRef(null),m=h.useRef(null),{disabled:b,updateMeasurementsFor:x,timeout:y}={...BQ,...s},E=Zi(x??r),A=h.useCallback(()=>{if(!p.current){p.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(E.current)?E.current:[E.current]),m.current=null},y)},[y]),w=yu({callback:A,disabled:b||!o}),N=h.useCallback((v,O)=>{w&&(O&&(w.unobserve(O),p.current=!1),v&&w.observe(v))},[w]),[_,k]=lc(N),S=Zi(t);return h.useEffect(()=>{!w||!_.current||(w.disconnect(),p.current=!1,w.observe(_.current))},[_,w]),h.useEffect(()=>(l({type:Zt.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:f,data:S}}),()=>l({type:Zt.UnregisterDroppable,key:i,id:r})),[r]),h.useEffect(()=>{n!==d.current.disabled&&(l({type:Zt.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)},[r,i,n,l]),{active:o,rect:f,isOver:c?.id===r,node:_,over:c,setNodeRef:k}}function UQ(e){let{animation:t,children:n}=e;const[r,s]=h.useState(null),[i,o]=h.useState(null),l=cc(n);return!n&&!r&&l&&s(l),_r(()=>{if(!i)return;const c=r?.key,u=r?.props.id;if(c==null||u==null){s(null);return}Promise.resolve(t(u,i)).then(()=>{s(null)})},[t,r,i]),st.createElement(st.Fragment,null,n,r?h.cloneElement(r,{ref:o}):null)}const zQ={x:0,y:0,scaleX:1,scaleY:1};function HQ(e){let{children:t}=e;return st.createElement(To.Provider,{value:zA},st.createElement(Eu.Provider,{value:zQ},t))}const GQ={position:"fixed",touchAction:"none"},WQ=e=>n0(e)?"transform 250ms ease":void 0,qQ=h.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:s,children:i,className:o,rect:l,style:c,transform:u,transition:d=WQ}=e;if(!l)return null;const p=s?u:{...u,scaleX:1,scaleY:1},f={...GQ,width:l.width,height:l.height,top:l.top,left:l.left,transform:Aa.Transform.toString(p),transformOrigin:s&&r?FX(r,l):void 0,transition:typeof d=="function"?d(r):d,...c};return st.createElement(n,{className:o,style:f,ref:t},i)}),VQ=e=>t=>{let{active:n,dragOverlay:r}=t;const s={},{styles:i,className:o}=e;if(i!=null&&i.active)for(const[l,c]of Object.entries(i.active))c!==void 0&&(s[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,c));if(i!=null&&i.dragOverlay)for(const[l,c]of Object.entries(i.dragOverlay))c!==void 0&&r.node.style.setProperty(l,c);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(const[c,u]of Object.entries(s))n.node.style.setProperty(c,u);o!=null&&o.active&&n.node.classList.remove(o.active)}},YQ=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Aa.Transform.toString(t)},{transform:Aa.Transform.toString(n)}]},KQ={duration:250,easing:"ease",keyframes:YQ,sideEffects:VQ({styles:{active:{opacity:"0"}}})};function ZQ(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:s}=e;return bu((i,o)=>{if(t===null)return;const l=n.get(i);if(!l)return;const c=l.node.current;if(!c)return;const u=UA(o);if(!u)return;const{transform:d}=Nn(o).getComputedStyle(o),p=RA(d);if(!p)return;const f=typeof t=="function"?t:XQ(t);return PA(c,s.draggable.measure),f({active:{id:i,data:l.data,node:c,rect:s.draggable.measure(c)},draggableNodes:n,dragOverlay:{node:o,rect:s.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:s,transform:p})})}function XQ(e){const{duration:t,easing:n,sideEffects:r,keyframes:s}={...KQ,...e};return i=>{let{active:o,dragOverlay:l,transform:c,...u}=i;if(!t)return;const d={x:l.rect.left-o.rect.left,y:l.rect.top-o.rect.top},p={scaleX:c.scaleX!==1?o.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?o.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-d.x,y:c.y-d.y,...p},m=s({...u,active:o,dragOverlay:l,transform:{initial:c,final:f}}),[b]=m,x=m[m.length-1];if(JSON.stringify(b)===JSON.stringify(x))return;const y=r?.({active:o,dragOverlay:l,...u}),E=l.node.animate(m,{duration:t,easing:n,fill:"forwards"});return new Promise(A=>{E.onfinish=()=>{y?.(),A()}})}}let kS=0;function QQ(e){return h.useMemo(()=>{if(e!=null)return kS++,kS},[e])}const JQ=st.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:s,transition:i,modifiers:o,wrapperElement:l="div",className:c,zIndex:u=999}=e;const{activatorEvent:d,active:p,activeNodeRect:f,containerNodeRect:m,draggableNodes:b,droppableContainers:x,dragOverlay:y,over:E,measuringConfiguration:A,scrollableAncestors:w,scrollableAncestorRects:N,windowRect:_}=FQ(),k=h.useContext(Eu),S=QQ(p?.id),v=GA(o,{activatorEvent:d,active:p,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:y.rect,over:E,overlayNodeRect:y.rect,scrollableAncestors:w,scrollableAncestorRects:N,transform:k,windowRect:_}),O=l0(f),C=ZQ({config:r,draggableNodes:b,droppableContainers:x,measuringConfiguration:A}),M=O?y.setRef:void 0;return st.createElement(HQ,null,st.createElement(UQ,{animation:C},p&&S?st.createElement(qQ,{key:S,id:p.id,ref:M,as:l,activatorEvent:d,adjustScale:t,className:c,transition:i,rect:O,style:{zIndex:u,...s},transform:v},n):null))}),eJ=6e4,tJ=10080*60*1e3,nJ={P1:"error",P2:"warning",P3:"neutral"},rJ={backlog:"bg-spur-text-faint",todo:"bg-spur-info",wip:"bg-spur-warning",testing:"bg-spur-accent",done:"bg-spur-success",blocked:"bg-spur-error",cancelled:"bg-spur-text-faint",deprecated:"bg-spur-text-muted"};function sJ(e,t){const n=new Date(e).getTime(),r=t-n,s=Math.floor(r/1e3);if(s<60)return"just now";const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const o=Math.floor(i/60);if(o<24)return`${o}h ago`;const l=Math.floor(o/24);return l<30?`${l}d ago`:`${Math.floor(l/30)}mo ago`}function WA({task:e,onClick:t}){const{attributes:n,listeners:r,setNodeRef:s,transform:i,isDragging:o}=MQ({id:e.wbs,data:{task:e}}),[l,c]=h.useState(Date.now());h.useEffect(()=>{const m=setInterval(()=>c(Date.now()),eJ);return()=>clearInterval(m)},[]);const u=i?{transform:Aa.Transform.toString(i),zIndex:o?50:void 0}:void 0,{subtaskProgress:d}=Ux(),p=d.get(e.wbs),f=e.updatedAt?l-new Date(e.updatedAt).getTime()>tJ:!1;return a.jsx(yx,{variant:"compact",asChild:!0,className:`group bg-spur-surface-2 hover:bg-spur-surface-3 rounded-xl border border-spur-border hover:border-spur-accent/60 shadow-xs hover:shadow-md cursor-pointer transition-all duration-150 w-full text-left ${o?"opacity-30":""}`,children:a.jsx("button",{ref:s,type:"button",style:u,onClick:()=>t(e.wbs),...r,...n,"aria-roledescription":"draggable card",children:a.jsxs(Ex,{className:"p-3 gap-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-mono font-semibold text-spur-text",children:[a.jsx("span",{className:`h-2 w-2 rounded-full shrink-0 ring-1 ring-spur-surface-2 ${rJ[e.status]??"bg-spur-text-faint"}`,"data-status":e.status,"aria-hidden":"true"}),e.wbs]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[e.estimateHours!==void 0&&a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted flex items-center gap-0.5",title:`Estimated: ${e.estimateHours}h`,children:[a.jsx("span",{className:"text-spur-text-faint text-[9px]",children:"⏱"}),e.estimateHours,"h"]}),e.priority&&a.jsx(tt,{variant:nJ[e.priority]??"outline",size:"xs",className:"font-mono text-[10px] font-semibold",children:e.priority})]})]}),a.jsx("p",{className:"text-sm font-medium text-spur-text leading-snug line-clamp-2 group-hover:text-spur-accent transition-colors",children:e.name}),a.jsxs("div",{className:"flex gap-1.5 flex-wrap items-center pt-0.5",children:[p&&p.total>0&&a.jsxs("div",{className:"flex items-center gap-1.5 min-w-[3.5rem]","data-testid":"subtask-progress",title:"subtasks done/total",children:[a.jsx("div",{className:"h-1 flex-1 rounded-full bg-spur-border/60 overflow-hidden",children:a.jsx("div",{className:"h-full bg-spur-success",style:{width:`${Math.round(p.done/p.total*100)}%`}})}),a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted shrink-0",children:[p.done,"/",p.total]})]}),e.type&&e.type!=="task"&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-border text-spur-text-muted",children:e.type}),e.template&&e.template!=="feature-impl"&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-accent/40 text-spur-accent bg-spur-accent/5 font-medium",children:e.template}),e.featureId&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-border text-spur-text-muted",children:e.featureId}),e.dependencyCount!==void 0&&e.dependencyCount>0&&a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted flex items-center gap-0.5",title:`${e.dependencyCount} dependenc${e.dependencyCount===1?"y":"ies"}`,children:[a.jsx("span",{className:"text-spur-text-faint text-[9px]",children:"⛓"}),e.dependencyCount]}),e.updatedAt&&a.jsx("span",{className:`text-xs font-mono ml-auto ${f?"text-spur-text-faint":"text-spur-text-muted"}`,title:e.updatedAt,children:sJ(e.updatedAt,l)})]})]})})})}function aJ({status:e,label:t,tasks:n,onCardClick:r,sortDir:s,onSortToggle:i}){const{setNodeRef:o,isOver:l}=$Q({id:e,data:{status:e}});return a.jsxs("section",{ref:o,"aria-label":`${t} column`,className:`flex flex-col flex-1 min-w-[16rem] rounded-xl border transition-colors duration-200 overflow-hidden ${l?"bg-spur-surface/40 border-spur-accent shadow-lg ring-1 ring-spur-accent/30":"bg-transparent border-spur-border"}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5 border-b border-spur-border shrink-0 bg-spur-surface",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text uppercase tracking-wide",children:[ef(e)," ",t]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(tt,{variant:"ghost",size:"sm",className:"font-mono text-spur-text-muted bg-spur-surface-2 border border-spur-border/80 px-2 py-0.5",children:n.length}),i&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 flex items-center justify-center text-spur-text-muted hover:text-spur-text hover:bg-spur-surface-2 rounded-md transition-colors",onClick:i,"aria-label":`Sort ${t} by WBS`,title:`Sort ${t}: ${s==="asc"?"WBS ↓":s==="desc"?"WBS ↑":"none"}`,children:s==="asc"?"↓":s==="desc"?"↑":"⇅"})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-2 min-h-[4rem]",children:[n.map(c=>a.jsx(WA,{task:c,onClick:r},c.wbs)),n.length===0&&a.jsx("div",{className:"flex items-center justify-center h-20 text-xs text-spur-text-muted italic border border-dashed border-spur-border/60 rounded-lg my-1 bg-spur-surface/30",children:"No tasks"})]})]})}const iJ=h.lazy(()=>Ak(()=>import("./TaskDetail.DWXct9_X.js"),__vite__mapDeps([2,3,1,4,5]))),oJ=Pn,qA="docs/tasks",AS="spur:detail-width",lJ=new Set(["blocked","cancelled","deprecated"]);function cJ(e,t){return t?e.filter(n=>!(t.status!==void 0&&!t.status.split(",").includes(n.status)||t.featureId&&!n.featureId?.toLowerCase().includes(t.featureId.toLowerCase())||t.parentWbs&&n.parentWbs!==t.parentWbs)):e}function VA(e){const{onSelectTask:t,filters:n,folder:r,hiddenColumns:s,onConnectionChange:i,onSyncChange:o}=e,[l,c]=h.useState({}),[u,d]=h.useState(qA),[p,f]=h.useState(null),[m,b]=h.useState(()=>{const V=typeof window<"u"?Math.min(1728,window.innerWidth*.8):1728;if(typeof window>"u")return V;try{const te=Number.parseFloat(window.localStorage.getItem(AS)??"");if(Number.isFinite(te)&&te>0)return Math.min(te,window.innerWidth*.8)}catch{}return V}),x=r??u,y=s??lJ,E=h.useCallback(()=>xt.task.list({folder:x}),[x]),{tasks:A,loading:w,error:N,connected:_,lastSyncAt:k,setTasks:S,store:v}=Ux(E),[O,C]=h.useState(null);h.useEffect(()=>{i?.(_)},[_,i]),h.useEffect(()=>{o?.(k)},[k,o]),h.useEffect(()=>{typeof xt.task.folders=="function"&&xt.task.folders({}).then(V=>{const{data:te,activeFolder:L}=V,ye=L??te?.[0]?.path;ye!==void 0&&d(ye)}).catch(()=>{})},[]),h.useEffect(()=>{document.documentElement.style.setProperty("--detail-w",`${m}px`)},[m]),h.useEffect(()=>{if(!p)return;const V=te=>{te.key==="Escape"&&f(null)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[p]);const M=Ji();h.useEffect(()=>{const V=M.pathname.split("/"),te=V.indexOf("tasks"),L=te>=0?V[te+1]:void 0;L&&/^\d{4}$/.test(L)&&f(L)},[M.pathname]);const B=hS(o0,{activationConstraint:{distance:5}}),R=hS(a0),z=MX(B,R),W=cJ(A,n),F=V=>{c(te=>{const L={...te};return te[V]==="asc"?L[V]="desc":te[V]==="desc"?delete L[V]:L[V]="asc",L})},J=V=>{const te=W.filter(ye=>ye.status===V),L=l[V]??"desc";return[...te].sort((ye,xe)=>{const P=ye.wbs.localeCompare(xe.wbs);return L==="asc"?P:-P})},K=V=>A.find(te=>te.wbs===V),X=V=>{C(String(V.active.id))},I=V=>{C(null);const{active:te,over:L}=V;if(!L)return;const ye=String(te.id),xe=String(L.id),P=K(ye);if(!P||P.status===xe)return;const oe=[...A];S(re=>re.map(H=>H.wbs===ye?{...H,status:xe}:H)),xt.task.transition({wbs:ye,toStatus:xe}).catch(re=>{S(oe);const H=re instanceof Error?re.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:H}}))})};return w?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(ln,{size:"lg",className:"text-spur-accent"})}):N?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-spur-text-muted",children:[a.jsx("p",{className:"text-lg font-semibold",children:"Failed to load tasks"}),a.jsx("p",{className:"text-sm",children:N.message})]})}):a.jsx(Mk.Provider,{value:v,children:a.jsxs(OQ,{sensors:z,onDragStart:X,onDragEnd:I,children:[a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex gap-3 overflow-x-auto h-full p-4",children:oJ.filter(V=>!y.has(V)).map(V=>a.jsx(aJ,{status:V,label:V,tasks:J(V),onCardClick:te=>{f(te),t(te)},sortDir:l[V],onSortToggle:()=>F(V)},V))}),p&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button","aria-label":"Close task detail",className:"fixed inset-0 z-50 bg-black/40 border-0 p-0 cursor-default",onClick:()=>f(null)}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Task detail",className:"fixed top-0 right-0 h-full z-50 bg-spur-surface border-l border-spur-border shadow-2xl flex",style:{width:"var(--detail-w)",minWidth:"36rem",maxWidth:"80vw"},children:[a.jsx(ka,{targetVar:"--detail-w",onResizeEnd:V=>{const te=Math.max(576,Math.min(V,window.innerWidth*.8));b(te);try{window.localStorage.setItem(AS,String(te))}catch{}},direction:"horizontal",invert:!0}),a.jsx("div",{className:"flex flex-col flex-1 overflow-hidden",children:a.jsx("div",{className:"flex-1 overflow-y-auto","data-testid":"detail-body",children:(()=>{const V=A.find(te=>te.wbs===p);return V?a.jsx(h.Suspense,{fallback:a.jsx("div",{className:"flex items-center justify-center h-32 text-spur-text-muted text-sm",children:"Loading detail..."}),children:a.jsx(iJ,{task:V,onClose:()=>f(null),onTransition:(te,L)=>{S(ye=>ye.map(xe=>xe.wbs===te?{...xe,status:L}:xe)),xt.task.transition({wbs:te,toStatus:L}).catch(ye=>{const xe=ye instanceof Error?ye.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:xe}}))})}})}):null})()})})]})]})]}),a.jsx(JQ,{dropAnimation:null,children:O?(()=>{const V=K(O);return V?a.jsx("div",{className:"opacity-90",children:a.jsx(WA,{task:V,onClick:()=>{}})}):null})():null})]})})}const Md=[{id:"kanban",label:"Kanban",component:VA}];function YA(){const[e,t]=Ca(),n=Ji(),r=mc(),s=h.useMemo(()=>{const c=n.pathname.split("/"),u=c.indexOf("tasks"),d=u>=0?c[u+1]:void 0;return d&&/^\d{4}$/.test(d)?d:e.get("selected")},[n.pathname,e]),i=h.useMemo(()=>{const c={},u=e.get("status"),d=e.get("feature"),p=e.get("parent"),f=e.get("assignee"),m=e.get("folder");return u!==null&&(c.status=u),d&&(c.featureId=d),p&&(c.parentWbs=p),f&&(c.assignee=f),m&&(c.folder=m),c},[e]);return{selected:s,filters:i,selectTask:c=>{const u=new URLSearchParams(e);u.delete("selected");const d=u.toString(),p=c?`/board/tasks/${c}`:"/board/tasks";r(`${p}${d?`?${d}`:""}`,{replace:!0})},setFilter:(c,u)=>{t(d=>{const p=new URLSearchParams(d);return c==="feature"&&p.delete("parent"),c==="parent"&&p.delete("feature"),u!==null?p.set(c,u):p.delete(c),p},{replace:!0})}}}function uJ(e){const t=e.trim();return/^\d{4}$/.test(t)?{kind:"navigate",wbs:t}:t.includes(".")?{kind:"filter",key:"parent",value:t}:{kind:"filter",key:"feature",value:t}}function dJ(){const{selectTask:e,setFilter:t,filters:n}=YA(),[r,s]=h.useState(qA),[i,o]=h.useState([]),[l,c]=h.useState("kanban"),[u,d]=h.useState(!1),[p,f]=h.useState(""),[m,b]=h.useState(!1),[x,y]=h.useState(void 0),E=n.folder??r,A=new Set(n.status===void 0?Pn.filter(S=>S!=="blocked"&&S!=="cancelled"&&S!=="deprecated"):n.status.split(",").filter(S=>Pn.some(v=>v===S))),w=new Set(Pn.filter(S=>!A.has(S)));h.useEffect(()=>{f(n.featureId??n.parentWbs??"")},[n.featureId,n.parentWbs]),h.useEffect(()=>{typeof xt.task.folders=="function"&&xt.task.folders({}).then(S=>{const{data:v,activeFolder:O}=S,C=O??v?.[0]?.path;v&&o(v),C!==void 0&&s(C)}).catch(()=>{})},[]);const N=S=>{const v=new Set(A);v.has(S)?v.delete(S):v.add(S),t("status",Pn.filter(O=>v.has(O)).join(","))},_=S=>{S.preventDefault();const v=uJ(p);if(v.kind==="navigate"){e(v.wbs),f("");return}t(v.key,v.value||null)},k=(Md.find(S=>S.id===l)??Md[0]).component;return a.jsxs("div",{className:"task-kanban flex flex-col h-full",children:[a.jsx("header",{className:"mx-auto w-full max-w-[1600px] shrink-0 px-4 pt-3",children:a.jsxs("div",{className:"flex flex-nowrap items-center justify-between gap-4 border-b border-spur-border pb-3",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx(Rr,{id:"tasks",size:"lg",className:"h-7 w-7 text-spur-accent","aria-hidden":"true"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("h1",{className:"text-xl font-bold tracking-tight text-spur-text",children:"Tasks"}),a.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-spur-border bg-spur-surface-2 px-2.5 py-0.5 text-xs text-spur-text-muted font-mono",role:"status","data-testid":"tasks-live-chip",children:[a.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${m?"bg-spur-success":"bg-spur-error"}`,"aria-hidden":"true"}),"last sync ",x?new Date(x).toLocaleString():"—"]})]}),a.jsx("p",{className:"text-xs text-spur-text-muted mt-0.5",children:"Task corpus, kanban lanes, and phase filters"})]})]}),a.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-2.5 overflow-x-auto",children:[a.jsx(qr,{variant:"ghost",size:"xs",className:"text-xs shrink-0 w-44 bg-spur-surface-2 border border-spur-border rounded-lg text-spur-text",value:E,onChange:S=>t("folder",S.target.value),"aria-label":"Task phase folder",children:i.map(S=>a.jsx("option",{value:S.path,children:S.label?`${S.label} (${S.path})`:S.path},S.path))}),a.jsx("div",{className:"flex shrink-0 items-center gap-1 bg-spur-surface-2 border border-spur-border px-2 py-1 rounded-xl",children:Pn.map(S=>a.jsxs("label",{htmlFor:`tasks-status-${S}`,className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md hover:bg-spur-surface-3 transition-colors cursor-pointer",children:[a.jsx(Sx,{id:`tasks-status-${S}`,size:"xs",checked:!w.has(S),onChange:()=>N(S)}),a.jsxs("span",{className:"text-[11px] font-medium text-spur-text-muted select-none",children:[ef(S)," ",S]})]},S))}),a.jsx("form",{onSubmit:_,className:"flex shrink-0 items-center",children:a.jsx(Vn,{"aria-label":"Filter by WBS or feature",type:"text",placeholder:"WBS or feature",variant:"bordered",size:"xs",className:"w-36 bg-spur-surface-2 border-spur-border text-spur-text",value:p,onChange:S=>f(S.target.value)})}),a.jsx(Ie,{variant:"primary",size:"sm",className:"shrink-0 font-medium",onClick:()=>d(!0),children:"+ New Task"}),a.jsx("div",{className:"flex shrink-0 items-center gap-1 bg-spur-surface-2 border border-spur-border p-1 rounded-xl",children:Md.map(S=>a.jsx("button",{type:"button",className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${l===S.id?"bg-primary text-primary-content font-bold shadow-sm":"text-spur-text-muted hover:text-spur-text hover:bg-spur-surface-3"}`,onClick:()=>c(S.id),children:S.label},S.id))})]})]})}),a.jsx(Lk,{folder:E}),a.jsx("div",{"data-kanban-board":!0,className:"flex-1 overflow-hidden",children:a.jsx(k,{onSelectTask:e,filters:n,folder:E,hiddenColumns:w,onConnectionChange:b,onSyncChange:y})}),a.jsx(Ok,{open:u,onClose:()=>d(!1),onCreated:()=>{},folder:E})]})}function pJ(e,t){xt.task.transition({wbs:e,toStatus:t}).catch(n=>{const r=n instanceof Error?n.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:r}}))})}function fJ(){const{filters:e,selectTask:t}=YA();return a.jsx("div",{className:"task-kanban flex flex-col h-full",children:a.jsx("div",{"data-kanban-board":!0,className:"flex-1 overflow-hidden",children:a.jsx(VA,{onSelectTask:t,filters:e})})})}const mJ={id:"tasks",name:"Tasks",icon:"📋",route:"tasks",component:dJ,sidebarLabel:"Tasks",description:"Task kanban, lifecycle status, and per-task detail",order:40},hJ=Object.freeze(Object.defineProperty({__proto__:null,TaskKanbanView:fJ,module:mJ,transition:pJ},Symbol.toStringTag,{value:"Module"}));function KA(e){return e===null||typeof e!="object"?null:"module"in e&&CS(e.module)?e.module:"default"in e&&CS(e.default)?e.default:null}function CS(e){return e===null||typeof e!="object"?!1:"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string"&&"icon"in e&&typeof e.icon=="string"&&"route"in e&&typeof e.route=="string"&&"component"in e&&typeof e.component=="function"}function ZA(e,t){const n=typeof e.order=="number",r=typeof t.order=="number";return n&&r?e.order-t.order:n?-1:r?1:0}function gJ(e){const t=[],n=e("./*/index.{ts,tsx}",{eager:!0});for(const r of Object.values(n)){const s=KA(r);s&&t.push(s)}return t.sort((r,s)=>r.id.localeCompare(s.id)),t.sort(ZA),t}function bJ(){try{return gJ(()=>Object.assign({"./designs/index.tsx":Mq,"./features/index.tsx":cV,"./history/index.tsx":HV,"./observability/index.tsx":RK,"./plans/index.tsx":UK,"./projects/index.tsx":GZ,"./search/index.tsx":XZ,"./settings/index.tsx":wX,"./task-kanban/index.tsx":hJ}))}catch(s){if(typeof require!="function")throw s}const e=require("node:fs"),t=require("node:path"),n=require("node:url"),r=typeof __dirname<"u"?__dirname:t.dirname(n.fileURLToPath(import.meta.url));return xJ(r,{readdirSync:(s,i)=>e.readdirSync(s,i),tryRequire:s=>require(s)})}function xJ(e,t){const n=require("node:path"),r=[];let s=[];try{s=t.readdirSync(e,{withFileTypes:!0})}catch{return r}const i=s.filter(o=>o.isDirectory()).map(o=>o.name).sort((o,l)=>o.localeCompare(l));for(const o of i)for(const l of["tsx","ts"]){const c=n.join(e,o,`index.${l}`);try{const u=t.tryRequire(c),d=KA(u);if(d){r.push(d);break}}catch{}}return r.sort(ZA),r}function XA(e,t){const n=new Set(t?.disabled??[]),r=e.slice(),s=new Set(n),i=t?.defaultModuleId;function o(){return r.filter(l=>!s.has(l.id))}return yJ(r),{get modules(){return o()},getModule(l){return o().find(c=>c.id===l)},get defaultModule(){const l=o();if(i){const c=l.find(u=>u.id===i);if(c)return c}return l[0]},disableModule(l){s.add(l)},enableModule(l){s.delete(l)},getEnabledModules(){return o().map(l=>l.id)}}}function yJ(e){const t=new Map,n=new Map;for(const r of e){const s=t.get(r.id);if(s!==void 0)throw new Error(`Duplicate module id "${r.id}" discovered in two sources: ${s} and ${hl(r)}`);t.set(r.id,hl(r));const i=n.get(r.route);if(i!==void 0)throw new Error(`Duplicate module route "${r.route}" discovered in two sources: ${i} and ${hl(r)}`);n.set(r.route,hl(r))}}function hl(e){return e.id}const c0=XA(bJ(),{disabled:Lj,defaultModuleId:jj}),Qi=c0;c0.modules;c0.defaultModule;const QA=h.createContext({registry:Qi,hostDiagnostics:[]});function EJ({value:e,children:t}){return a.jsx(QA.Provider,{value:e,children:t})}function JA(){return h.useContext(QA)}const Up="spur-board-layout-v3",_S="spur-board-layout-v2",IS="spur-board-layout",ir={version:3,sidebarWidth:240,rightPanelWidth:320,sidebarCollapsed:!0,rightPanelCollapsed:!0};function SJ(){try{const e=localStorage.getItem(Up);if(e){const s=JSON.parse(e);return{version:3,sidebarWidth:typeof s.sidebarWidth=="number"?s.sidebarWidth:ir.sidebarWidth,rightPanelWidth:typeof s.rightPanelWidth=="number"?s.rightPanelWidth:ir.rightPanelWidth,sidebarCollapsed:typeof s.sidebarCollapsed=="boolean"?s.sidebarCollapsed:ir.sidebarCollapsed,rightPanelCollapsed:typeof s.rightPanelCollapsed=="boolean"?s.rightPanelCollapsed:ir.rightPanelCollapsed}}const t=localStorage.getItem(_S),n=localStorage.getItem(IS),r=t||n;if(r){const s=JSON.parse(r),i={version:3,sidebarWidth:typeof s.sidebarWidth=="number"?s.sidebarWidth:ir.sidebarWidth,rightPanelWidth:typeof s.rightPanelWidth=="number"?s.rightPanelWidth:ir.rightPanelWidth,sidebarCollapsed:ir.sidebarCollapsed,rightPanelCollapsed:typeof s.rightPanelCollapsed=="boolean"?s.rightPanelCollapsed:ir.rightPanelCollapsed};try{localStorage.setItem(Up,JSON.stringify(i)),localStorage.removeItem(_S),localStorage.removeItem(IS)}catch{}return i}return{...ir}}catch{return{...ir}}}function wJ(e){try{localStorage.setItem(Up,JSON.stringify({...e,version:3}))}catch{}}const eC="spur.board.projects.draft.v1";function la(e){return{path:e,text:"",revision:0}}function vJ(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.path!="string"||typeof t.text!="string"||typeof t.revision!="number"||!Number.isFinite(t.revision))return null;const n={path:t.path,text:t.text,revision:t.revision};return t.pending!==void 0&&(n.pending=t.pending),n}function NJ(e){try{const t=globalThis.localStorage?.getItem(eC);if(t==null)return la(e);const n=vJ(JSON.parse(t));return n===null||n.path!==e?(Rl(la(e)),la(e)):n}catch{return la(e)}}function Rl(e){try{globalThis.localStorage?.setItem(eC,JSON.stringify(e))}catch{}}const TJ={draft:la(""),setText:()=>{},persistPending:()=>{},clearSubmitted:()=>{}},tC=h.createContext(TJ);function kJ(){return h.useContext(tC)}function AJ({children:e}){const n=Ms().path,[r,s]=h.useState(()=>la(""));h.useEffect(()=>{n!==null&&s(NJ(n))},[n]);const i=h.useMemo(()=>({draft:r,setText:o=>s(l=>{if(l.path!==n)return l;const c={...l,text:o,revision:l.revision+1};return Rl(c),c}),persistPending:o=>s(l=>{if(l.path!==r.path||l.revision!==r.revision)return l;const c={...l,pending:{requestKey:o,revision:l.revision}};return Rl(c),c}),clearSubmitted:(o,l)=>s(c=>{if(c.path!==l||c.revision!==o)return c;const u={path:c.path,text:"",revision:c.revision+1};return Rl(u),u})}),[r,n]);return a.jsx(tC.Provider,{value:i,children:e})}function CJ(){const[e,t]=h.useState([]);return h.useEffect(()=>{if(typeof window>"u")return;const n=r=>{const i=r.detail?.message||"An error occurred",o=`${Date.now()}-${Math.random().toString(36).slice(2,7)}`;t(l=>[...l,{id:o,message:i}]),setTimeout(()=>{t(l=>l.filter(c=>c.id!==o))},5e3)};return window.addEventListener("api-error",n),()=>{window.removeEventListener("api-error",n)}},[]),e.length===0?null:a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-md w-full px-4 pointer-events-none",children:e.map(n=>a.jsxs("div",{className:"pointer-events-auto flex items-center justify-between gap-3 p-3 bg-red-950/90 border border-red-500/40 text-red-200 text-sm rounded-md shadow-lg backdrop-blur",role:"alert",children:[a.jsx("span",{className:"flex-1 break-words",children:n.message}),a.jsx("button",{type:"button",className:"text-red-400 hover:text-red-100 text-base font-bold leading-none px-1",onClick:()=>t(r=>r.filter(s=>s.id!==n.id)),"aria-label":"Close error toast",children:"×"})]},n.id))})}const _J="Enter",IJ=229;function RJ(e){return e.key===_J&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==IJ}const DJ=[{name:"/review",description:"Inspect staged git diff, verify test coverage & lint",category:"git",argumentHint:"[target] [--cached]",tags:["builtin","git","review"]},{name:"/commit",description:"Draft conventional commit message from staged hunks",category:"git",argumentHint:"[--all] [-m <message>]",tags:["builtin","git","commit"]},{name:"/compact",description:"Purge execution trace and condense context window",category:"sys",argumentHint:"[focus]",tags:["builtin","sys","compact"]},{name:"/revert",description:"Undo last agent file changes or restore git stash",category:"git",argumentHint:"[stash-id | file]",tags:["builtin","git","revert"]},{name:"/resume",description:"Resume paused background agent run",category:"dev",argumentHint:"[run-id]",tags:["builtin","dev","resume"]},{name:"/terminal",description:"Run isolated bash execution in sandbox mirror",category:"sys",argumentHint:"[command]",tags:["builtin","sys","terminal"]},{name:"/cost",description:"Inspect token breakdown and USD expenditure",category:"sys",tags:["builtin","sys","cost"]},{name:"/sp:dev-plan",description:"Plan a feature from description (intake → AC → tasks)",category:"harness",argumentHint:'"<description>" [--feature <id>]',tags:["sp","dev","plan"]},{name:"/sp:dev-run",description:"Drive one task end-to-end through verification pipeline",category:"harness",argumentHint:"<wbs> [--mode <full|implement>]",tags:["sp","dev","run"]},{name:"/sp:dev-verify",description:"Verify a task against requirements and acceptance criteria",category:"harness",argumentHint:"<wbs> [--bdd] [--auto]",tags:["sp","dev","verify"]}],OJ={sending:{icon:"…",label:"Sending",meaning:"the request is being stored",action:"wait for the mailbox",tone:"warn"},queued:{icon:"○",label:"Queued",meaning:"the orchestrator has not claimed it yet",action:"wait for the orchestrator",tone:"warn"},working:{icon:"◐",label:"In progress",meaning:"a member claimed it",action:"wait for the run to finish",tone:"warn"},delivered:{icon:"✓",label:"Delivered",meaning:"the member consumed the request",action:"read the reply in the Inbox tab",tone:"ok"},failed:{icon:"✕",label:"Failed",meaning:"delivery did not start or the run errored",action:"resend, or read the error in the Inbox tab",tone:"err"},unresolved:{icon:"!",label:"Unresolved",meaning:"the run left no verified outcome",action:"check the Inbox tab for the hold reason",tone:"warn"},absent:{icon:"·",label:"No receipt",meaning:"the request did not reach an inbox",action:"check the project binding and resend",tone:"warn"}};function LJ(e,t){return t?"sending":e===null?"absent":e.status==="failed"||["failed","errored","cancelled"].includes(e.runStatus??"")?"failed":e.runStatus==="running"?"working":e.reason!==null&&e.reason!==""?e.status==="delivered"?"unresolved":"working":e.status==="delivered"?"delivered":e.status==="claimed"?"working":"queued"}const jJ=[{id:"auto",label:"auto",desc:"Orchestrator auto-dispatch (default)"},{id:"coder",label:"coder",desc:"Implementation & refactoring specialist"},{id:"reviewer",label:"reviewer",desc:"Verification, lint & SECUA reviewer"},{id:"planner",label:"planner",desc:"Architecture & decomposition specialist"}];function MJ(e){if(!e)return!0;const{state:t,instanceId:n}=e.orchestrator;return t==="missing"||t==="unresolvable"||!n}function FJ({activeModule:e}){const[t,n]=h.useState(!1),[r,s]=h.useState(!1),[i,o]=h.useState(null),[l,c]=h.useState("auto"),[u,d]=h.useState(!1),[p,f]=h.useState(!1),[m,b]=h.useState(0),[x,y]=h.useState("all"),[E,A]=h.useState(DJ),w=h.useMemo(()=>{const Z=new Map;for(const Re of E){if(Array.isArray(Re.tags)){for(const rt of Re.tags)if(rt&&typeof rt=="string"){const ae=rt.trim().toLowerCase();Z.set(ae,(Z.get(ae)??0)+1)}}if(Re.category){const rt=Re.category.trim().toLowerCase();Z.set(rt,(Z.get(rt)??0)+1)}}const ke=["sp","cc","kk","wt","git","dev","sys","harness","builtin"];return["all",...Array.from(Z.keys()).sort((Re,rt)=>{const ae=ke.indexOf(Re),pe=ke.indexOf(rt);if(ae!==-1&&pe!==-1)return ae-pe;if(ae!==-1)return-1;if(pe!==-1)return 1;const De=(Z.get(rt)??0)-(Z.get(Re)??0);return De!==0?De:Re.localeCompare(rt)})]},[E]),N=Ms(),_=h.useRef({path:N.path,generation:0,inFlight:!1});_.current.path!==N.path&&(_.current={path:N.path,generation:_.current.generation+1,inFlight:!1}),h.useEffect(()=>()=>{_.current.generation+=1},[]);const{draft:k,setText:S,persistPending:v,clearSubmitted:O}=kJ(),C=N.fleet?.orchestrator?.instanceId,M=MJ(N.fleet),[B,R]=h.useState(null),[z,W]=h.useState(!1),[F,J]=h.useState(null),[K,X]=h.useState(0);h.useEffect(()=>{N.path,s(!1),o(null),R(null),W(!1),J(null)},[N.path]),h.useEffect(()=>{if(i===null)return;let Z=!1;return(async()=>{try{const ke=await xt.inbox.requests({messageId:i});if(Z)return;const Fe=ke.find(Re=>Re.messageId===i);Fe!==void 0&&R({status:Fe.status,reason:Fe.reason,runStatus:Fe.runStatus}),W(!1)}catch{Z||W(!0)}})(),()=>{Z=!0}},[i,K]),h.useEffect(()=>{if(typeof EventSource>"u")return;const Z=new EventSource(`${it()}/events/planning`);return Z.onmessage=ke=>{try{const Fe=JSON.parse(ke.data).eventName;typeof Fe=="string"&&Fe.startsWith("message.")&&X(Re=>Re+1)}catch{}},()=>Z.close()},[]);const I=LJ(B,r),V=OJ[I],te=r||i!==null,L=te?`${V.label} — Next: ${V.action}`:"";h.useEffect(()=>{if(i===null||N.path===null||B===null||["completed","exited","failed","errored","cancelled"].includes(B.runStatus??"")||B.status!=="queued"&&B.status!=="claimed"&&B.runStatus!=="running")return;const Z=setInterval(()=>X(ke=>ke+1),2e3);return()=>clearInterval(Z)},[i,N.path,B]);const ye=h.useRef(null);h.useEffect(()=>{let Z=!0;return(async()=>{try{const ke=await Xe(new Request(`${it()}/agent/commands`));if(ke.ok){const Fe=await ke.json();Z&&Array.isArray(Fe.commands)&&Fe.commands.length>0&&A(Fe.commands)}}catch{}})(),()=>{Z=!1}},[]),h.useEffect(()=>{if(!u)return;const Z=ke=>{ye.current&&!ye.current.contains(ke.target)&&d(!1)};return document.addEventListener("click",Z),()=>document.removeEventListener("click",Z)},[u]),h.useEffect(()=>{k.text.startsWith("/")&&f(!1)},[k.text]);const xe=k.text.trim().toLowerCase(),P=xe.startsWith("/")&&!p,oe=P?E.filter(Z=>{const ke=x==="all"||Array.isArray(Z.tags)&&Z.tags.map(rt=>rt.toLowerCase()).includes(x)||Z.category.toLowerCase()===x,Fe=xe.startsWith("/")?xe.slice(1):xe,Re=Z.name.toLowerCase().startsWith(xe)||Z.name.toLowerCase().includes(Fe)||!!Z.argumentHint?.toLowerCase().includes(Fe)||Z.description.toLowerCase().includes(Fe)||Array.isArray(Z.tags)&&Z.tags.some(rt=>rt.toLowerCase().includes(Fe));return ke&&Re}):[],re=P&&oe.length>0,H=Z=>{S(`${Z} `),f(!0),document.querySelector('[data-testid="agent-bar-input"]')?.focus()},Ce=Z=>{const ke=k.text,Fe=ke.length>0&&!ke.endsWith(" ")?`${ke} ${Z}`:`${ke}${Z}`;S(Fe),document.querySelector('[data-testid="agent-bar-input"]')?.focus()},me=()=>l==="auto"?C:N.fleet?.members?.find(ke=>ke.role===l||ke.instanceId===l)?.instanceId??C,he=async()=>{const Z=N.path,ke=me();if(Z===null||k.path!==Z||ke===void 0||_.current.inFlight)return;const Fe=++_.current.generation,Re=()=>_.current.path===Z&&_.current.generation===Fe,rt=k.text;if(rt.trim().length===0)return;_.current.inFlight=!0;const ae={text:rt,revision:k.revision},pe=k.pending!==void 0&&typeof k.pending.requestKey=="string"&&k.pending.requestKey.length>0&&k.pending.revision===k.revision?k.pending:void 0,De=pe!==void 0?pe.requestKey:crypto.randomUUID();v(De),J(null),s(!0),o(null),R(null),f(!0);try{const Me=await xt.inbox.send({...ke!==null?{to:ke}:{},body:ae.text,requestKey:De,...Z!==null?{projectPath:Z}:{}});if(!Re())return;R({status:Me.message.status,reason:null}),o(Me.message.id),O(ae.revision,Z)}catch(Me){Re()&&J(Me instanceof Error?Me.message:"the message was not sent")}finally{Re()&&(_.current.inFlight=!1,s(!1))}};if(!t)return a.jsxs(a.Fragment,{children:[a.jsx("div",{role:"status","aria-live":"polite",className:"sr-only","data-agent-bar-live":!0,children:L}),a.jsx(Ie,{variant:"ghost",className:"fixed bottom-6 right-6 z-30 h-12 w-12 rounded-full backdrop-blur-md bg-base-100/80 border border-spur-border shadow-2xl text-xl text-spur-text",onClick:()=>n(!0),"aria-label":"Open agent prompt bar","aria-expanded":!1,"data-testid":"agent-bar-dock",children:"✨"})]});const Ne=N.fleet?.members&&N.fleet.members.length>0?[{id:"auto",label:"auto",desc:"Orchestrator auto-dispatch (default)"},...N.fleet.members.map(Z=>({id:Z.instanceId,label:Z.role||Z.instanceId,desc:`${Z.executor}${Z.model?` · ${Z.model}`:""}`}))]:jJ,Ge=k.text.trim().length===0||l==="auto"&&M;return a.jsxs("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 w-[calc(100vw-2rem)] max-w-[84rem] backdrop-blur-md bg-base-100/80 border border-spur-border shadow-2xl rounded-2xl p-2.5 flex flex-col gap-2 transition-colors","data-testid":"agent-bar",children:[a.jsx("div",{role:"status","aria-live":"polite",className:"sr-only","data-agent-bar-live":!0,children:L}),re&&a.jsxs("div",{"data-testid":"agent-bar-palette",className:"w-full rounded-2xl bg-base-100/95 border border-spur-border shadow-2xl overflow-hidden flex flex-col backdrop-blur-2xl mb-1 transition-colors",children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2 border-b border-spur-border bg-base-200/50 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{className:"font-mono text-spur-accent font-semibold text-[13px]",children:"/"}),a.jsx("span",{className:"font-mono text-[12px] font-medium text-spur-text",children:"Commands"}),a.jsxs("span",{className:"text-[11px] font-mono text-spur-text-muted",children:[oe.length," available"]})]}),a.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar max-w-[65%] py-0.5",role:"tablist",children:w.slice(0,10).map(Z=>a.jsx("button",{type:"button",role:"tab","aria-selected":x===Z,onClick:()=>y(Z),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors shrink-0 cursor-pointer ${x===Z?"bg-spur-accent/15 text-spur-accent border border-spur-accent/30 font-medium":"text-spur-text-muted hover:text-spur-text hover:bg-base-200"}`,children:Z==="all"?"All":Z},Z))})]}),a.jsx("div",{className:"flex flex-col py-1.5 px-2 max-h-[260px] overflow-y-auto",role:"listbox",children:oe.map((Z,ke)=>{const Fe=ke===m;return a.jsxs("button",{type:"button",role:"option","aria-selected":Fe,onClick:()=>H(Z.name),title:Z.description,className:`flex items-center w-full text-left px-3 py-2 rounded-lg cursor-pointer transition-colors ${Fe?"bg-spur-surface text-spur-accent font-medium":"hover:bg-base-200 text-spur-text-muted hover:text-spur-text"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[13px] min-w-0 truncate flex-1",children:[a.jsx("span",{className:Fe?"font-semibold text-spur-accent":"font-medium text-spur-text",children:Z.name}),Z.argumentHint?a.jsx("span",{className:`font-mono text-xs truncate ${Fe?"text-spur-text/80":"text-spur-text-muted"}`,children:Z.argumentHint}):a.jsx("span",{className:`font-sans text-xs italic truncate ${Fe?"text-spur-text/60":"text-spur-text-muted/60"}`,children:Z.description})]}),a.jsx("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:(Z.tags&&Z.tags.length>0?Z.tags.slice(0,2):[Z.category]).map(Re=>a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-base-200 text-spur-text-muted border border-spur-border",children:Re},Re))})]},Z.name)})}),a.jsxs("div",{"data-testid":"agent-bar-hints",className:"flex items-center justify-between px-4 py-2 border-t border-spur-border bg-base-200/70 font-mono text-[11px] text-spur-text-muted select-none",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"↑↓"}),a.jsx("span",{children:"navigate"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"Tab"}),a.jsx("span",{children:"complete"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"↵"}),a.jsx("span",{children:"execute"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"ESC"}),a.jsx("span",{children:"dismiss"})]})]}),a.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px]",children:[a.jsxs("button",{type:"button",onClick:()=>Ce("@"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Reference files",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"@"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"files"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("button",{type:"button",onClick:()=>Ce("#"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Reference tasks and context",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"#"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"context"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("button",{type:"button",onClick:()=>Ce("!"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Execute shell directly",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"!"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"bash"})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-spur-text-muted font-mono text-sm select-none font-bold pl-1",children:">"}),a.jsxs("div",{className:"relative shrink-0",ref:ye,children:[a.jsxs("button",{type:"button",onClick:()=>d(Z=>!Z),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-spur-surface hover:bg-base-200 border border-spur-border text-xs font-mono text-spur-accent transition-colors cursor-pointer group",title:"Target Agent Receiver (default: auto dispatch to orchestrator)","data-testid":"agent-bar-role-tag",children:[a.jsx("span",{className:"text-spur-text-muted font-sans text-[11px]",children:"to:"}),a.jsx("span",{className:"font-semibold",children:Ne.find(Z=>Z.id===l)?.label??l}),a.jsx("span",{className:"text-spur-text-muted text-[10px] group-hover:text-spur-text transition-colors",children:"▾"})]}),u&&a.jsxs("div",{"data-testid":"agent-bar-role-menu",className:"absolute bottom-full left-0 mb-2 w-56 rounded-xl bg-base-100 border border-spur-border shadow-2xl p-1.5 z-50 flex flex-col gap-1 text-spur-text",children:[a.jsx("div",{className:"px-2.5 py-1 text-[10px] font-mono text-spur-text-muted uppercase tracking-wider",children:"Dispatch Target"}),Ne.map(Z=>a.jsxs("button",{type:"button",onClick:()=>{c(Z.id),d(!1)},className:`flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs font-mono transition-colors ${l===Z.id?"bg-spur-accent/15 text-spur-accent font-semibold":"hover:bg-base-200 text-spur-text-muted hover:text-spur-text"}`,children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"font-medium text-spur-text",children:Z.label}),a.jsx("span",{className:"text-[10px] text-spur-text-muted",children:Z.desc})]}),l===Z.id&&a.jsx("span",{className:"text-[12px]",children:"✓"})]},Z.id))]})]}),a.jsx(aG,{variant:"ghost",rows:1,value:k.text,onChange:Z=>S(Z.target.value),onKeyDown:Z=>{if(re&&oe.length>0){if(Z.key==="ArrowDown"){Z.preventDefault(),b(ke=>(ke+1)%oe.length);return}if(Z.key==="ArrowUp"){Z.preventDefault(),b(ke=>(ke-1+oe.length)%oe.length);return}if(Z.key==="Tab"){Z.preventDefault();const ke=oe[m];ke&&H(ke.name);return}if(Z.key==="Escape"){Z.preventDefault(),f(!0);return}}RJ(Z)&&(Ge||(Z.preventDefault(),he()))},placeholder:"Ask a coding agent to refine or implement, or type / for commands…","aria-label":"Agent prompt",className:"flex-1 min-h-9 resize-none bg-transparent text-spur-text placeholder:text-spur-text-muted border-0 focus:ring-0 focus:outline-none","data-testid":"agent-bar-input"}),a.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>n(!1),"aria-label":"Collapse agent prompt bar","aria-expanded":!0,className:"text-spur-text-muted hover:text-spur-text h-8 w-8 p-0 shrink-0",children:"▾"})]}),l==="auto"&&M&&a.jsx("div",{"data-testid":"agent-bar-orchestrator-missing",role:"status",className:"px-1 text-xs text-spur-text-muted",children:"Orchestrator unavailable — no orchestrator instance is bound to this project, so requests cannot be delivered yet."}),F!==null&&a.jsxs("div",{role:"alert",className:"rounded-lg px-2.5 py-1 text-xs bg-spur-error/10 text-spur-error",children:["Not sent: ",F]}),te&&a.jsxs("div",{"data-receipt-state":I,role:"status",className:`rounded-lg px-2.5 py-1 text-xs ${V.tone==="err"?"bg-spur-error/10 text-spur-error":V.tone==="warn"?"bg-spur-warning/10 text-spur-warning":"bg-spur-success/10 text-spur-success"}`,children:[a.jsx("span",{"aria-hidden":"true",className:"mr-1",children:V.icon}),a.jsx("span",{className:"font-medium",children:V.label}),a.jsxs("span",{className:"text-spur-text-muted",children:[" ","— ",V.meaning," Next: ",V.action,"."]}),z&&a.jsx("span",{className:"text-spur-text-muted",children:" (results feed unavailable)"})]})]})}function PJ(e){return u0(e.host)?`${e.name} (${e.host?.trim()})`:e.name}function u0(e){const t=e?.trim().toLowerCase();return t!==void 0&&t!==""&&t!=="localhost"&&t!=="127.0.0.1"&&t!=="::1"}function BJ(e){return e.port<=0||!e.running&&!u0(e.host)?null:`http://${e.host?.trim()||"localhost"}:${e.port}/board`}async function $J(e,t){return Promise.all(e.map(async n=>!n.running&&n.port>0&&u0(n.host)?{...n,running:await t(`http://${n.host?.trim()}:${n.port}/api/health`)}:n))}async function UJ(e){try{return await Xe(new Request(e,{mode:"no-cors"}),1500),!0}catch{return!1}}function zJ({name:e}){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;const n=Math.abs(t)%8,s=["text-emerald-400 bg-emerald-500/10 border-emerald-500/30","text-sky-400 bg-sky-500/10 border-sky-500/30","text-indigo-400 bg-indigo-500/10 border-indigo-500/30","text-amber-400 bg-amber-500/10 border-amber-500/30","text-rose-400 bg-rose-500/10 border-rose-500/30","text-purple-400 bg-purple-500/10 border-purple-500/30","text-teal-400 bg-teal-500/10 border-teal-500/30","text-cyan-400 bg-cyan-500/10 border-cyan-500/30"][n],i=()=>{switch(n){case 0:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M8 1.5l5.5 3.2v6.6L8 14.5l-5.5-3.2V4.7L8 1.5z"}),a.jsx("path",{d:"M8 1.5v13M2.5 4.7l5.5 3.3 5.5-3.3"})]});case 1:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),a.jsx("path",{d:"M5 6l2.5 2L5 10M8.5 10H11"})]});case 2:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"4.5",cy:"4",r:"1.5"}),a.jsx("circle",{cx:"4.5",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"11.5",cy:"7",r:"1.5"}),a.jsx("path",{d:"M4.5 5.5v5M4.5 7.5a4 4 0 004-1"})]});case 3:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M8 2l5.5 3-5.5 3-5.5-3L8 2z"}),a.jsx("path",{d:"M2.5 8l5.5 3 5.5-3M2.5 11l5.5 3 5.5-3"})]});case 4:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5"}),a.jsx("path",{d:"M6 1.5v2M10 1.5v2M6 12.5v2M10 12.5v2M1.5 6h2M1.5 10h2M12.5 6h2M12.5 10h2"})]});case 5:return a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5M9 3l-2 10"})});case 6:return a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M2 4a1.5 1.5 0 011.5-1.5h2.8a1.5 1.5 0 011.06.44l1.14 1.14c.28.28.66.42 1.06.42H12.5A1.5 1.5 0 0114 6v6a1.5 1.5 0 01-1.5 1.5h-9A1.5 1.5 0 012 12V4z"})});default:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6"}),a.jsx("path",{d:"M2 8h12M8 2a9 9 0 010 12 9 9 0 010-12z"})]})}};return a.jsx("span",{"data-testid":"project-avatar-icon",className:`flex h-7 w-7 items-center justify-center rounded border ${s}`,children:i()})}function RS({currentName:e,collapsed:t=!1}){const[n,r]=h.useState(!1),[s,i]=h.useState([]),[o,l]=h.useState(null),[c,u]=h.useState(null),d=h.useRef(null);h.useEffect(()=>{if(!n)return;const m=new AbortController;return Xe(new Request(`${it()}/projects`,{signal:m.signal})).then(async b=>{if(!b.ok)return;const y=(await b.json()).projects??[];i(y);const E=await $J(y,UJ);m.signal.aborted||i(E)}).catch(()=>{u("Failed to load projects")}),()=>m.abort()},[n]),h.useEffect(()=>{if(!n)return;const m=x=>{x.key==="Escape"&&r(!1)},b=x=>{d.current&&!d.current.contains(x.target)&&r(!1)};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b)}},[n]);const p=async m=>{if(m.current){r(!1);return}const b=BJ(m);if(b){window.location.href=b;return}l(m.name);try{const x=await Xe(new Request(`${it()}/projects/start`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:m.name,path:m.path})}));if(!x.ok)throw new Error("Failed to start project");const y=await x.json();window.location.href=y.url||`http://${m.host??"localhost"}:${y.port}/board`}catch(x){u(x instanceof Error?x.message:"Start failed"),l(null)}},f=a.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-haspopup":"listbox","aria-expanded":n,"aria-label":`Switch project: ${e}`,title:e,"data-testid":"project-switcher-trigger",className:"group relative flex h-8 w-8 items-center justify-center rounded-md hover:bg-spur-accent/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-spur-accent",children:[a.jsx("span",{className:`items-center justify-center ${n?"hidden":"flex group-hover:hidden"}`,children:a.jsx(zJ,{name:e})}),a.jsx("span",{"data-testid":"project-switcher-chevron",className:`h-7 w-7 items-center justify-center rounded text-spur-text ${n?"flex":"hidden group-hover:flex"}`,children:a.jsx("svg",{className:`h-4 w-4 shrink-0 transition-transform ${n?"rotate-180 text-spur-accent":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M4 6l4 4 4-4"})})})]});return a.jsxs("div",{className:`relative ${t?"flex items-center justify-center":"min-w-0 flex-1"}`,ref:d,children:[t?n?f:a.jsx(ur,{position:"right",tip:`Switch project: ${e}`,className:"block",children:f}):a.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-haspopup":"listbox","aria-expanded":n,"aria-label":"Switch project",title:e,"data-testid":"project-switcher-trigger",className:"flex w-full items-center justify-between gap-1 rounded-md px-1.5 py-1 text-left text-sm font-semibold text-spur-text hover:bg-spur-border/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-spur-accent",children:[a.jsx("span",{className:"font-semibold truncate",children:e}),a.jsx("svg",{className:`h-4 w-4 shrink-0 transition-transform ${n?"rotate-180":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M4 6l4 4 4-4"})})]}),n&&a.jsxs("div",{role:"listbox","aria-label":"Registered projects","data-testid":"project-switcher-menu",className:`absolute z-50 w-64 rounded-md border border-spur-border bg-spur-surface p-1 shadow-lg ${t?"left-full top-0 ml-2":"left-0 top-full mt-1"}`,children:[a.jsx("div",{className:"px-2 py-1 text-xs font-medium text-spur-text-muted border-b border-spur-border/50 mb-1",children:"Projects"}),s.length===0?a.jsx("div",{className:"px-2 py-1.5 text-xs text-spur-text-muted",children:c||"No projects registered"}):s.map(m=>a.jsxs("button",{type:"button",role:"option","aria-selected":m.current,disabled:o===m.name,onClick:()=>p(m),"data-testid":`project-item-${m.name}`,className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-xs text-left transition-colors ${m.current?"bg-spur-accent/15 text-spur-accent font-medium":"text-spur-text hover:bg-spur-border/30"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx("span",{className:`h-2 w-2 rounded-full shrink-0 ${m.running?"bg-green-500":"bg-gray-400"}`,title:m.running?`Running on port ${m.port}`:"Stopped"}),a.jsx("span",{className:"truncate",children:PJ(m)})]}),o===m.name?a.jsx("span",{className:"text-[10px] text-spur-accent animate-pulse",children:"Starting..."}):m.current?a.jsx("span",{className:"text-[10px] font-semibold text-spur-accent",children:"current"}):m.running?a.jsxs("span",{className:"text-[10px] text-spur-text-muted",children:[":",m.port]}):a.jsx("span",{className:"text-[10px] text-spur-text-muted",children:"stopped"})]},m.path))]})]})}const nC="spur-theme";function HJ(){try{const e=localStorage.getItem(nC);if(e==="light"||e==="dark")return e}catch{}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function GJ(e){document.documentElement.setAttribute("data-theme",e);try{localStorage.setItem(nC,e)}catch{}}function WJ(e){const t=e==="dark"?"light":"dark";return GJ(t),t}function DS(){const[e,t]=h.useState(HJ);h.useEffect(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)"),i=o=>{if(!(()=>{try{return localStorage.getItem("spur-theme")}catch{return null}})()){const c=o.matches?"dark":"light";t(c),document.documentElement.setAttribute("data-theme",c)}};return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[]);const n=h.useCallback(()=>t(WJ),[]),r=e==="dark"?"Switch to light mode":"Switch to dark mode";return a.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,className:"flex h-8 w-8 items-center justify-center rounded-md text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent","aria-label":r,title:r,children:e==="dark"?a.jsx(AG,{className:"h-4 w-4 shrink-0",strokeWidth:1.8,"aria-hidden":"true"}):a.jsx(vG,{className:"h-4 w-4 shrink-0",strokeWidth:1.8,"aria-hidden":"true"})})}const qJ="Modules";function VJ(){const[e,t]=h.useState(qJ);return h.useEffect(()=>{const n=new AbortController;return Xe(new Request(`${it()}/project`,{signal:n.signal})).then(async r=>{if(!r.ok)return;const s=await r.json();s.name&&t(s.name)}).catch(()=>{}),()=>n.abort()},[]),e}function YJ({direction:e}){const t=e==="expand";return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),a.jsx("line",{x1:"6",y1:"2",x2:"6",y2:"14"}),t?a.jsx("path",{d:"M9 6l2 2-2 2"}):a.jsx("path",{d:"M11 6l-2 2 2 2"})]})}function OS({collapsed:e,onToggle:t}){const n=e?"Expand sidebar":"Collapse sidebar";return a.jsx("button",{type:"button",onClick:t,"aria-label":n,title:n,"data-testid":e?"sidebar-expand":"sidebar-collapse",className:"flex h-8 w-8 items-center justify-center rounded-md text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent",children:a.jsx(YJ,{direction:e?"expand":"collapse"})})}function LS({collapsed:e}){const t=a.jsx(MS,{to:"/board/settings","aria-label":"Open settings",title:"Open settings","data-testid":"sidebar-settings",className:({isActive:n})=>`flex h-8 w-8 items-center justify-center rounded-md transition-colors ${n?"bg-spur-accent/20 text-spur-accent":"text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent"} focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent`,children:a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})});return e?a.jsx(ur,{position:"right",tip:"Settings",className:"block",children:t}):t}function KJ({collapsed:e,onToggle:t,onMobileClose:n}){const r=VJ(),{registry:s}=JA();return a.jsxs("aside",{className:`flex flex-col bg-spur-surface border-r border-spur-border ${e?"overflow-visible":"overflow-hidden"}`,children:[a.jsx("div",{"data-spur-drag-region":"","data-testid":"desktop-drag-region",className:"h-0 w-full shrink-0","aria-hidden":"true"}),e?a.jsx("div",{className:"flex items-center justify-center border-b border-spur-border shrink-0 py-2",children:a.jsx(RS,{currentName:r,collapsed:!0})}):a.jsxs("div",{className:"flex items-center justify-between gap-1 p-3 border-b border-spur-border shrink-0",children:[a.jsx(RS,{currentName:r}),n&&a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text-muted md:hidden",onClick:n,"aria-label":"Close navigation",children:"✕"})]}),a.jsx("nav",{className:`flex-1 ${e?"overflow-visible":"overflow-y-auto"}`,children:s.modules.filter(i=>i.id!=="settings").map(i=>{const o=i.sidebarLabel??i.name,l=a.jsxs(MS,{to:`/board/${i.route}`,className:({isActive:c})=>`flex items-center gap-2 px-3 py-2 text-sm transition-colors ${c?"bg-spur-accent/20 text-spur-accent":"text-spur-text-muted hover:text-spur-text hover:bg-spur-border/30"} ${e?"justify-center py-3":""}`,children:[a.jsx("span",{className:"flex h-5 w-5 items-center justify-center shrink-0",children:a.jsx(Rr,{id:i.id,icon:i.icon})}),!e&&a.jsx("span",{children:o})]},i.id);if(e){const c=i.description?`${o}
319
+ `},LX={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function jX(e){let{announcements:t=LX,container:n,hiddenTextDescribedById:r,screenReaderInstructions:s=OX}=e;const{announce:i,announcement:o}=IX(),l=xu("DndLiveRegion"),[c,u]=h.useState(!1);if(h.useEffect(()=>{u(!0)},[]),RX(h.useMemo(()=>({onDragStart(p){let{active:f}=p;i(t.onDragStart({active:f}))},onDragMove(p){let{active:f,over:m}=p;t.onDragMove&&i(t.onDragMove({active:f,over:m}))},onDragOver(p){let{active:f,over:m}=p;i(t.onDragOver({active:f,over:m}))},onDragEnd(p){let{active:f,over:m}=p;i(t.onDragEnd({active:f,over:m}))},onDragCancel(p){let{active:f,over:m}=p;i(t.onDragCancel({active:f,over:m}))}}),[i,t])),!c)return null;const d=st.createElement(st.Fragment,null,st.createElement(CX,{id:r,value:s.draggable}),st.createElement(_X,{id:l,announcement:o}));return n?Ur.createPortal(d,n):d}var Zt;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Zt||(Zt={}));function pc(){}function hS(e,t){return h.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function MX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return h.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const Zn=Object.freeze({x:0,y:0});function FX(e,t){const n=dc(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function PX(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function BX(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function $X(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,l=i-n;if(r<s&&n<i){const c=t.width*t.height,u=e.width*e.height,d=o*l,p=d/(c+u-d);return Number(p.toFixed(4))}return 0}const UX=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const s=[];for(const i of r){const{id:o}=i,l=n.get(o);if(l){const c=$X(l,t);c>0&&s.push({id:o,data:{droppableContainer:i,value:c}})}}return s.sort(PX)};function zX(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function IA(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Zn}function HX(e){return function(n){for(var r=arguments.length,s=new Array(r>1?r-1:0),i=1;i<r;i++)s[i-1]=arguments[i];return s.reduce((o,l)=>({...o,top:o.top+e*l.y,bottom:o.bottom+e*l.y,left:o.left+e*l.x,right:o.right+e*l.x}),{...n})}}const GX=HX(1);function RA(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function WX(e,t,n){const r=RA(t);if(!r)return e;const{scaleX:s,scaleY:i,x:o,y:l}=r,c=e.left-o-(1-s)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,p=i?e.height/i:e.height;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c}}const qX={ignoreTransform:!1};function No(e,t){t===void 0&&(t=qX);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:d}=Nn(e).getComputedStyle(e);u&&(n=WX(n,u,d))}const{top:r,left:s,width:i,height:o,bottom:l,right:c}=n;return{top:r,left:s,width:i,height:o,bottom:l,right:c}}function gS(e){return No(e,{ignoreTransform:!0})}function VX(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function YX(e,t){return t===void 0&&(t=Nn(e).getComputedStyle(e)),t.position==="fixed"}function KX(e,t){t===void 0&&(t=Nn(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const i=t[s];return typeof i=="string"?n.test(i):!1})}function r0(e,t){const n=[];function r(s){if(t!=null&&n.length>=t||!s)return n;if(t0(s)&&s.scrollingElement!=null&&!n.includes(s.scrollingElement))return n.push(s.scrollingElement),n;if(!wo(s)||AA(s)||n.includes(s))return n;const i=Nn(e).getComputedStyle(s);return s!==e&&KX(s,i)&&n.push(s),YX(s,i)?n:r(s.parentNode)}return e?r(e):n}function DA(e){const[t]=r0(e,1);return t??null}function Od(e){return!gu||!e?null:Va(e)?e:e0(e)?t0(e)||e===Ya(e).scrollingElement?window:wo(e)?e:null:null}function OA(e){return Va(e)?e.scrollX:e.scrollLeft}function LA(e){return Va(e)?e.scrollY:e.scrollTop}function Pp(e){return{x:OA(e),y:LA(e)}}var rn;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(rn||(rn={}));function jA(e){return!gu||!e?!1:e===document.scrollingElement}function MA(e){const t={x:0,y:0},n=jA(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},s=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,o=e.scrollTop>=r.y,l=e.scrollLeft>=r.x;return{isTop:s,isLeft:i,isBottom:o,isRight:l,maxScroll:r,minScroll:t}}const ZX={x:.2,y:.2};function XX(e,t,n,r,s){let{top:i,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),s===void 0&&(s=ZX);const{isTop:u,isBottom:d,isLeft:p,isRight:f}=MA(e),m={x:0,y:0},b={x:0,y:0},x={height:t.height*s.y,width:t.width*s.x};return!u&&i<=t.top+x.height?(m.y=rn.Backward,b.y=r*Math.abs((t.top+x.height-i)/x.height)):!d&&c>=t.bottom-x.height&&(m.y=rn.Forward,b.y=r*Math.abs((t.bottom-x.height-c)/x.height)),!f&&l>=t.right-x.width?(m.x=rn.Forward,b.x=r*Math.abs((t.right-x.width-l)/x.width)):!p&&o<=t.left+x.width&&(m.x=rn.Backward,b.x=r*Math.abs((t.left+x.width-o)/x.width)),{direction:m,speed:b}}function QX(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:o}=window;return{top:0,left:0,right:i,bottom:o,width:i,height:o}}const{top:t,left:n,right:r,bottom:s}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:s,width:e.clientWidth,height:e.clientHeight}}function FA(e){return e.reduce((t,n)=>ha(t,Pp(n)),Zn)}function JX(e){return e.reduce((t,n)=>t+OA(n),0)}function eQ(e){return e.reduce((t,n)=>t+LA(n),0)}function PA(e,t){if(t===void 0&&(t=No),!e)return;const{top:n,left:r,bottom:s,right:i}=t(e);DA(e)&&(s<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const tQ=[["x",["left","right"],JX],["y",["top","bottom"],eQ]];class s0{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=r0(n),s=FA(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,o,l]of tQ)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=s[i]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ri{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var s;(s=this.target)==null||s.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function nQ(e){const{EventTarget:t}=Nn(e);return e instanceof t?e:Ya(e)}function Ld(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var jn;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(jn||(jn={}));function bS(e){e.preventDefault()}function rQ(e){e.stopPropagation()}var It;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(It||(It={}));const BA={start:[It.Space,It.Enter],cancel:[It.Esc],end:[It.Space,It.Enter,It.Tab]},sQ=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case It.Right:return{...n,x:n.x+25};case It.Left:return{...n,x:n.x-25};case It.Down:return{...n,y:n.y+25};case It.Up:return{...n,y:n.y-25}}};class a0{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ri(Ya(n)),this.windowListeners=new Ri(Nn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(jn.Resize,this.handleCancel),this.windowListeners.add(jn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(jn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&PA(r),n(Zn)}handleKeyDown(t){if(n0(t)){const{active:n,context:r,options:s}=this.props,{keyboardCodes:i=BA,coordinateGetter:o=sQ,scrollBehavior:l="smooth"}=s,{code:c}=t;if(i.end.includes(c)){this.handleEnd(t);return}if(i.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:Zn;this.referenceCoordinates||(this.referenceCoordinates=d);const p=o(t,{active:n,context:r.current,currentCoordinates:d});if(p){const f=uc(p,d),m={x:0,y:0},{scrollableAncestors:b}=r.current;for(const x of b){const y=t.code,{isTop:E,isRight:A,isLeft:w,isBottom:N,maxScroll:_,minScroll:k}=MA(x),S=QX(x),v={x:Math.min(y===It.Right?S.right-S.width/2:S.right,Math.max(y===It.Right?S.left:S.left+S.width/2,p.x)),y:Math.min(y===It.Down?S.bottom-S.height/2:S.bottom,Math.max(y===It.Down?S.top:S.top+S.height/2,p.y))},O=y===It.Right&&!A||y===It.Left&&!w,C=y===It.Down&&!N||y===It.Up&&!E;if(O&&v.x!==p.x){const M=x.scrollLeft+f.x,B=y===It.Right&&M<=_.x||y===It.Left&&M>=k.x;if(B&&!f.y){x.scrollTo({left:M,behavior:l});return}B?m.x=x.scrollLeft-M:m.x=y===It.Right?x.scrollLeft-_.x:x.scrollLeft-k.x,m.x&&x.scrollBy({left:-m.x,behavior:l});break}else if(C&&v.y!==p.y){const M=x.scrollTop+f.y,B=y===It.Down&&M<=_.y||y===It.Up&&M>=k.y;if(B&&!f.x){x.scrollTo({top:M,behavior:l});return}B?m.y=x.scrollTop-M:m.y=y===It.Down?x.scrollTop-_.y:x.scrollTop-k.y,m.y&&x.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(t,ha(uc(p,this.referenceCoordinates),m))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}a0.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=BA,onActivation:s}=t,{active:i}=n;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const l=i.activatorNode.current;return l&&e.target!==l?!1:(e.preventDefault(),s?.({event:e.nativeEvent}),!0)}return!1}}];function xS(e){return!!(e&&"distance"in e)}function yS(e){return!!(e&&"delay"in e)}class i0{constructor(t,n,r){var s;r===void 0&&(r=nQ(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:o}=i;this.props=t,this.events=n,this.document=Ya(o),this.documentListeners=new Ri(this.document),this.listeners=new Ri(r),this.windowListeners=new Ri(Nn(o)),this.initialCoordinates=(s=dc(i))!=null?s:Zn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(jn.Resize,this.handleCancel),this.windowListeners.add(jn.DragStart,bS),this.windowListeners.add(jn.VisibilityChange,this.handleCancel),this.windowListeners.add(jn.ContextMenu,bS),this.documentListeners.add(jn.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(yS(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(xS(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:s}=this.props;s(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(jn.Click,rQ,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(jn.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:s,props:i}=this,{onMove:o,options:{activationConstraint:l}}=i;if(!s)return;const c=(n=dc(t))!=null?n:Zn,u=uc(s,c);if(!r&&l){if(xS(l)){if(l.tolerance!=null&&Ld(u,l.tolerance))return this.handleCancel();if(Ld(u,l.distance))return this.handleStart()}if(yS(l)&&Ld(u,l.tolerance))return this.handleCancel();this.handlePending(l,u);return}t.cancelable&&t.preventDefault(),o(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===It.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const aQ={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class o0 extends i0{constructor(t){const{event:n}=t,r=Ya(n.target);super(t,aQ,r)}}o0.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const iQ={move:{name:"mousemove"},end:{name:"mouseup"}};var Bp;(function(e){e[e.RightClick=2]="RightClick"})(Bp||(Bp={}));class oQ extends i0{constructor(t){super(t,iQ,Ya(t.event.target))}}oQ.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Bp.RightClick?!1:(r?.({event:n}),!0)}}];const jd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class lQ extends i0{constructor(t){super(t,jd)}static setup(){return window.addEventListener(jd.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(jd.move.name,t)};function t(){}}}lQ.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:s}=n;return s.length>1?!1:(r?.({event:n}),!0)}}];var Di;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Di||(Di={}));var fc;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(fc||(fc={}));function cQ(e){let{acceleration:t,activator:n=Di.Pointer,canScroll:r,draggingRect:s,enabled:i,interval:o=5,order:l=fc.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:p,threshold:f}=e;const m=dQ({delta:p,disabled:!i}),[b,x]=vX(),y=h.useRef({x:0,y:0}),E=h.useRef({x:0,y:0}),A=h.useMemo(()=>{switch(n){case Di.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Di.DraggableRect:return s}},[n,s,c]),w=h.useRef(null),N=h.useCallback(()=>{const k=w.current;if(!k)return;const S=y.current.x*E.current.x,v=y.current.y*E.current.y;k.scrollBy(S,v)},[]),_=h.useMemo(()=>l===fc.TreeOrder?[...u].reverse():u,[l,u]);h.useEffect(()=>{if(!i||!u.length||!A){x();return}for(const k of _){if(r?.(k)===!1)continue;const S=u.indexOf(k),v=d[S];if(!v)continue;const{direction:O,speed:C}=XX(k,v,A,t,f);for(const M of["x","y"])m[M][O[M]]||(C[M]=0,O[M]=0);if(C.x>0||C.y>0){x(),w.current=k,b(N,o),y.current=C,E.current=O;return}}y.current={x:0,y:0},E.current={x:0,y:0},x()},[t,N,r,x,i,o,JSON.stringify(A),JSON.stringify(m),b,u,_,d,JSON.stringify(f)])}const uQ={x:{[rn.Backward]:!1,[rn.Forward]:!1},y:{[rn.Backward]:!1,[rn.Forward]:!1}};function dQ(e){let{delta:t,disabled:n}=e;const r=cc(t);return vo(s=>{if(n||!r||!s)return uQ;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[rn.Backward]:s.x[rn.Backward]||i.x===-1,[rn.Forward]:s.x[rn.Forward]||i.x===1},y:{[rn.Backward]:s.y[rn.Backward]||i.y===-1,[rn.Forward]:s.y[rn.Forward]||i.y===1}}},[n,t,r])}function pQ(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return vo(s=>{var i;return t==null?null:(i=r??s)!=null?i:null},[r,t])}function fQ(e,t){return h.useMemo(()=>e.reduce((n,r)=>{const{sensor:s}=r,i=s.activators.map(o=>({eventName:o.eventName,handler:t(o.handler,r)}));return[...n,...i]},[]),[e,t])}var Xi;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Xi||(Xi={}));var $p;(function(e){e.Optimized="optimized"})($p||($p={}));const ES=new Map;function mQ(e,t){let{dragging:n,dependencies:r,config:s}=t;const[i,o]=h.useState(null),{frequency:l,measure:c,strategy:u}=s,d=h.useRef(e),p=y(),f=Zi(p),m=h.useCallback(function(E){E===void 0&&(E=[]),!f.current&&o(A=>A===null?E:A.concat(E.filter(w=>!A.includes(w))))},[f]),b=h.useRef(null),x=vo(E=>{if(p&&!n)return ES;if(!E||E===ES||d.current!==e||i!=null){const A=new Map;for(let w of e){if(!w)continue;if(i&&i.length>0&&!i.includes(w.id)&&w.rect.current){A.set(w.id,w.rect.current);continue}const N=w.node.current,_=N?new s0(c(N),N):null;w.rect.current=_,_&&A.set(w.id,_)}return A}return E},[e,i,n,p,c]);return h.useEffect(()=>{d.current=e},[e]),h.useEffect(()=>{p||m()},[n,p]),h.useEffect(()=>{i&&i.length>0&&o(null)},[JSON.stringify(i)]),h.useEffect(()=>{p||typeof l!="number"||b.current!==null||(b.current=setTimeout(()=>{m(),b.current=null},l))},[l,p,m,...r]),{droppableRects:x,measureDroppableContainers:m,measuringScheduled:i!=null};function y(){switch(u){case Xi.Always:return!1;case Xi.BeforeDragging:return n;default:return!n}}}function l0(e,t){return vo(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function hQ(e,t){return l0(e,t)}function gQ(e){let{callback:t,disabled:n}=e;const r=bu(t),s=h.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return h.useEffect(()=>()=>s?.disconnect(),[s]),s}function yu(e){let{callback:t,disabled:n}=e;const r=bu(t),s=h.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return h.useEffect(()=>()=>s?.disconnect(),[s]),s}function bQ(e){return new s0(No(e),e)}function SS(e,t,n){t===void 0&&(t=bQ);const[r,s]=h.useState(null);function i(){s(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=t(e);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=gQ({callback(c){if(e)for(const u of c){const{type:d,target:p}=u;if(d==="childList"&&p instanceof HTMLElement&&p.contains(e)){i();break}}}}),l=yu({callback:i});return _r(()=>{i(),e?(l?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[e]),r}function xQ(e){const t=l0(e);return IA(e,t)}const wS=[];function yQ(e){const t=h.useRef(e),n=vo(r=>e?r&&r!==wS&&e&&t.current&&e.parentNode===t.current.parentNode?r:r0(e):wS,[e]);return h.useEffect(()=>{t.current=e},[e]),n}function EQ(e){const[t,n]=h.useState(null),r=h.useRef(e),s=h.useCallback(i=>{const o=Od(i.target);o&&n(l=>l?(l.set(o,Pp(o)),new Map(l)):null)},[]);return h.useEffect(()=>{const i=r.current;if(e!==i){o(i);const l=e.map(c=>{const u=Od(c);return u?(u.addEventListener("scroll",s,{passive:!0}),[u,Pp(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=e}return()=>{o(e),o(i)};function o(l){l.forEach(c=>{const u=Od(c);u?.removeEventListener("scroll",s)})}},[s,e]),h.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,o)=>ha(i,o),Zn):FA(e):Zn,[e,t])}function vS(e,t){t===void 0&&(t=[]);const n=h.useRef(null);return h.useEffect(()=>{n.current=null},t),h.useEffect(()=>{const r=e!==Zn;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?uc(e,n.current):Zn}function SQ(e){h.useEffect(()=>{if(!gu)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function wQ(e,t){return h.useMemo(()=>e.reduce((n,r)=>{let{eventName:s,handler:i}=r;return n[s]=o=>{i(o,t)},n},{}),[e,t])}function $A(e){return h.useMemo(()=>e?VX(e):null,[e])}const NS=[];function vQ(e,t){t===void 0&&(t=No);const[n]=e,r=$A(n?Nn(n):null),[s,i]=h.useState(NS);function o(){i(()=>e.length?e.map(c=>jA(c)?r:new s0(t(c),c)):NS)}const l=yu({callback:o});return _r(()=>{l?.disconnect(),o(),e.forEach(c=>l?.observe(c))},[e]),s}function UA(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return wo(t)?t:e}function NQ(e){let{measure:t}=e;const[n,r]=h.useState(null),s=h.useCallback(u=>{for(const{target:d}of u)if(wo(d)){r(p=>{const f=t(d);return p?{...p,width:f.width,height:f.height}:f});break}},[t]),i=yu({callback:s}),o=h.useCallback(u=>{const d=UA(u);i?.disconnect(),d&&i?.observe(d),r(d?t(d):null)},[t,i]),[l,c]=lc(o);return h.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const TQ=[{sensor:o0,options:{}},{sensor:a0,options:{}}],kQ={current:{}},Il={draggable:{measure:gS},droppable:{measure:gS,strategy:Xi.WhileDragging,frequency:$p.Optimized},dragOverlay:{measure:No}};class Oi extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const AQ={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Oi,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:pc},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Il,measureDroppableContainers:pc,windowRect:null,measuringScheduled:!1},zA={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:pc,draggableNodes:new Map,over:null,measureDroppableContainers:pc},To=h.createContext(zA),HA=h.createContext(AQ);function CQ(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Oi}}}function _Q(e,t){switch(t.type){case Zt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Zt.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Zt.DragEnd:case Zt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Zt.RegisterDroppable:{const{element:n}=t,{id:r}=n,s=new Oi(e.droppable.containers);return s.set(r,n),{...e,droppable:{...e.droppable,containers:s}}}case Zt.SetDroppableDisabled:{const{id:n,key:r,disabled:s}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new Oi(e.droppable.containers);return o.set(n,{...i,disabled:s}),{...e,droppable:{...e.droppable,containers:o}}}case Zt.UnregisterDroppable:{const{id:n,key:r}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new Oi(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function IQ(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:s}=h.useContext(To),i=cc(r),o=cc(n?.id);return h.useEffect(()=>{if(!t&&!r&&i&&o!=null){if(!n0(i)||document.activeElement===i.target)return;const l=s.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const p=kX(d);if(p){p.focus();break}}})}},[r,t,s,o,i]),null}function GA(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((s,i)=>i({transform:s,...r}),n):n}function RQ(e){return h.useMemo(()=>({draggable:{...Il.draggable,...e?.draggable},droppable:{...Il.droppable,...e?.droppable},dragOverlay:{...Il.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function DQ(e){let{activeNode:t,measure:n,initialRect:r,config:s=!0}=e;const i=h.useRef(!1),{x:o,y:l}=typeof s=="boolean"?{x:s,y:s}:s;_r(()=>{if(!o&&!l||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),p=IA(d,r);if(o||(p.x=0),l||(p.y=0),i.current=!0,Math.abs(p.x)>0||Math.abs(p.y)>0){const f=DA(u);f&&f.scrollBy({top:p.y,left:p.x})}},[t,o,l,r,n])}const Eu=h.createContext({...Zn,scaleX:1,scaleY:1});var Br;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Br||(Br={}));const OQ=h.memo(function(t){var n,r,s,i;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=TQ,collisionDetection:p=UX,measuring:f,modifiers:m,...b}=t;const x=h.useReducer(_Q,void 0,CQ),[y,E]=x,[A,w]=DX(),[N,_]=h.useState(Br.Uninitialized),k=N===Br.Initialized,{draggable:{active:S,nodes:v,translate:O},droppable:{containers:C}}=y,M=S!=null?v.get(S):null,B=h.useRef({initial:null,translated:null}),R=h.useMemo(()=>{var Oe;return S!=null?{id:S,data:(Oe=M?.data)!=null?Oe:kQ,rect:B}:null},[S,M]),z=h.useRef(null),[W,F]=h.useState(null),[J,K]=h.useState(null),X=Zi(b,Object.values(b)),I=xu("DndDescribedBy",o),V=h.useMemo(()=>C.getEnabled(),[C]),te=RQ(f),{droppableRects:L,measureDroppableContainers:ye,measuringScheduled:xe}=mQ(V,{dragging:k,dependencies:[O.x,O.y],config:te.droppable}),P=pQ(v,S),oe=h.useMemo(()=>J?dc(J):null,[J]),re=Ct(),H=hQ(P,te.draggable.measure);DQ({activeNode:S!=null?v.get(S):null,config:re.layoutShiftCompensation,initialRect:H,measure:te.draggable.measure});const Ce=SS(P,te.draggable.measure,H),me=SS(P?P.parentElement:null),he=h.useRef({activatorEvent:null,active:null,activeNode:P,collisionRect:null,collisions:null,droppableRects:L,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:C,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ne=C.getNodeFor((n=he.current.over)==null?void 0:n.id),Ge=NQ({measure:te.dragOverlay.measure}),Z=(r=Ge.nodeRef.current)!=null?r:P,ke=k?(s=Ge.rect)!=null?s:Ce:null,Fe=!!(Ge.nodeRef.current&&Ge.rect),Re=xQ(Fe?null:Ce),rt=$A(Z?Nn(Z):null),ae=yQ(k?Ne??P:null),pe=vQ(ae),De=GA(m,{transform:{x:O.x-Re.x,y:O.y-Re.y,scaleX:1,scaleY:1},activatorEvent:J,active:R,activeNodeRect:Ce,containerNodeRect:me,draggingNodeRect:ke,over:he.current.over,overlayNodeRect:Ge.rect,scrollableAncestors:ae,scrollableAncestorRects:pe,windowRect:rt}),Me=oe?ha(oe,O):null,Le=EQ(ae),ot=vS(Le),dt=vS(Le,[Ce]),se=ha(De,ot),fe=ke?GX(ke,De):null,je=R&&fe?p({active:R,collisionRect:fe,droppableRects:L,droppableContainers:V,pointerCoordinates:Me}):null,Y=BX(je,"id"),[He,Ue]=h.useState(null),at=Fe?De:ha(De,dt),Nt=zX(at,(i=He?.rect)!=null?i:null,Ce),At=h.useRef(null),de=h.useCallback((Oe,Qe)=>{let{sensor:qe,options:St}=Qe;if(z.current==null)return;const ce=v.get(z.current);if(!ce)return;const Ee=Oe.nativeEvent,Ye=new qe({active:z.current,activeNode:ce,event:Ee,options:St,context:he,onAbort(ee){if(!v.get(ee))return;const{onDragAbort:lt}=X.current,bt={id:ee};lt?.(bt),A({type:"onDragAbort",event:bt})},onPending(ee,We,lt,bt){if(!v.get(ee))return;const{onDragPending:xr}=X.current,nr={id:ee,constraint:We,initialCoordinates:lt,offset:bt};xr?.(nr),A({type:"onDragPending",event:nr})},onStart(ee){const We=z.current;if(We==null)return;const lt=v.get(We);if(!lt)return;const{onDragStart:bt}=X.current,In={activatorEvent:Ee,active:{id:We,data:lt.data,rect:B}};Ur.unstable_batchedUpdates(()=>{bt?.(In),_(Br.Initializing),E({type:Zt.DragStart,initialCoordinates:ee,active:We}),A({type:"onDragStart",event:In}),F(At.current),K(Ee)})},onMove(ee){E({type:Zt.DragMove,coordinates:ee})},onEnd:Dt(Zt.DragEnd),onCancel:Dt(Zt.DragCancel)});At.current=Ye;function Dt(ee){return async function(){const{active:lt,collisions:bt,over:In,scrollAdjustedTranslate:xr}=he.current;let nr=null;if(lt&&xr){const{cancelDrop:Hn}=X.current;nr={activatorEvent:Ee,active:lt,collisions:bt,delta:xr,over:In},ee===Zt.DragEnd&&typeof Hn=="function"&&await Promise.resolve(Hn(nr))&&(ee=Zt.DragCancel)}z.current=null,Ur.unstable_batchedUpdates(()=>{E({type:ee}),_(Br.Uninitialized),Ue(null),F(null),K(null),At.current=null;const Hn=ee===Zt.DragEnd?"onDragEnd":"onDragCancel";if(nr){const Ka=X.current[Hn];Ka?.(nr),A({type:Hn,event:nr})}})}}},[v]),_e=h.useCallback((Oe,Qe)=>(qe,St)=>{const ce=qe.nativeEvent,Ee=v.get(St);if(z.current!==null||!Ee||ce.dndKit||ce.defaultPrevented)return;const Ye={active:Ee};Oe(qe,Qe.options,Ye)===!0&&(ce.dndKit={capturedBy:Qe.sensor},z.current=St,de(qe,Qe))},[v,de]),Ve=fQ(d,_e);SQ(d),_r(()=>{Ce&&N===Br.Initializing&&_(Br.Initialized)},[Ce,N]),h.useEffect(()=>{const{onDragMove:Oe}=X.current,{active:Qe,activatorEvent:qe,collisions:St,over:ce}=he.current;if(!Qe||!qe)return;const Ee={active:Qe,activatorEvent:qe,collisions:St,delta:{x:se.x,y:se.y},over:ce};Ur.unstable_batchedUpdates(()=>{Oe?.(Ee),A({type:"onDragMove",event:Ee})})},[se.x,se.y]),h.useEffect(()=>{const{active:Oe,activatorEvent:Qe,collisions:qe,droppableContainers:St,scrollAdjustedTranslate:ce}=he.current;if(!Oe||z.current==null||!Qe||!ce)return;const{onDragOver:Ee}=X.current,Ye=St.get(Y),Dt=Ye&&Ye.rect.current?{id:Ye.id,rect:Ye.rect.current,data:Ye.data,disabled:Ye.disabled}:null,ee={active:Oe,activatorEvent:Qe,collisions:qe,delta:{x:ce.x,y:ce.y},over:Dt};Ur.unstable_batchedUpdates(()=>{Ue(Dt),Ee?.(ee),A({type:"onDragOver",event:ee})})},[Y]),_r(()=>{he.current={activatorEvent:J,active:R,activeNode:P,collisionRect:fe,collisions:je,droppableRects:L,draggableNodes:v,draggingNode:Z,draggingNodeRect:ke,droppableContainers:C,over:He,scrollableAncestors:ae,scrollAdjustedTranslate:se},B.current={initial:ke,translated:fe}},[R,P,je,fe,v,Z,ke,L,C,He,ae,se]),cQ({...re,delta:O,draggingRect:fe,pointerCoordinates:Me,scrollableAncestors:ae,scrollableAncestorRects:pe});const Pe=h.useMemo(()=>({active:R,activeNode:P,activeNodeRect:Ce,activatorEvent:J,collisions:je,containerNodeRect:me,dragOverlay:Ge,draggableNodes:v,droppableContainers:C,droppableRects:L,over:He,measureDroppableContainers:ye,scrollableAncestors:ae,scrollableAncestorRects:pe,measuringConfiguration:te,measuringScheduled:xe,windowRect:rt}),[R,P,Ce,J,je,me,Ge,v,C,L,He,ye,ae,pe,te,xe,rt]),Je=h.useMemo(()=>({activatorEvent:J,activators:Ve,active:R,activeNodeRect:Ce,ariaDescribedById:{draggable:I},dispatch:E,draggableNodes:v,over:He,measureDroppableContainers:ye}),[J,Ve,R,Ce,E,I,v,He,ye]);return st.createElement(_A.Provider,{value:w},st.createElement(To.Provider,{value:Je},st.createElement(HA.Provider,{value:Pe},st.createElement(Eu.Provider,{value:Nt},u)),st.createElement(IQ,{disabled:l?.restoreFocus===!1})),st.createElement(jX,{...l,hiddenTextDescribedById:I}));function Ct(){const Oe=W?.autoScrollEnabled===!1,Qe=typeof c=="object"?c.enabled===!1:c===!1,qe=k&&!Oe&&!Qe;return typeof c=="object"?{...c,enabled:qe}:{enabled:qe}}}),LQ=h.createContext(null),TS="button",jQ="Draggable";function MQ(e){let{id:t,data:n,disabled:r=!1,attributes:s}=e;const i=xu(jQ),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:p,over:f}=h.useContext(To),{role:m=TS,roleDescription:b="draggable",tabIndex:x=0}=s??{},y=c?.id===t,E=h.useContext(y?Eu:LQ),[A,w]=lc(),[N,_]=lc(),k=wQ(o,t),S=Zi(n);_r(()=>(p.set(t,{id:t,key:i,node:A,activatorNode:N,data:S}),()=>{const O=p.get(t);O&&O.key===i&&p.delete(t)}),[p,t]);const v=h.useMemo(()=>({role:m,tabIndex:x,"aria-disabled":r,"aria-pressed":y&&m===TS?!0:void 0,"aria-roledescription":b,"aria-describedby":d.draggable}),[r,m,x,y,b,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:v,isDragging:y,listeners:r?void 0:k,node:A,over:f,setNodeRef:w,setActivatorNodeRef:_,transform:E}}function FQ(){return h.useContext(HA)}const PQ="Droppable",BQ={timeout:25};function $Q(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:s}=e;const i=xu(PQ),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=h.useContext(To),d=h.useRef({disabled:n}),p=h.useRef(!1),f=h.useRef(null),m=h.useRef(null),{disabled:b,updateMeasurementsFor:x,timeout:y}={...BQ,...s},E=Zi(x??r),A=h.useCallback(()=>{if(!p.current){p.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(E.current)?E.current:[E.current]),m.current=null},y)},[y]),w=yu({callback:A,disabled:b||!o}),N=h.useCallback((v,O)=>{w&&(O&&(w.unobserve(O),p.current=!1),v&&w.observe(v))},[w]),[_,k]=lc(N),S=Zi(t);return h.useEffect(()=>{!w||!_.current||(w.disconnect(),p.current=!1,w.observe(_.current))},[_,w]),h.useEffect(()=>(l({type:Zt.RegisterDroppable,element:{id:r,key:i,disabled:n,node:_,rect:f,data:S}}),()=>l({type:Zt.UnregisterDroppable,key:i,id:r})),[r]),h.useEffect(()=>{n!==d.current.disabled&&(l({type:Zt.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)},[r,i,n,l]),{active:o,rect:f,isOver:c?.id===r,node:_,over:c,setNodeRef:k}}function UQ(e){let{animation:t,children:n}=e;const[r,s]=h.useState(null),[i,o]=h.useState(null),l=cc(n);return!n&&!r&&l&&s(l),_r(()=>{if(!i)return;const c=r?.key,u=r?.props.id;if(c==null||u==null){s(null);return}Promise.resolve(t(u,i)).then(()=>{s(null)})},[t,r,i]),st.createElement(st.Fragment,null,n,r?h.cloneElement(r,{ref:o}):null)}const zQ={x:0,y:0,scaleX:1,scaleY:1};function HQ(e){let{children:t}=e;return st.createElement(To.Provider,{value:zA},st.createElement(Eu.Provider,{value:zQ},t))}const GQ={position:"fixed",touchAction:"none"},WQ=e=>n0(e)?"transform 250ms ease":void 0,qQ=h.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:s,children:i,className:o,rect:l,style:c,transform:u,transition:d=WQ}=e;if(!l)return null;const p=s?u:{...u,scaleX:1,scaleY:1},f={...GQ,width:l.width,height:l.height,top:l.top,left:l.left,transform:Aa.Transform.toString(p),transformOrigin:s&&r?FX(r,l):void 0,transition:typeof d=="function"?d(r):d,...c};return st.createElement(n,{className:o,style:f,ref:t},i)}),VQ=e=>t=>{let{active:n,dragOverlay:r}=t;const s={},{styles:i,className:o}=e;if(i!=null&&i.active)for(const[l,c]of Object.entries(i.active))c!==void 0&&(s[l]=n.node.style.getPropertyValue(l),n.node.style.setProperty(l,c));if(i!=null&&i.dragOverlay)for(const[l,c]of Object.entries(i.dragOverlay))c!==void 0&&r.node.style.setProperty(l,c);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(const[c,u]of Object.entries(s))n.node.style.setProperty(c,u);o!=null&&o.active&&n.node.classList.remove(o.active)}},YQ=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Aa.Transform.toString(t)},{transform:Aa.Transform.toString(n)}]},KQ={duration:250,easing:"ease",keyframes:YQ,sideEffects:VQ({styles:{active:{opacity:"0"}}})};function ZQ(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:s}=e;return bu((i,o)=>{if(t===null)return;const l=n.get(i);if(!l)return;const c=l.node.current;if(!c)return;const u=UA(o);if(!u)return;const{transform:d}=Nn(o).getComputedStyle(o),p=RA(d);if(!p)return;const f=typeof t=="function"?t:XQ(t);return PA(c,s.draggable.measure),f({active:{id:i,data:l.data,node:c,rect:s.draggable.measure(c)},draggableNodes:n,dragOverlay:{node:o,rect:s.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:s,transform:p})})}function XQ(e){const{duration:t,easing:n,sideEffects:r,keyframes:s}={...KQ,...e};return i=>{let{active:o,dragOverlay:l,transform:c,...u}=i;if(!t)return;const d={x:l.rect.left-o.rect.left,y:l.rect.top-o.rect.top},p={scaleX:c.scaleX!==1?o.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?o.rect.height*c.scaleY/l.rect.height:1},f={x:c.x-d.x,y:c.y-d.y,...p},m=s({...u,active:o,dragOverlay:l,transform:{initial:c,final:f}}),[b]=m,x=m[m.length-1];if(JSON.stringify(b)===JSON.stringify(x))return;const y=r?.({active:o,dragOverlay:l,...u}),E=l.node.animate(m,{duration:t,easing:n,fill:"forwards"});return new Promise(A=>{E.onfinish=()=>{y?.(),A()}})}}let kS=0;function QQ(e){return h.useMemo(()=>{if(e!=null)return kS++,kS},[e])}const JQ=st.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:s,transition:i,modifiers:o,wrapperElement:l="div",className:c,zIndex:u=999}=e;const{activatorEvent:d,active:p,activeNodeRect:f,containerNodeRect:m,draggableNodes:b,droppableContainers:x,dragOverlay:y,over:E,measuringConfiguration:A,scrollableAncestors:w,scrollableAncestorRects:N,windowRect:_}=FQ(),k=h.useContext(Eu),S=QQ(p?.id),v=GA(o,{activatorEvent:d,active:p,activeNodeRect:f,containerNodeRect:m,draggingNodeRect:y.rect,over:E,overlayNodeRect:y.rect,scrollableAncestors:w,scrollableAncestorRects:N,transform:k,windowRect:_}),O=l0(f),C=ZQ({config:r,draggableNodes:b,droppableContainers:x,measuringConfiguration:A}),M=O?y.setRef:void 0;return st.createElement(HQ,null,st.createElement(UQ,{animation:C},p&&S?st.createElement(qQ,{key:S,id:p.id,ref:M,as:l,activatorEvent:d,adjustScale:t,className:c,transition:i,rect:O,style:{zIndex:u,...s},transform:v},n):null))}),eJ=6e4,tJ=10080*60*1e3,nJ={P1:"error",P2:"warning",P3:"neutral"},rJ={backlog:"bg-spur-text-faint",todo:"bg-spur-info",wip:"bg-spur-warning",testing:"bg-spur-accent",done:"bg-spur-success",blocked:"bg-spur-error",cancelled:"bg-spur-text-faint",deprecated:"bg-spur-text-muted"};function sJ(e,t){const n=new Date(e).getTime(),r=t-n,s=Math.floor(r/1e3);if(s<60)return"just now";const i=Math.floor(s/60);if(i<60)return`${i}m ago`;const o=Math.floor(i/60);if(o<24)return`${o}h ago`;const l=Math.floor(o/24);return l<30?`${l}d ago`:`${Math.floor(l/30)}mo ago`}function WA({task:e,onClick:t}){const{attributes:n,listeners:r,setNodeRef:s,transform:i,isDragging:o}=MQ({id:e.wbs,data:{task:e}}),[l,c]=h.useState(Date.now());h.useEffect(()=>{const m=setInterval(()=>c(Date.now()),eJ);return()=>clearInterval(m)},[]);const u=i?{transform:Aa.Transform.toString(i),zIndex:o?50:void 0}:void 0,{subtaskProgress:d}=Ux(),p=d.get(e.wbs),f=e.updatedAt?l-new Date(e.updatedAt).getTime()>tJ:!1;return a.jsx(yx,{variant:"compact",asChild:!0,className:`group bg-spur-surface-2 hover:bg-spur-surface-3 rounded-xl border border-spur-border hover:border-spur-accent/60 shadow-xs hover:shadow-md cursor-pointer transition-all duration-150 w-full text-left ${o?"opacity-30":""}`,children:a.jsx("button",{ref:s,type:"button",style:u,onClick:()=>t(e.wbs),...r,...n,"aria-roledescription":"draggable card",children:a.jsxs(Ex,{className:"p-3 gap-1.5",children:[a.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-mono font-semibold text-spur-text",children:[a.jsx("span",{className:`h-2 w-2 rounded-full shrink-0 ring-1 ring-spur-surface-2 ${rJ[e.status]??"bg-spur-text-faint"}`,"data-status":e.status,"aria-hidden":"true"}),e.wbs]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[e.estimateHours!==void 0&&a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted flex items-center gap-0.5",title:`Estimated: ${e.estimateHours}h`,children:[a.jsx("span",{className:"text-spur-text-faint text-[9px]",children:"⏱"}),e.estimateHours,"h"]}),e.priority&&a.jsx(tt,{variant:nJ[e.priority]??"outline",size:"xs",className:"font-mono text-[10px] font-semibold",children:e.priority})]})]}),a.jsx("p",{className:"text-sm font-medium text-spur-text leading-snug line-clamp-2 group-hover:text-spur-accent transition-colors",children:e.name}),a.jsxs("div",{className:"flex gap-1.5 flex-wrap items-center pt-0.5",children:[p&&p.total>0&&a.jsxs("div",{className:"flex items-center gap-1.5 min-w-[3.5rem]","data-testid":"subtask-progress",title:"subtasks done/total",children:[a.jsx("div",{className:"h-1 flex-1 rounded-full bg-spur-border/60 overflow-hidden",children:a.jsx("div",{className:"h-full bg-spur-success",style:{width:`${Math.round(p.done/p.total*100)}%`}})}),a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted shrink-0",children:[p.done,"/",p.total]})]}),e.type&&e.type!=="task"&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-border text-spur-text-muted",children:e.type}),e.template&&e.template!=="feature-impl"&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-accent/40 text-spur-accent bg-spur-accent/5 font-medium",children:e.template}),e.featureId&&a.jsx(tt,{variant:"outline",size:"xs",className:"text-[10px] font-mono border-spur-border text-spur-text-muted",children:e.featureId}),e.dependencyCount!==void 0&&e.dependencyCount>0&&a.jsxs("span",{className:"text-[10px] font-mono text-spur-text-muted flex items-center gap-0.5",title:`${e.dependencyCount} dependenc${e.dependencyCount===1?"y":"ies"}`,children:[a.jsx("span",{className:"text-spur-text-faint text-[9px]",children:"⛓"}),e.dependencyCount]}),e.updatedAt&&a.jsx("span",{className:`text-xs font-mono ml-auto ${f?"text-spur-text-faint":"text-spur-text-muted"}`,title:e.updatedAt,children:sJ(e.updatedAt,l)})]})]})})})}function aJ({status:e,label:t,tasks:n,onCardClick:r,sortDir:s,onSortToggle:i}){const{setNodeRef:o,isOver:l}=$Q({id:e,data:{status:e}});return a.jsxs("section",{ref:o,"aria-label":`${t} column`,className:`flex flex-col flex-1 min-w-[16rem] rounded-xl border transition-colors duration-200 overflow-hidden ${l?"bg-spur-surface/40 border-spur-accent shadow-lg ring-1 ring-spur-accent/30":"bg-transparent border-spur-border"}`,children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5 border-b border-spur-border shrink-0 bg-spur-surface",children:[a.jsxs("span",{className:"text-xs font-semibold text-spur-text uppercase tracking-wide",children:[ef(e)," ",t]}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx(tt,{variant:"ghost",size:"sm",className:"font-mono text-spur-text-muted bg-spur-surface-2 border border-spur-border/80 px-2 py-0.5",children:n.length}),i&&a.jsx(Ie,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 flex items-center justify-center text-spur-text-muted hover:text-spur-text hover:bg-spur-surface-2 rounded-md transition-colors",onClick:i,"aria-label":`Sort ${t} by WBS`,title:`Sort ${t}: ${s==="asc"?"WBS ↓":s==="desc"?"WBS ↑":"none"}`,children:s==="asc"?"↓":s==="desc"?"↑":"⇅"})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-2 min-h-[4rem]",children:[n.map(c=>a.jsx(WA,{task:c,onClick:r},c.wbs)),n.length===0&&a.jsx("div",{className:"flex items-center justify-center h-20 text-xs text-spur-text-muted italic border border-dashed border-spur-border/60 rounded-lg my-1 bg-spur-surface/30",children:"No tasks"})]})]})}const iJ=h.lazy(()=>Ak(()=>import("./TaskDetail.c48Pnba6.js"),__vite__mapDeps([2,3,1,4,5]))),oJ=Pn,qA="docs/tasks",AS="spur:detail-width",lJ=new Set(["blocked","cancelled","deprecated"]);function cJ(e,t){return t?e.filter(n=>!(t.status!==void 0&&!t.status.split(",").includes(n.status)||t.featureId&&!n.featureId?.toLowerCase().includes(t.featureId.toLowerCase())||t.parentWbs&&n.parentWbs!==t.parentWbs)):e}function VA(e){const{onSelectTask:t,filters:n,folder:r,hiddenColumns:s,onConnectionChange:i,onSyncChange:o}=e,[l,c]=h.useState({}),[u,d]=h.useState(qA),[p,f]=h.useState(null),[m,b]=h.useState(()=>{const V=typeof window<"u"?Math.min(1728,window.innerWidth*.8):1728;if(typeof window>"u")return V;try{const te=Number.parseFloat(window.localStorage.getItem(AS)??"");if(Number.isFinite(te)&&te>0)return Math.min(te,window.innerWidth*.8)}catch{}return V}),x=r??u,y=s??lJ,E=h.useCallback(()=>xt.task.list({folder:x}),[x]),{tasks:A,loading:w,error:N,connected:_,lastSyncAt:k,setTasks:S,store:v}=Ux(E),[O,C]=h.useState(null);h.useEffect(()=>{i?.(_)},[_,i]),h.useEffect(()=>{o?.(k)},[k,o]),h.useEffect(()=>{typeof xt.task.folders=="function"&&xt.task.folders({}).then(V=>{const{data:te,activeFolder:L}=V,ye=L??te?.[0]?.path;ye!==void 0&&d(ye)}).catch(()=>{})},[]),h.useEffect(()=>{document.documentElement.style.setProperty("--detail-w",`${m}px`)},[m]),h.useEffect(()=>{if(!p)return;const V=te=>{te.key==="Escape"&&f(null)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[p]);const M=Ji();h.useEffect(()=>{const V=M.pathname.split("/"),te=V.indexOf("tasks"),L=te>=0?V[te+1]:void 0;L&&/^\d{4}$/.test(L)&&f(L)},[M.pathname]);const B=hS(o0,{activationConstraint:{distance:5}}),R=hS(a0),z=MX(B,R),W=cJ(A,n),F=V=>{c(te=>{const L={...te};return te[V]==="asc"?L[V]="desc":te[V]==="desc"?delete L[V]:L[V]="asc",L})},J=V=>{const te=W.filter(ye=>ye.status===V),L=l[V]??"desc";return[...te].sort((ye,xe)=>{const P=ye.wbs.localeCompare(xe.wbs);return L==="asc"?P:-P})},K=V=>A.find(te=>te.wbs===V),X=V=>{C(String(V.active.id))},I=V=>{C(null);const{active:te,over:L}=V;if(!L)return;const ye=String(te.id),xe=String(L.id),P=K(ye);if(!P||P.status===xe)return;const oe=[...A];S(re=>re.map(H=>H.wbs===ye?{...H,status:xe}:H)),xt.task.transition({wbs:ye,toStatus:xe}).catch(re=>{S(oe);const H=re instanceof Error?re.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:H}}))})};return w?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(ln,{size:"lg",className:"text-spur-accent"})}):N?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsxs("div",{className:"text-center text-spur-text-muted",children:[a.jsx("p",{className:"text-lg font-semibold",children:"Failed to load tasks"}),a.jsx("p",{className:"text-sm",children:N.message})]})}):a.jsx(Mk.Provider,{value:v,children:a.jsxs(OQ,{sensors:z,onDragStart:X,onDragEnd:I,children:[a.jsxs("div",{className:"flex flex-col h-full",children:[a.jsx("div",{className:"flex gap-3 overflow-x-auto h-full p-4",children:oJ.filter(V=>!y.has(V)).map(V=>a.jsx(aJ,{status:V,label:V,tasks:J(V),onCardClick:te=>{f(te),t(te)},sortDir:l[V],onSortToggle:()=>F(V)},V))}),p&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button","aria-label":"Close task detail",className:"fixed inset-0 z-50 bg-black/40 border-0 p-0 cursor-default",onClick:()=>f(null)}),a.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Task detail",className:"fixed top-0 right-0 h-full z-50 bg-spur-surface border-l border-spur-border shadow-2xl flex",style:{width:"var(--detail-w)",minWidth:"36rem",maxWidth:"80vw"},children:[a.jsx(ka,{targetVar:"--detail-w",onResizeEnd:V=>{const te=Math.max(576,Math.min(V,window.innerWidth*.8));b(te);try{window.localStorage.setItem(AS,String(te))}catch{}},direction:"horizontal",invert:!0}),a.jsx("div",{className:"flex flex-col flex-1 overflow-hidden",children:a.jsx("div",{className:"flex-1 overflow-y-auto","data-testid":"detail-body",children:(()=>{const V=A.find(te=>te.wbs===p);return V?a.jsx(h.Suspense,{fallback:a.jsx("div",{className:"flex items-center justify-center h-32 text-spur-text-muted text-sm",children:"Loading detail..."}),children:a.jsx(iJ,{task:V,onClose:()=>f(null),onTransition:(te,L)=>{S(ye=>ye.map(xe=>xe.wbs===te?{...xe,status:L}:xe)),xt.task.transition({wbs:te,toStatus:L}).catch(ye=>{const xe=ye instanceof Error?ye.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:xe}}))})}})}):null})()})})]})]})]}),a.jsx(JQ,{dropAnimation:null,children:O?(()=>{const V=K(O);return V?a.jsx("div",{className:"opacity-90",children:a.jsx(WA,{task:V,onClick:()=>{}})}):null})():null})]})})}const Md=[{id:"kanban",label:"Kanban",component:VA}];function YA(){const[e,t]=Ca(),n=Ji(),r=mc(),s=h.useMemo(()=>{const c=n.pathname.split("/"),u=c.indexOf("tasks"),d=u>=0?c[u+1]:void 0;return d&&/^\d{4}$/.test(d)?d:e.get("selected")},[n.pathname,e]),i=h.useMemo(()=>{const c={},u=e.get("status"),d=e.get("feature"),p=e.get("parent"),f=e.get("assignee"),m=e.get("folder");return u!==null&&(c.status=u),d&&(c.featureId=d),p&&(c.parentWbs=p),f&&(c.assignee=f),m&&(c.folder=m),c},[e]);return{selected:s,filters:i,selectTask:c=>{const u=new URLSearchParams(e);u.delete("selected");const d=u.toString(),p=c?`/board/tasks/${c}`:"/board/tasks";r(`${p}${d?`?${d}`:""}`,{replace:!0})},setFilter:(c,u)=>{t(d=>{const p=new URLSearchParams(d);return c==="feature"&&p.delete("parent"),c==="parent"&&p.delete("feature"),u!==null?p.set(c,u):p.delete(c),p},{replace:!0})}}}function uJ(e){const t=e.trim();return/^\d{4}$/.test(t)?{kind:"navigate",wbs:t}:t.includes(".")?{kind:"filter",key:"parent",value:t}:{kind:"filter",key:"feature",value:t}}function dJ(){const{selectTask:e,setFilter:t,filters:n}=YA(),[r,s]=h.useState(qA),[i,o]=h.useState([]),[l,c]=h.useState("kanban"),[u,d]=h.useState(!1),[p,f]=h.useState(""),[m,b]=h.useState(!1),[x,y]=h.useState(void 0),E=n.folder??r,A=new Set(n.status===void 0?Pn.filter(S=>S!=="blocked"&&S!=="cancelled"&&S!=="deprecated"):n.status.split(",").filter(S=>Pn.some(v=>v===S))),w=new Set(Pn.filter(S=>!A.has(S)));h.useEffect(()=>{f(n.featureId??n.parentWbs??"")},[n.featureId,n.parentWbs]),h.useEffect(()=>{typeof xt.task.folders=="function"&&xt.task.folders({}).then(S=>{const{data:v,activeFolder:O}=S,C=O??v?.[0]?.path;v&&o(v),C!==void 0&&s(C)}).catch(()=>{})},[]);const N=S=>{const v=new Set(A);v.has(S)?v.delete(S):v.add(S),t("status",Pn.filter(O=>v.has(O)).join(","))},_=S=>{S.preventDefault();const v=uJ(p);if(v.kind==="navigate"){e(v.wbs),f("");return}t(v.key,v.value||null)},k=(Md.find(S=>S.id===l)??Md[0]).component;return a.jsxs("div",{className:"task-kanban flex flex-col h-full",children:[a.jsx("header",{className:"mx-auto w-full max-w-[1600px] shrink-0 px-4 pt-3",children:a.jsxs("div",{className:"flex flex-nowrap items-center justify-between gap-4 border-b border-spur-border pb-3",children:[a.jsxs("div",{className:"flex shrink-0 items-center gap-3",children:[a.jsx(Rr,{id:"tasks",size:"lg",className:"h-7 w-7 text-spur-accent","aria-hidden":"true"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2.5",children:[a.jsx("h1",{className:"text-xl font-bold tracking-tight text-spur-text",children:"Tasks"}),a.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-spur-border bg-spur-surface-2 px-2.5 py-0.5 text-xs text-spur-text-muted font-mono",role:"status","data-testid":"tasks-live-chip",children:[a.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${m?"bg-spur-success":"bg-spur-error"}`,"aria-hidden":"true"}),"last sync ",x?new Date(x).toLocaleString():"—"]})]}),a.jsx("p",{className:"text-xs text-spur-text-muted mt-0.5",children:"Task corpus, kanban lanes, and phase filters"})]})]}),a.jsxs("div",{className:"flex min-w-0 flex-nowrap items-center gap-2.5 overflow-x-auto",children:[a.jsx(qr,{variant:"ghost",size:"xs",className:"text-xs shrink-0 w-44 bg-spur-surface-2 border border-spur-border rounded-lg text-spur-text",value:E,onChange:S=>t("folder",S.target.value),"aria-label":"Task phase folder",children:i.map(S=>a.jsx("option",{value:S.path,children:S.label?`${S.label} (${S.path})`:S.path},S.path))}),a.jsx("div",{className:"flex shrink-0 items-center gap-1 bg-spur-surface-2 border border-spur-border px-2 py-1 rounded-xl",children:Pn.map(S=>a.jsxs("label",{htmlFor:`tasks-status-${S}`,className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md hover:bg-spur-surface-3 transition-colors cursor-pointer",children:[a.jsx(Sx,{id:`tasks-status-${S}`,size:"xs",checked:!w.has(S),onChange:()=>N(S)}),a.jsxs("span",{className:"text-[11px] font-medium text-spur-text-muted select-none",children:[ef(S)," ",S]})]},S))}),a.jsx("form",{onSubmit:_,className:"flex shrink-0 items-center",children:a.jsx(Vn,{"aria-label":"Filter by WBS or feature",type:"text",placeholder:"WBS or feature",variant:"bordered",size:"xs",className:"w-36 bg-spur-surface-2 border-spur-border text-spur-text",value:p,onChange:S=>f(S.target.value)})}),a.jsx(Ie,{variant:"primary",size:"sm",className:"shrink-0 font-medium",onClick:()=>d(!0),children:"+ New Task"}),a.jsx("div",{className:"flex shrink-0 items-center gap-1 bg-spur-surface-2 border border-spur-border p-1 rounded-xl",children:Md.map(S=>a.jsx("button",{type:"button",className:`px-3 py-1.5 text-xs font-semibold rounded-lg transition-all ${l===S.id?"bg-primary text-primary-content font-bold shadow-sm":"text-spur-text-muted hover:text-spur-text hover:bg-spur-surface-3"}`,onClick:()=>c(S.id),children:S.label},S.id))})]})]})}),a.jsx(Lk,{folder:E}),a.jsx("div",{"data-kanban-board":!0,className:"flex-1 overflow-hidden",children:a.jsx(k,{onSelectTask:e,filters:n,folder:E,hiddenColumns:w,onConnectionChange:b,onSyncChange:y})}),a.jsx(Ok,{open:u,onClose:()=>d(!1),onCreated:()=>{},folder:E})]})}function pJ(e,t){xt.task.transition({wbs:e,toStatus:t}).catch(n=>{const r=n instanceof Error?n.message:"Transition failed";typeof window<"u"&&window.dispatchEvent(new CustomEvent("api-error",{detail:{message:r}}))})}function fJ(){const{filters:e,selectTask:t}=YA();return a.jsx("div",{className:"task-kanban flex flex-col h-full",children:a.jsx("div",{"data-kanban-board":!0,className:"flex-1 overflow-hidden",children:a.jsx(VA,{onSelectTask:t,filters:e})})})}const mJ={id:"tasks",name:"Tasks",icon:"📋",route:"tasks",component:dJ,sidebarLabel:"Tasks",description:"Task kanban, lifecycle status, and per-task detail",order:40},hJ=Object.freeze(Object.defineProperty({__proto__:null,TaskKanbanView:fJ,module:mJ,transition:pJ},Symbol.toStringTag,{value:"Module"}));function KA(e){return e===null||typeof e!="object"?null:"module"in e&&CS(e.module)?e.module:"default"in e&&CS(e.default)?e.default:null}function CS(e){return e===null||typeof e!="object"?!1:"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string"&&"icon"in e&&typeof e.icon=="string"&&"route"in e&&typeof e.route=="string"&&"component"in e&&typeof e.component=="function"}function ZA(e,t){const n=typeof e.order=="number",r=typeof t.order=="number";return n&&r?e.order-t.order:n?-1:r?1:0}function gJ(e){const t=[],n=e("./*/index.{ts,tsx}",{eager:!0});for(const r of Object.values(n)){const s=KA(r);s&&t.push(s)}return t.sort((r,s)=>r.id.localeCompare(s.id)),t.sort(ZA),t}function bJ(){try{return gJ(()=>Object.assign({"./designs/index.tsx":Mq,"./features/index.tsx":cV,"./history/index.tsx":HV,"./observability/index.tsx":RK,"./plans/index.tsx":UK,"./projects/index.tsx":GZ,"./search/index.tsx":XZ,"./settings/index.tsx":wX,"./task-kanban/index.tsx":hJ}))}catch(s){if(typeof require!="function")throw s}const e=require("node:fs"),t=require("node:path"),n=require("node:url"),r=typeof __dirname<"u"?__dirname:t.dirname(n.fileURLToPath(import.meta.url));return xJ(r,{readdirSync:(s,i)=>e.readdirSync(s,i),tryRequire:s=>require(s)})}function xJ(e,t){const n=require("node:path"),r=[];let s=[];try{s=t.readdirSync(e,{withFileTypes:!0})}catch{return r}const i=s.filter(o=>o.isDirectory()).map(o=>o.name).sort((o,l)=>o.localeCompare(l));for(const o of i)for(const l of["tsx","ts"]){const c=n.join(e,o,`index.${l}`);try{const u=t.tryRequire(c),d=KA(u);if(d){r.push(d);break}}catch{}}return r.sort(ZA),r}function XA(e,t){const n=new Set(t?.disabled??[]),r=e.slice(),s=new Set(n),i=t?.defaultModuleId;function o(){return r.filter(l=>!s.has(l.id))}return yJ(r),{get modules(){return o()},getModule(l){return o().find(c=>c.id===l)},get defaultModule(){const l=o();if(i){const c=l.find(u=>u.id===i);if(c)return c}return l[0]},disableModule(l){s.add(l)},enableModule(l){s.delete(l)},getEnabledModules(){return o().map(l=>l.id)}}}function yJ(e){const t=new Map,n=new Map;for(const r of e){const s=t.get(r.id);if(s!==void 0)throw new Error(`Duplicate module id "${r.id}" discovered in two sources: ${s} and ${hl(r)}`);t.set(r.id,hl(r));const i=n.get(r.route);if(i!==void 0)throw new Error(`Duplicate module route "${r.route}" discovered in two sources: ${i} and ${hl(r)}`);n.set(r.route,hl(r))}}function hl(e){return e.id}const c0=XA(bJ(),{disabled:Lj,defaultModuleId:jj}),Qi=c0;c0.modules;c0.defaultModule;const QA=h.createContext({registry:Qi,hostDiagnostics:[]});function EJ({value:e,children:t}){return a.jsx(QA.Provider,{value:e,children:t})}function JA(){return h.useContext(QA)}const Up="spur-board-layout-v3",_S="spur-board-layout-v2",IS="spur-board-layout",ir={version:3,sidebarWidth:240,rightPanelWidth:320,sidebarCollapsed:!0,rightPanelCollapsed:!0};function SJ(){try{const e=localStorage.getItem(Up);if(e){const s=JSON.parse(e);return{version:3,sidebarWidth:typeof s.sidebarWidth=="number"?s.sidebarWidth:ir.sidebarWidth,rightPanelWidth:typeof s.rightPanelWidth=="number"?s.rightPanelWidth:ir.rightPanelWidth,sidebarCollapsed:typeof s.sidebarCollapsed=="boolean"?s.sidebarCollapsed:ir.sidebarCollapsed,rightPanelCollapsed:typeof s.rightPanelCollapsed=="boolean"?s.rightPanelCollapsed:ir.rightPanelCollapsed}}const t=localStorage.getItem(_S),n=localStorage.getItem(IS),r=t||n;if(r){const s=JSON.parse(r),i={version:3,sidebarWidth:typeof s.sidebarWidth=="number"?s.sidebarWidth:ir.sidebarWidth,rightPanelWidth:typeof s.rightPanelWidth=="number"?s.rightPanelWidth:ir.rightPanelWidth,sidebarCollapsed:ir.sidebarCollapsed,rightPanelCollapsed:typeof s.rightPanelCollapsed=="boolean"?s.rightPanelCollapsed:ir.rightPanelCollapsed};try{localStorage.setItem(Up,JSON.stringify(i)),localStorage.removeItem(_S),localStorage.removeItem(IS)}catch{}return i}return{...ir}}catch{return{...ir}}}function wJ(e){try{localStorage.setItem(Up,JSON.stringify({...e,version:3}))}catch{}}const eC="spur.board.projects.draft.v1";function la(e){return{path:e,text:"",revision:0}}function vJ(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;const t=e;if(typeof t.path!="string"||typeof t.text!="string"||typeof t.revision!="number"||!Number.isFinite(t.revision))return null;const n={path:t.path,text:t.text,revision:t.revision};return t.pending!==void 0&&(n.pending=t.pending),n}function NJ(e){try{const t=globalThis.localStorage?.getItem(eC);if(t==null)return la(e);const n=vJ(JSON.parse(t));return n===null||n.path!==e?(Rl(la(e)),la(e)):n}catch{return la(e)}}function Rl(e){try{globalThis.localStorage?.setItem(eC,JSON.stringify(e))}catch{}}const TJ={draft:la(""),setText:()=>{},persistPending:()=>{},clearSubmitted:()=>{}},tC=h.createContext(TJ);function kJ(){return h.useContext(tC)}function AJ({children:e}){const n=Ms().path,[r,s]=h.useState(()=>la(""));h.useEffect(()=>{n!==null&&s(NJ(n))},[n]);const i=h.useMemo(()=>({draft:r,setText:o=>s(l=>{if(l.path!==n)return l;const c={...l,text:o,revision:l.revision+1};return Rl(c),c}),persistPending:o=>s(l=>{if(l.path!==r.path||l.revision!==r.revision)return l;const c={...l,pending:{requestKey:o,revision:l.revision}};return Rl(c),c}),clearSubmitted:(o,l)=>s(c=>{if(c.path!==l||c.revision!==o)return c;const u={path:c.path,text:"",revision:c.revision+1};return Rl(u),u})}),[r,n]);return a.jsx(tC.Provider,{value:i,children:e})}function CJ(){const[e,t]=h.useState([]);return h.useEffect(()=>{if(typeof window>"u")return;const n=r=>{const i=r.detail?.message||"An error occurred",o=`${Date.now()}-${Math.random().toString(36).slice(2,7)}`;t(l=>[...l,{id:o,message:i}]),setTimeout(()=>{t(l=>l.filter(c=>c.id!==o))},5e3)};return window.addEventListener("api-error",n),()=>{window.removeEventListener("api-error",n)}},[]),e.length===0?null:a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-md w-full px-4 pointer-events-none",children:e.map(n=>a.jsxs("div",{className:"pointer-events-auto flex items-center justify-between gap-3 p-3 bg-red-950/90 border border-red-500/40 text-red-200 text-sm rounded-md shadow-lg backdrop-blur",role:"alert",children:[a.jsx("span",{className:"flex-1 break-words",children:n.message}),a.jsx("button",{type:"button",className:"text-red-400 hover:text-red-100 text-base font-bold leading-none px-1",onClick:()=>t(r=>r.filter(s=>s.id!==n.id)),"aria-label":"Close error toast",children:"×"})]},n.id))})}const _J="Enter",IJ=229;function RJ(e){return e.key===_J&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==IJ}const DJ=[{name:"/review",description:"Inspect staged git diff, verify test coverage & lint",category:"git",argumentHint:"[target] [--cached]",tags:["builtin","git","review"]},{name:"/commit",description:"Draft conventional commit message from staged hunks",category:"git",argumentHint:"[--all] [-m <message>]",tags:["builtin","git","commit"]},{name:"/compact",description:"Purge execution trace and condense context window",category:"sys",argumentHint:"[focus]",tags:["builtin","sys","compact"]},{name:"/revert",description:"Undo last agent file changes or restore git stash",category:"git",argumentHint:"[stash-id | file]",tags:["builtin","git","revert"]},{name:"/resume",description:"Resume paused background agent run",category:"dev",argumentHint:"[run-id]",tags:["builtin","dev","resume"]},{name:"/terminal",description:"Run isolated bash execution in sandbox mirror",category:"sys",argumentHint:"[command]",tags:["builtin","sys","terminal"]},{name:"/cost",description:"Inspect token breakdown and USD expenditure",category:"sys",tags:["builtin","sys","cost"]},{name:"/sp:dev-plan",description:"Plan a feature from description (intake → AC → tasks)",category:"harness",argumentHint:'"<description>" [--feature <id>]',tags:["sp","dev","plan"]},{name:"/sp:dev-run",description:"Drive one task end-to-end through verification pipeline",category:"harness",argumentHint:"<wbs> [--mode <full|implement>]",tags:["sp","dev","run"]},{name:"/sp:dev-verify",description:"Verify a task against requirements and acceptance criteria",category:"harness",argumentHint:"<wbs> [--bdd] [--auto]",tags:["sp","dev","verify"]}],OJ={sending:{icon:"…",label:"Sending",meaning:"the request is being stored",action:"wait for the mailbox",tone:"warn"},queued:{icon:"○",label:"Queued",meaning:"the orchestrator has not claimed it yet",action:"wait for the orchestrator",tone:"warn"},working:{icon:"◐",label:"In progress",meaning:"a member claimed it",action:"wait for the run to finish",tone:"warn"},delivered:{icon:"✓",label:"Delivered",meaning:"the member consumed the request",action:"read the reply in the Inbox tab",tone:"ok"},failed:{icon:"✕",label:"Failed",meaning:"delivery did not start or the run errored",action:"resend, or read the error in the Inbox tab",tone:"err"},unresolved:{icon:"!",label:"Unresolved",meaning:"the run left no verified outcome",action:"check the Inbox tab for the hold reason",tone:"warn"},absent:{icon:"·",label:"No receipt",meaning:"the request did not reach an inbox",action:"check the project binding and resend",tone:"warn"}};function LJ(e,t){return t?"sending":e===null?"absent":e.status==="failed"||["failed","errored","cancelled"].includes(e.runStatus??"")?"failed":e.runStatus==="running"?"working":e.reason!==null&&e.reason!==""?e.status==="delivered"?"unresolved":"working":e.status==="delivered"?"delivered":e.status==="claimed"?"working":"queued"}const jJ=[{id:"auto",label:"auto",desc:"Orchestrator auto-dispatch (default)"},{id:"coder",label:"coder",desc:"Implementation & refactoring specialist"},{id:"reviewer",label:"reviewer",desc:"Verification, lint & SECUA reviewer"},{id:"planner",label:"planner",desc:"Architecture & decomposition specialist"}];function MJ(e){if(!e)return!0;const{state:t,instanceId:n}=e.orchestrator;return t==="missing"||t==="unresolvable"||!n}function FJ({activeModule:e}){const[t,n]=h.useState(!1),[r,s]=h.useState(!1),[i,o]=h.useState(null),[l,c]=h.useState("auto"),[u,d]=h.useState(!1),[p,f]=h.useState(!1),[m,b]=h.useState(0),[x,y]=h.useState("all"),[E,A]=h.useState(DJ),w=h.useMemo(()=>{const Z=new Map;for(const Re of E){if(Array.isArray(Re.tags)){for(const rt of Re.tags)if(rt&&typeof rt=="string"){const ae=rt.trim().toLowerCase();Z.set(ae,(Z.get(ae)??0)+1)}}if(Re.category){const rt=Re.category.trim().toLowerCase();Z.set(rt,(Z.get(rt)??0)+1)}}const ke=["sp","cc","kk","wt","git","dev","sys","harness","builtin"];return["all",...Array.from(Z.keys()).sort((Re,rt)=>{const ae=ke.indexOf(Re),pe=ke.indexOf(rt);if(ae!==-1&&pe!==-1)return ae-pe;if(ae!==-1)return-1;if(pe!==-1)return 1;const De=(Z.get(rt)??0)-(Z.get(Re)??0);return De!==0?De:Re.localeCompare(rt)})]},[E]),N=Ms(),_=h.useRef({path:N.path,generation:0,inFlight:!1});_.current.path!==N.path&&(_.current={path:N.path,generation:_.current.generation+1,inFlight:!1}),h.useEffect(()=>()=>{_.current.generation+=1},[]);const{draft:k,setText:S,persistPending:v,clearSubmitted:O}=kJ(),C=N.fleet?.orchestrator?.instanceId,M=MJ(N.fleet),[B,R]=h.useState(null),[z,W]=h.useState(!1),[F,J]=h.useState(null),[K,X]=h.useState(0);h.useEffect(()=>{N.path,s(!1),o(null),R(null),W(!1),J(null)},[N.path]),h.useEffect(()=>{if(i===null)return;let Z=!1;return(async()=>{try{const ke=await xt.inbox.requests({messageId:i});if(Z)return;const Fe=ke.find(Re=>Re.messageId===i);Fe!==void 0&&R({status:Fe.status,reason:Fe.reason,runStatus:Fe.runStatus}),W(!1)}catch{Z||W(!0)}})(),()=>{Z=!0}},[i,K]),h.useEffect(()=>{if(typeof EventSource>"u")return;const Z=new EventSource(`${it()}/events/planning`);return Z.onmessage=ke=>{try{const Fe=JSON.parse(ke.data).eventName;typeof Fe=="string"&&Fe.startsWith("message.")&&X(Re=>Re+1)}catch{}},()=>Z.close()},[]);const I=LJ(B,r),V=OJ[I],te=r||i!==null,L=te?`${V.label} — Next: ${V.action}`:"";h.useEffect(()=>{if(i===null||N.path===null||B===null||["completed","exited","failed","errored","cancelled"].includes(B.runStatus??"")||B.status!=="queued"&&B.status!=="claimed"&&B.runStatus!=="running")return;const Z=setInterval(()=>X(ke=>ke+1),2e3);return()=>clearInterval(Z)},[i,N.path,B]);const ye=h.useRef(null);h.useEffect(()=>{let Z=!0;return(async()=>{try{const ke=await Xe(new Request(`${it()}/agent/commands`));if(ke.ok){const Fe=await ke.json();Z&&Array.isArray(Fe.commands)&&Fe.commands.length>0&&A(Fe.commands)}}catch{}})(),()=>{Z=!1}},[]),h.useEffect(()=>{if(!u)return;const Z=ke=>{ye.current&&!ye.current.contains(ke.target)&&d(!1)};return document.addEventListener("click",Z),()=>document.removeEventListener("click",Z)},[u]),h.useEffect(()=>{k.text.startsWith("/")&&f(!1)},[k.text]);const xe=k.text.trim().toLowerCase(),P=xe.startsWith("/")&&!p,oe=P?E.filter(Z=>{const ke=x==="all"||Array.isArray(Z.tags)&&Z.tags.map(rt=>rt.toLowerCase()).includes(x)||Z.category.toLowerCase()===x,Fe=xe.startsWith("/")?xe.slice(1):xe,Re=Z.name.toLowerCase().startsWith(xe)||Z.name.toLowerCase().includes(Fe)||!!Z.argumentHint?.toLowerCase().includes(Fe)||Z.description.toLowerCase().includes(Fe)||Array.isArray(Z.tags)&&Z.tags.some(rt=>rt.toLowerCase().includes(Fe));return ke&&Re}):[],re=P&&oe.length>0,H=Z=>{S(`${Z} `),f(!0),document.querySelector('[data-testid="agent-bar-input"]')?.focus()},Ce=Z=>{const ke=k.text,Fe=ke.length>0&&!ke.endsWith(" ")?`${ke} ${Z}`:`${ke}${Z}`;S(Fe),document.querySelector('[data-testid="agent-bar-input"]')?.focus()},me=()=>l==="auto"?C:N.fleet?.members?.find(ke=>ke.role===l||ke.instanceId===l)?.instanceId??C,he=async()=>{const Z=N.path,ke=me();if(Z===null||k.path!==Z||ke===void 0||_.current.inFlight)return;const Fe=++_.current.generation,Re=()=>_.current.path===Z&&_.current.generation===Fe,rt=k.text;if(rt.trim().length===0)return;_.current.inFlight=!0;const ae={text:rt,revision:k.revision},pe=k.pending!==void 0&&typeof k.pending.requestKey=="string"&&k.pending.requestKey.length>0&&k.pending.revision===k.revision?k.pending:void 0,De=pe!==void 0?pe.requestKey:crypto.randomUUID();v(De),J(null),s(!0),o(null),R(null),f(!0);try{const Me=await xt.inbox.send({...ke!==null?{to:ke}:{},body:ae.text,requestKey:De,...Z!==null?{projectPath:Z}:{}});if(!Re())return;R({status:Me.message.status,reason:null}),o(Me.message.id),O(ae.revision,Z)}catch(Me){Re()&&J(Me instanceof Error?Me.message:"the message was not sent")}finally{Re()&&(_.current.inFlight=!1,s(!1))}};if(!t)return a.jsxs(a.Fragment,{children:[a.jsx("div",{role:"status","aria-live":"polite",className:"sr-only","data-agent-bar-live":!0,children:L}),a.jsx(Ie,{variant:"ghost",className:"fixed bottom-6 right-6 z-30 h-12 w-12 rounded-full backdrop-blur-md bg-base-100/80 border border-spur-border shadow-2xl text-xl text-spur-text",onClick:()=>n(!0),"aria-label":"Open agent prompt bar","aria-expanded":!1,"data-testid":"agent-bar-dock",children:"✨"})]});const Ne=N.fleet?.members&&N.fleet.members.length>0?[{id:"auto",label:"auto",desc:"Orchestrator auto-dispatch (default)"},...N.fleet.members.map(Z=>({id:Z.instanceId,label:Z.role||Z.instanceId,desc:`${Z.executor}${Z.model?` · ${Z.model}`:""}`}))]:jJ,Ge=k.text.trim().length===0||l==="auto"&&M;return a.jsxs("div",{className:"fixed bottom-4 left-1/2 -translate-x-1/2 z-30 w-[calc(100vw-2rem)] max-w-[84rem] backdrop-blur-md bg-base-100/80 border border-spur-border shadow-2xl rounded-2xl p-2.5 flex flex-col gap-2 transition-colors","data-testid":"agent-bar",children:[a.jsx("div",{role:"status","aria-live":"polite",className:"sr-only","data-agent-bar-live":!0,children:L}),re&&a.jsxs("div",{"data-testid":"agent-bar-palette",className:"w-full rounded-2xl bg-base-100/95 border border-spur-border shadow-2xl overflow-hidden flex flex-col backdrop-blur-2xl mb-1 transition-colors",children:[a.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2 border-b border-spur-border bg-base-200/50 text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{className:"font-mono text-spur-accent font-semibold text-[13px]",children:"/"}),a.jsx("span",{className:"font-mono text-[12px] font-medium text-spur-text",children:"Commands"}),a.jsxs("span",{className:"text-[11px] font-mono text-spur-text-muted",children:[oe.length," available"]})]}),a.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar max-w-[65%] py-0.5",role:"tablist",children:w.slice(0,10).map(Z=>a.jsx("button",{type:"button",role:"tab","aria-selected":x===Z,onClick:()=>y(Z),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors shrink-0 cursor-pointer ${x===Z?"bg-spur-accent/15 text-spur-accent border border-spur-accent/30 font-medium":"text-spur-text-muted hover:text-spur-text hover:bg-base-200"}`,children:Z==="all"?"All":Z},Z))})]}),a.jsx("div",{className:"flex flex-col py-1.5 px-2 max-h-[260px] overflow-y-auto",role:"listbox",children:oe.map((Z,ke)=>{const Fe=ke===m;return a.jsxs("button",{type:"button",role:"option","aria-selected":Fe,onClick:()=>H(Z.name),title:Z.description,className:`flex items-center w-full text-left px-3 py-2 rounded-lg cursor-pointer transition-colors ${Fe?"bg-spur-surface text-spur-accent font-medium":"hover:bg-base-200 text-spur-text-muted hover:text-spur-text"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 font-mono text-[13px] min-w-0 truncate flex-1",children:[a.jsx("span",{className:Fe?"font-semibold text-spur-accent":"font-medium text-spur-text",children:Z.name}),Z.argumentHint?a.jsx("span",{className:`font-mono text-xs truncate ${Fe?"text-spur-text/80":"text-spur-text-muted"}`,children:Z.argumentHint}):a.jsx("span",{className:`font-sans text-xs italic truncate ${Fe?"text-spur-text/60":"text-spur-text-muted/60"}`,children:Z.description})]}),a.jsx("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:(Z.tags&&Z.tags.length>0?Z.tags.slice(0,2):[Z.category]).map(Re=>a.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-base-200 text-spur-text-muted border border-spur-border",children:Re},Re))})]},Z.name)})}),a.jsxs("div",{"data-testid":"agent-bar-hints",className:"flex items-center justify-between px-4 py-2 border-t border-spur-border bg-base-200/70 font-mono text-[11px] text-spur-text-muted select-none",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"↑↓"}),a.jsx("span",{children:"navigate"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"Tab"}),a.jsx("span",{children:"complete"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"↵"}),a.jsx("span",{children:"execute"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-base-100 border border-spur-border text-spur-text font-semibold text-[10px] shadow-sm",children:"ESC"}),a.jsx("span",{children:"dismiss"})]})]}),a.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px]",children:[a.jsxs("button",{type:"button",onClick:()=>Ce("@"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Reference files",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"@"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"files"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("button",{type:"button",onClick:()=>Ce("#"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Reference tasks and context",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"#"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"context"})]}),a.jsx("span",{className:"text-spur-border",children:"•"}),a.jsxs("button",{type:"button",onClick:()=>Ce("!"),className:"text-spur-text-muted hover:text-spur-accent cursor-pointer transition-colors flex items-center gap-0.5 group",title:"Execute shell directly",children:[a.jsx("span",{className:"font-semibold text-spur-accent group-hover:underline",children:"!"}),a.jsx("span",{className:"group-hover:text-spur-text",children:"bash"})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-spur-text-muted font-mono text-sm select-none font-bold pl-1",children:">"}),a.jsxs("div",{className:"relative shrink-0",ref:ye,children:[a.jsxs("button",{type:"button",onClick:()=>d(Z=>!Z),className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-spur-surface hover:bg-base-200 border border-spur-border text-xs font-mono text-spur-accent transition-colors cursor-pointer group",title:"Target Agent Receiver (default: auto dispatch to orchestrator)","data-testid":"agent-bar-role-tag",children:[a.jsx("span",{className:"text-spur-text-muted font-sans text-[11px]",children:"to:"}),a.jsx("span",{className:"font-semibold",children:Ne.find(Z=>Z.id===l)?.label??l}),a.jsx("span",{className:"text-spur-text-muted text-[10px] group-hover:text-spur-text transition-colors",children:"▾"})]}),u&&a.jsxs("div",{"data-testid":"agent-bar-role-menu",className:"absolute bottom-full left-0 mb-2 w-56 rounded-xl bg-base-100 border border-spur-border shadow-2xl p-1.5 z-50 flex flex-col gap-1 text-spur-text",children:[a.jsx("div",{className:"px-2.5 py-1 text-[10px] font-mono text-spur-text-muted uppercase tracking-wider",children:"Dispatch Target"}),Ne.map(Z=>a.jsxs("button",{type:"button",onClick:()=>{c(Z.id),d(!1)},className:`flex items-center justify-between px-2.5 py-1.5 rounded-lg text-left text-xs font-mono transition-colors ${l===Z.id?"bg-spur-accent/15 text-spur-accent font-semibold":"hover:bg-base-200 text-spur-text-muted hover:text-spur-text"}`,children:[a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{className:"font-medium text-spur-text",children:Z.label}),a.jsx("span",{className:"text-[10px] text-spur-text-muted",children:Z.desc})]}),l===Z.id&&a.jsx("span",{className:"text-[12px]",children:"✓"})]},Z.id))]})]}),a.jsx(aG,{variant:"ghost",rows:1,value:k.text,onChange:Z=>S(Z.target.value),onKeyDown:Z=>{if(re&&oe.length>0){if(Z.key==="ArrowDown"){Z.preventDefault(),b(ke=>(ke+1)%oe.length);return}if(Z.key==="ArrowUp"){Z.preventDefault(),b(ke=>(ke-1+oe.length)%oe.length);return}if(Z.key==="Tab"){Z.preventDefault();const ke=oe[m];ke&&H(ke.name);return}if(Z.key==="Escape"){Z.preventDefault(),f(!0);return}}RJ(Z)&&(Ge||(Z.preventDefault(),he()))},placeholder:"Ask a coding agent to refine or implement, or type / for commands…","aria-label":"Agent prompt",className:"flex-1 min-h-9 resize-none bg-transparent text-spur-text placeholder:text-spur-text-muted border-0 focus:ring-0 focus:outline-none","data-testid":"agent-bar-input"}),a.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>n(!1),"aria-label":"Collapse agent prompt bar","aria-expanded":!0,className:"text-spur-text-muted hover:text-spur-text h-8 w-8 p-0 shrink-0",children:"▾"})]}),l==="auto"&&M&&a.jsx("div",{"data-testid":"agent-bar-orchestrator-missing",role:"status",className:"px-1 text-xs text-spur-text-muted",children:"Orchestrator unavailable — no orchestrator instance is bound to this project, so requests cannot be delivered yet."}),F!==null&&a.jsxs("div",{role:"alert",className:"rounded-lg px-2.5 py-1 text-xs bg-spur-error/10 text-spur-error",children:["Not sent: ",F]}),te&&a.jsxs("div",{"data-receipt-state":I,role:"status",className:`rounded-lg px-2.5 py-1 text-xs ${V.tone==="err"?"bg-spur-error/10 text-spur-error":V.tone==="warn"?"bg-spur-warning/10 text-spur-warning":"bg-spur-success/10 text-spur-success"}`,children:[a.jsx("span",{"aria-hidden":"true",className:"mr-1",children:V.icon}),a.jsx("span",{className:"font-medium",children:V.label}),a.jsxs("span",{className:"text-spur-text-muted",children:[" ","— ",V.meaning," Next: ",V.action,"."]}),z&&a.jsx("span",{className:"text-spur-text-muted",children:" (results feed unavailable)"})]})]})}function PJ(e){return u0(e.host)?`${e.name} (${e.host?.trim()})`:e.name}function u0(e){const t=e?.trim().toLowerCase();return t!==void 0&&t!==""&&t!=="localhost"&&t!=="127.0.0.1"&&t!=="::1"}function BJ(e){return e.port<=0||!e.running&&!u0(e.host)?null:`http://${e.host?.trim()||"localhost"}:${e.port}/board`}async function $J(e,t){return Promise.all(e.map(async n=>!n.running&&n.port>0&&u0(n.host)?{...n,running:await t(`http://${n.host?.trim()}:${n.port}/api/health`)}:n))}async function UJ(e){try{return await Xe(new Request(e,{mode:"no-cors"}),1500),!0}catch{return!1}}function zJ({name:e}){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;const n=Math.abs(t)%8,s=["text-emerald-400 bg-emerald-500/10 border-emerald-500/30","text-sky-400 bg-sky-500/10 border-sky-500/30","text-indigo-400 bg-indigo-500/10 border-indigo-500/30","text-amber-400 bg-amber-500/10 border-amber-500/30","text-rose-400 bg-rose-500/10 border-rose-500/30","text-purple-400 bg-purple-500/10 border-purple-500/30","text-teal-400 bg-teal-500/10 border-teal-500/30","text-cyan-400 bg-cyan-500/10 border-cyan-500/30"][n],i=()=>{switch(n){case 0:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M8 1.5l5.5 3.2v6.6L8 14.5l-5.5-3.2V4.7L8 1.5z"}),a.jsx("path",{d:"M8 1.5v13M2.5 4.7l5.5 3.3 5.5-3.3"})]});case 1:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"2",y:"2.5",width:"12",height:"11",rx:"2"}),a.jsx("path",{d:"M5 6l2.5 2L5 10M8.5 10H11"})]});case 2:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"4.5",cy:"4",r:"1.5"}),a.jsx("circle",{cx:"4.5",cy:"12",r:"1.5"}),a.jsx("circle",{cx:"11.5",cy:"7",r:"1.5"}),a.jsx("path",{d:"M4.5 5.5v5M4.5 7.5a4 4 0 004-1"})]});case 3:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M8 2l5.5 3-5.5 3-5.5-3L8 2z"}),a.jsx("path",{d:"M2.5 8l5.5 3 5.5-3M2.5 11l5.5 3 5.5-3"})]});case 4:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5"}),a.jsx("path",{d:"M6 1.5v2M10 1.5v2M6 12.5v2M10 12.5v2M1.5 6h2M1.5 10h2M12.5 6h2M12.5 10h2"})]});case 5:return a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5M9 3l-2 10"})});case 6:return a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M2 4a1.5 1.5 0 011.5-1.5h2.8a1.5 1.5 0 011.06.44l1.14 1.14c.28.28.66.42 1.06.42H12.5A1.5 1.5 0 0114 6v6a1.5 1.5 0 01-1.5 1.5h-9A1.5 1.5 0 012 12V4z"})});default:return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6"}),a.jsx("path",{d:"M2 8h12M8 2a9 9 0 010 12 9 9 0 010-12z"})]})}};return a.jsx("span",{"data-testid":"project-avatar-icon",className:`flex h-7 w-7 items-center justify-center rounded border ${s}`,children:i()})}function RS({currentName:e,collapsed:t=!1}){const[n,r]=h.useState(!1),[s,i]=h.useState([]),[o,l]=h.useState(null),[c,u]=h.useState(null),d=h.useRef(null);h.useEffect(()=>{if(!n)return;const m=new AbortController;return Xe(new Request(`${it()}/projects`,{signal:m.signal})).then(async b=>{if(!b.ok)return;const y=(await b.json()).projects??[];i(y);const E=await $J(y,UJ);m.signal.aborted||i(E)}).catch(()=>{u("Failed to load projects")}),()=>m.abort()},[n]),h.useEffect(()=>{if(!n)return;const m=x=>{x.key==="Escape"&&r(!1)},b=x=>{d.current&&!d.current.contains(x.target)&&r(!1)};return document.addEventListener("keydown",m),document.addEventListener("mousedown",b),()=>{document.removeEventListener("keydown",m),document.removeEventListener("mousedown",b)}},[n]);const p=async m=>{if(m.current){r(!1);return}const b=BJ(m);if(b){window.location.href=b;return}l(m.name);try{const x=await Xe(new Request(`${it()}/projects/start`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:m.name,path:m.path})}));if(!x.ok)throw new Error("Failed to start project");const y=await x.json();window.location.href=y.url||`http://${m.host??"localhost"}:${y.port}/board`}catch(x){u(x instanceof Error?x.message:"Start failed"),l(null)}},f=a.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-haspopup":"listbox","aria-expanded":n,"aria-label":`Switch project: ${e}`,title:e,"data-testid":"project-switcher-trigger",className:"group relative flex h-8 w-8 items-center justify-center rounded-md hover:bg-spur-accent/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-spur-accent",children:[a.jsx("span",{className:`items-center justify-center ${n?"hidden":"flex group-hover:hidden"}`,children:a.jsx(zJ,{name:e})}),a.jsx("span",{"data-testid":"project-switcher-chevron",className:`h-7 w-7 items-center justify-center rounded text-spur-text ${n?"flex":"hidden group-hover:flex"}`,children:a.jsx("svg",{className:`h-4 w-4 shrink-0 transition-transform ${n?"rotate-180 text-spur-accent":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M4 6l4 4 4-4"})})})]});return a.jsxs("div",{className:`relative ${t?"flex items-center justify-center":"min-w-0 flex-1"}`,ref:d,children:[t?n?f:a.jsx(ur,{position:"right",tip:`Switch project: ${e}`,className:"block",children:f}):a.jsxs("button",{type:"button",onClick:()=>r(m=>!m),"aria-haspopup":"listbox","aria-expanded":n,"aria-label":"Switch project",title:e,"data-testid":"project-switcher-trigger",className:"flex w-full items-center justify-between gap-1 rounded-md px-1.5 py-1 text-left text-sm font-semibold text-spur-text hover:bg-spur-border/30 focus-visible:outline focus-visible:outline-2 focus-visible:outline-spur-accent",children:[a.jsx("span",{className:"font-semibold truncate",children:e}),a.jsx("svg",{className:`h-4 w-4 shrink-0 transition-transform ${n?"rotate-180":""}`,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M4 6l4 4 4-4"})})]}),n&&a.jsxs("div",{role:"listbox","aria-label":"Registered projects","data-testid":"project-switcher-menu",className:`absolute z-50 w-64 rounded-md border border-spur-border bg-spur-surface p-1 shadow-lg ${t?"left-full top-0 ml-2":"left-0 top-full mt-1"}`,children:[a.jsx("div",{className:"px-2 py-1 text-xs font-medium text-spur-text-muted border-b border-spur-border/50 mb-1",children:"Projects"}),s.length===0?a.jsx("div",{className:"px-2 py-1.5 text-xs text-spur-text-muted",children:c||"No projects registered"}):s.map(m=>a.jsxs("button",{type:"button",role:"option","aria-selected":m.current,disabled:o===m.name,onClick:()=>p(m),"data-testid":`project-item-${m.name}`,className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-xs text-left transition-colors ${m.current?"bg-spur-accent/15 text-spur-accent font-medium":"text-spur-text hover:bg-spur-border/30"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[a.jsx("span",{className:`h-2 w-2 rounded-full shrink-0 ${m.running?"bg-green-500":"bg-gray-400"}`,title:m.running?`Running on port ${m.port}`:"Stopped"}),a.jsx("span",{className:"truncate",children:PJ(m)})]}),o===m.name?a.jsx("span",{className:"text-[10px] text-spur-accent animate-pulse",children:"Starting..."}):m.current?a.jsx("span",{className:"text-[10px] font-semibold text-spur-accent",children:"current"}):m.running?a.jsxs("span",{className:"text-[10px] text-spur-text-muted",children:[":",m.port]}):a.jsx("span",{className:"text-[10px] text-spur-text-muted",children:"stopped"})]},m.path))]})]})}const nC="spur-theme";function HJ(){try{const e=localStorage.getItem(nC);if(e==="light"||e==="dark")return e}catch{}return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function GJ(e){document.documentElement.setAttribute("data-theme",e);try{localStorage.setItem(nC,e)}catch{}}function WJ(e){const t=e==="dark"?"light":"dark";return GJ(t),t}function DS(){const[e,t]=h.useState(HJ);h.useEffect(()=>{const s=window.matchMedia("(prefers-color-scheme: dark)"),i=o=>{if(!(()=>{try{return localStorage.getItem("spur-theme")}catch{return null}})()){const c=o.matches?"dark":"light";t(c),document.documentElement.setAttribute("data-theme",c)}};return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[]);const n=h.useCallback(()=>t(WJ),[]),r=e==="dark"?"Switch to light mode":"Switch to dark mode";return a.jsx(Ie,{variant:"ghost",size:"sm",onClick:n,className:"flex h-8 w-8 items-center justify-center rounded-md text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent","aria-label":r,title:r,children:e==="dark"?a.jsx(AG,{className:"h-4 w-4 shrink-0",strokeWidth:1.8,"aria-hidden":"true"}):a.jsx(vG,{className:"h-4 w-4 shrink-0",strokeWidth:1.8,"aria-hidden":"true"})})}const qJ="Modules";function VJ(){const[e,t]=h.useState(qJ);return h.useEffect(()=>{const n=new AbortController;return Xe(new Request(`${it()}/project`,{signal:n.signal})).then(async r=>{if(!r.ok)return;const s=await r.json();s.name&&t(s.name)}).catch(()=>{}),()=>n.abort()},[]),e}function YJ({direction:e}){const t=e==="expand";return a.jsxs("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),a.jsx("line",{x1:"6",y1:"2",x2:"6",y2:"14"}),t?a.jsx("path",{d:"M9 6l2 2-2 2"}):a.jsx("path",{d:"M11 6l-2 2 2 2"})]})}function OS({collapsed:e,onToggle:t}){const n=e?"Expand sidebar":"Collapse sidebar";return a.jsx("button",{type:"button",onClick:t,"aria-label":n,title:n,"data-testid":e?"sidebar-expand":"sidebar-collapse",className:"flex h-8 w-8 items-center justify-center rounded-md text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent",children:a.jsx(YJ,{direction:e?"expand":"collapse"})})}function LS({collapsed:e}){const t=a.jsx(MS,{to:"/board/settings","aria-label":"Open settings",title:"Open settings","data-testid":"sidebar-settings",className:({isActive:n})=>`flex h-8 w-8 items-center justify-center rounded-md transition-colors ${n?"bg-spur-accent/20 text-spur-accent":"text-spur-text-muted hover:bg-spur-accent/20 hover:text-spur-accent"} focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-spur-accent`,children:a.jsx("svg",{className:"h-4 w-4 shrink-0",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:a.jsx("path",{fillRule:"evenodd",d:"M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",clipRule:"evenodd"})})});return e?a.jsx(ur,{position:"right",tip:"Settings",className:"block",children:t}):t}function KJ({collapsed:e,onToggle:t,onMobileClose:n}){const r=VJ(),{registry:s}=JA();return a.jsxs("aside",{className:`flex flex-col bg-spur-surface border-r border-spur-border ${e?"overflow-visible":"overflow-hidden"}`,children:[e?a.jsx("div",{className:"flex items-center justify-center border-b border-spur-border shrink-0 py-2",children:a.jsx(RS,{currentName:r,collapsed:!0})}):a.jsxs("div",{className:"flex items-center justify-between gap-1 p-3 border-b border-spur-border shrink-0",children:[a.jsx(RS,{currentName:r}),n&&a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text-muted md:hidden",onClick:n,"aria-label":"Close navigation",children:"✕"})]}),a.jsx("nav",{className:`flex-1 ${e?"overflow-visible":"overflow-y-auto"}`,children:s.modules.filter(i=>i.id!=="settings").map(i=>{const o=i.sidebarLabel??i.name,l=a.jsxs(MS,{to:`/board/${i.route}`,className:({isActive:c})=>`flex items-center gap-2 px-3 py-2 text-sm transition-colors ${c?"bg-spur-accent/20 text-spur-accent":"text-spur-text-muted hover:text-spur-text hover:bg-spur-border/30"} ${e?"justify-center py-3":""}`,children:[a.jsx("span",{className:"flex h-5 w-5 items-center justify-center shrink-0",children:a.jsx(Rr,{id:i.id,icon:i.icon})}),!e&&a.jsx("span",{children:o})]},i.id);if(e){const c=i.description?`${o}
320
320
  ${i.description}`:o;return a.jsx(ur,{position:"right",tip:c,className:"[&:before]:whitespace-pre-line block",children:l},i.id)}return l})}),a.jsx("div",{"data-testid":"sidebar-footer",className:`border-t border-spur-border shrink-0 ${e?"py-2 flex flex-col items-center gap-2":"p-3 flex items-center justify-between gap-2"}`,children:e?a.jsxs(a.Fragment,{children:[a.jsx(DS,{}),a.jsx(LS,{collapsed:!0}),a.jsx(OS,{collapsed:!0,onToggle:t})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(DS,{}),a.jsx(LS,{})]}),a.jsx(OS,{collapsed:!1,onToggle:t})]})})]})}function ZJ({children:e,mobileHeader:t,framed:n=!1}){return a.jsxs("main",{className:"flex flex-col h-full overflow-hidden bg-spur-bg",children:[t,a.jsx("div",{className:n?"flex flex-1 min-h-0 flex-col overflow-hidden":"flex-1 min-h-0 overflow-auto",children:e})]})}function XJ({collapsed:e,onToggle:t,onMobileClose:n,children:r,actions:s}){return a.jsxs("aside",{className:"flex flex-col bg-spur-surface border-l border-spur-border overflow-hidden",children:[n&&a.jsx("div",{className:"hidden max-md:flex items-center justify-center py-2 shrink-0",children:a.jsx("div",{className:"w-10 h-1 rounded-full bg-spur-border"})}),a.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-spur-border shrink-0",children:[!e&&a.jsx("span",{className:"text-sm font-semibold text-spur-text",children:r?"Context":""}),a.jsx("div",{className:"flex items-center gap-1",children:s}),a.jsxs("div",{className:"flex items-center gap-1",children:[n&&a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text-muted md:hidden",onClick:n,"aria-label":"Close panel",children:"✕"}),a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text-muted hidden md:inline-flex",onClick:t,"aria-label":e?"Expand panel":"Collapse panel",children:e?"◀":"▶"})]})]}),!e&&a.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:r})]})}const QJ=h.createContext(void 0);function JJ(){const[e,t]=h.useState(()=>SJ()),[n,r]=h.useState(!1),[s,i]=h.useState(!1),o=Ji(),{registry:l,hostDiagnostics:c}=JA(),u=(()=>{const _=o.pathname.split("/"),k=_.indexOf("board"),S=k>=0?_[k+1]:void 0;if(!S)return;const v=S==="modules"&&_[k+2]?`modules/${_[k+2]}`:S;return l.modules.find(O=>O.route===v)})();h.useLayoutEffect(()=>{const _=document.documentElement;_.style.setProperty("--sidebar-w",`${e.sidebarWidth}px`),_.style.setProperty("--rightpanel-w",`${e.rightPanelWidth}px`)},[e.sidebarWidth,e.rightPanelWidth]);const d=h.useCallback(_=>wJ(_),[]),p=h.useCallback(()=>{t(_=>{const k={..._,sidebarCollapsed:!_.sidebarCollapsed};return d(k),k})},[d]),f=h.useCallback(()=>{t(_=>{const k={..._,rightPanelCollapsed:!_.rightPanelCollapsed};return d(k),k})},[d]),m=h.useCallback(_=>t(k=>{const S={...k,sidebarWidth:_};return d(S),S}),[d]),b=h.useCallback(_=>t(k=>{const S={...k,rightPanelWidth:_};return d(S),S}),[d]),x=h.useCallback(()=>{r(!1),i(!1)},[]),y=h.useCallback(_=>{_.key==="Escape"&&x()},[x]),E=u?.rightPanelComponent,A=u?.contributionType==="iframe";h.useLayoutEffect(()=>{E&&e.rightPanelCollapsed&&t(_=>({..._,rightPanelCollapsed:!1}))},[E,e.rightPanelCollapsed]);const w=a.jsxs("div",{className:"mobile-bar",children:[a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text",onClick:()=>r(!0),"aria-label":"Open navigation",children:"☰"}),a.jsx("span",{className:"text-sm font-semibold text-spur-text",children:u?.name??"Spur"}),!A&&a.jsx(Ie,{variant:"ghost",size:"sm",className:"text-spur-text",onClick:()=>i(!0),"aria-label":"Open panel",children:"◧"})]}),N=n||s;return a.jsx(cZ,{children:a.jsxs(AJ,{children:[N&&a.jsx("div",{className:"fixed inset-0 z-40 bg-black/50 md:hidden",onClick:x,onKeyDown:y,"aria-hidden":"true"}),a.jsx("div",{className:"board-layout","data-sidebar-collapsed":String(e.sidebarCollapsed),"data-rightpanel-collapsed":String(e.rightPanelCollapsed),"data-mobile-sidebar-open":String(n),"data-mobile-panel-open":String(s),"data-framed-workspace":String(A),children:a.jsxs(QJ.Provider,{value:u,children:[a.jsx(KJ,{collapsed:e.sidebarCollapsed&&!n,onToggle:p,onMobileClose:x}),a.jsx(ka,{targetVar:"--sidebar-w",onResizeEnd:m}),a.jsxs(ZJ,{mobileHeader:w,framed:A,children:[a.jsx(Tj,{diagnostics:c}),a.jsx(bC,{})]}),!A&&a.jsxs(a.Fragment,{children:[a.jsx(ka,{targetVar:"--rightpanel-w",onResizeEnd:b}),a.jsx(XJ,{collapsed:e.rightPanelCollapsed,onToggle:f,onMobileClose:x,children:E?u&&u.contributionType==="react"?a.jsx(Xw,{moduleId:u.id,category:"panel",children:a.jsx(E,{})}):a.jsx(E,{}):null})]})]})}),!A&&a.jsx(FJ,{activeModule:u}),a.jsx(CJ,{})]})})}const eee=[{from:"workspace",to:"/board/projects"},{from:"teams",to:"/board/settings/agents"}];function zp(e){return e.contributionType==="react"||e.contributionType==="iframe"}function jS(e){const t=e.component;return zp(e)?a.jsx(Xw,{moduleId:e.id,children:a.jsx(t,{})}):a.jsx(t,{})}function tee(e){const t=e.defaultModule;return t&&!zp(t)?t:e.modules.find(n=>!zp(n))??t}function rC(e){const t=tee(e);return[{path:"/board",element:a.jsx(JJ,{}),children:[{index:!0,element:a.jsx(_o,{to:t?`/board/${t.route}`:"/board",replace:!0})},...eee.flatMap(n=>[{path:n.from,element:a.jsx(_o,{to:n.to,replace:!0})},{path:`${n.from}/*`,element:a.jsx(_o,{to:n.to,replace:!0})}]),...e.modules.flatMap(n=>[{path:n.route,element:jS(n)},{path:`${n.route}/*`,element:jS(n)}])]},{path:"/",element:a.jsx(_o,{to:t?`/board/${t.route}`:"/board",replace:!0})}]}rC(Qi);function nee(e=Qi){return xC(rC(e))}async function ree(e=()=>xt.board.modules()){const t=await e().catch(()=>null),n=await Oj(t,Qi.modules);try{return{registry:XA([...n.modules]),hostDiagnostics:n.hostDiagnostics}}catch(r){return{registry:Qi,hostDiagnostics:[...n.hostDiagnostics,{moduleId:"catalog",category:"catalog",message:r instanceof Error?r.message:String(r)}]}}}function hee(){const[e,t]=h.useState(null);return h.useEffect(()=>{let n=!0;return ree().then(r=>{n&&t({value:r,router:nee(r.registry)})}),()=>{n=!1}},[]),e?a.jsx(EJ,{value:e.value,children:a.jsx(yC,{router:e.router})}):null}export{Ie as B,Sx as C,ln as L,wa as M,qr as S,pee as T,Ak as _,xt as a,YY as b,fee as c,tt as d,Ck as e,mee as f,Pn as g,hee as h,ree as l,Ta as m,ef as t,Ux as u};