chorus-codes 0.8.43 → 0.8.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +3 -3
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/connect/page.js +1 -1
- package/.next/server/app/connect/page_client-reference-manifest.js +1 -1
- package/.next/server/app/demo/[scenario]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/new/page.js +1 -1
- package/.next/server/app/new/page_client-reference-manifest.js +1 -1
- package/.next/server/app/new.html +1 -1
- package/.next/server/app/new.rsc +3 -3
- package/.next/server/app/new.segments/_full.segment.rsc +3 -3
- package/.next/server/app/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/new.segments/_index.segment.rsc +2 -2
- package/.next/server/app/new.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/new.segments/new/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/new.segments/new.segment.rsc +1 -1
- package/.next/server/app/onboarding/page.js +2 -2
- package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/.next/server/app/onboarding.html +1 -1
- package/.next/server/app/onboarding.rsc +3 -3
- package/.next/server/app/onboarding.segments/_full.segment.rsc +3 -3
- package/.next/server/app/onboarding.segments/_head.segment.rsc +1 -1
- package/.next/server/app/onboarding.segments/_index.segment.rsc +2 -2
- package/.next/server/app/onboarding.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/onboarding.segments/onboarding.segment.rsc +1 -1
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/personas/page_client-reference-manifest.js +1 -1
- package/.next/server/app/personas.html +1 -1
- package/.next/server/app/personas.rsc +3 -3
- package/.next/server/app/personas.segments/_full.segment.rsc +3 -3
- package/.next/server/app/personas.segments/_head.segment.rsc +1 -1
- package/.next/server/app/personas.segments/_index.segment.rsc +2 -2
- package/.next/server/app/personas.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/personas.segments/personas/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/personas.segments/personas.segment.rsc +1 -1
- package/.next/server/app/runs/[runId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/permissions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +3 -3
- package/.next/server/app/settings.segments/_full.segment.rsc +3 -3
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +2 -2
- package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/app/templates/page.js +1 -1
- package/.next/server/app/templates/page_client-reference-manifest.js +1 -1
- package/.next/server/app/templates.html +1 -1
- package/.next/server/app/templates.rsc +3 -3
- package/.next/server/app/templates.segments/_full.segment.rsc +3 -3
- package/.next/server/app/templates.segments/_head.segment.rsc +1 -1
- package/.next/server/app/templates.segments/_index.segment.rsc +2 -2
- package/.next/server/app/templates.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/templates.segments/templates/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/templates.segments/templates.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/189.js +1 -1
- package/.next/server/chunks/325.js +1 -1
- package/.next/server/chunks/642.js +1 -1
- package/.next/server/chunks/681.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/245-f3d2948b0049e981.js +1 -0
- package/.next/static/chunks/{641-66f3ba81d2479b02.js → 641-8c9e921c7be99a9d.js} +1 -1
- package/.next/static/chunks/744-c2e8529e7a5b0221.js +1 -0
- package/.next/static/chunks/app/connect/page-14d8e3fa9505959f.js +1 -0
- package/.next/static/chunks/app/new/page-4452a15141b14ef3.js +1 -0
- package/.next/static/chunks/app/onboarding/page-cc53c4eeeb372cda.js +1 -0
- package/.next/static/chunks/app/page-de91de3476faae94.js +1 -0
- package/.next/static/chunks/app/templates/page-4984d1f588c30038.js +1 -0
- package/.next/static/css/{a2b7a8d35dba10d3.css → e17f6c0e70cdd1f3.css} +1 -1
- package/.next/trace +20 -20
- package/.next/trace-build +1 -1
- package/dist/cli/commands/doctor.js +1 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/init.js +1 -0
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/quickstart.js +1 -0
- package/dist/cli/commands/quickstart.js.map +1 -1
- package/dist/cli/commands/start.js +87 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/update.js +123 -1
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/daemon/agents/antigravity.js +87 -0
- package/dist/daemon/agents/antigravity.js.map +1 -0
- package/dist/daemon/agents/index.js +4 -1
- package/dist/daemon/agents/index.js.map +1 -1
- package/dist/daemon/agents/parsers/antigravity.js +119 -0
- package/dist/daemon/agents/parsers/antigravity.js.map +1 -0
- package/dist/daemon/agents/parsers/index.js +4 -1
- package/dist/daemon/agents/parsers/index.js.map +1 -1
- package/dist/daemon/error-detector.js +20 -2
- package/dist/daemon/error-detector.js.map +1 -1
- package/dist/lib/cli-detect.js +9 -0
- package/dist/lib/cli-detect.js.map +1 -1
- package/dist/lib/cli-health.js +1 -0
- package/dist/lib/cli-health.js.map +1 -1
- package/dist/lib/cli-paths.js +1 -0
- package/dist/lib/cli-paths.js.map +1 -1
- package/dist/lib/cli-precheck.js +9 -0
- package/dist/lib/cli-precheck.js.map +1 -1
- package/dist/lib/db/voices.js +1 -1
- package/dist/lib/db/voices.js.map +1 -1
- package/dist/lib/lineage-maps.js +31 -0
- package/dist/lib/lineage-maps.js.map +1 -1
- package/dist/lib/template-schema.js +2 -2
- package/dist/lib/template-schema.js.map +1 -1
- package/dist/lib/voices.js +6 -0
- package/dist/lib/voices.js.map +1 -1
- package/package.json +1 -1
- package/.next/static/chunks/245-686f2a9a3d4d5554.js +0 -1
- package/.next/static/chunks/744-a5a2f718e91700bd.js +0 -1
- package/.next/static/chunks/app/connect/page-e216744a2daa061b.js +0 -1
- package/.next/static/chunks/app/new/page-d65ea7687a1b37ad.js +0 -1
- package/.next/static/chunks/app/onboarding/page-9f2b388be3008bdc.js +0 -1
- package/.next/static/chunks/app/page-75f1f750029680bd.js +0 -1
- package/.next/static/chunks/app/templates/page-0cfb5ce79f29fcd5.js +0 -1
- /package/.next/static/{4hHxZHWTDLJU0ZZPkLRz- → K3ZP-A6lDlsvS8qZe3cKK}/_buildManifest.js +0 -0
- /package/.next/static/{4hHxZHWTDLJU0ZZPkLRz- → K3ZP-A6lDlsvS8qZe3cKK}/_ssgManifest.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{var a={};a.id=814,a.ids=[814],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4602:(a,b,c)=>{"use strict";c.d(b,{E:()=>i});var d=c(66722);c(31131);var e=c(82786),f=c(29399),g=c(16276);let h=(0,e.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function i({className:a,variant:b="default",asChild:c=!1,...e}){let j=c?f.bL:"span";return(0,d.jsx)(j,{"data-slot":"badge","data-variant":b,className:(0,g.cn)(h({variant:b}),a),...e})}},7400:(a,b,c)=>{Promise.resolve().then(c.bind(c,45036))},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14463:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},15213:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]])},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19771:a=>{"use strict";a.exports=require("process")},24961:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},26516:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31006:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("sliders-vertical",[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]])},31650:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},33873:a=>{"use strict";a.exports=require("path")},33911:(a,b,c)=>{"use strict";c.d(b,{N:()=>f});var d=c(66722),e=c(5616);function f({filename:a,charCount:b,footer:c,maxHeightClassName:g="max-h-[70vh]",children:h}){return(0,d.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card",children:[(0,d.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/60 px-4 py-2.5",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:a})]}),"number"==typeof b&&(0,d.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:[b.toLocaleString()," chars"]})]}),(0,d.jsx)("pre",{className:`${g} min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words bg-background px-5 py-4 font-mono text-[12px] leading-relaxed text-foreground/90`,children:h}),c&&(0,d.jsx)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border bg-card/60 px-4 py-2.5 text-[11px] text-muted-foreground",children:c})]})}},36500:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>aS});var d=c(66722),e=c(31131),f=c(26516),g=c(66635),h=c(78770),i=c(80282),j=c(50133),k=c(4602),l=c(91887),m=c(33911),n=c(62435),o=c(15213),p=c(90057),q=c(68598),r=c(65850),s=c(55932),t=c(64519),u=c(66152),v=c(11022),w=c(94755);let x=Object.freeze({valid:!0,issues:[]});var y=c(16276),z=c(52449);let A=(0,z.A)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);var B=c(89629),C=c(91458),D=c(31006);let E={claude:"anthropic",codex:"openai",gemini:"google",opencode:"opencode",kimi:"moonshot",openrouter:"openrouter",local:"local",grok:"grok"},F={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",openrouter:"openrouter",xai:"opencode",local:"local",grok:"grok"},G={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build"},H={id:"",name:"",description:"",author:"you",category:"review",phases:[{id:"review",name:"Review",description:"Three independent critiques.",kind:"review",gate:"ask-user",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:3,crossLineage:!0,candidates:["codex","gemini","opencode"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!1}],threshold:"unanimous",onThresholdMet:"ask-user",maxRounds:3,yoloDefault:!1,fallbackDoer:[],fallbackReviewer:[]},I=[{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}],J=[{id:"unanimous",label:"Unanimous",hint:"All lineages must agree. Strictest — best for high-stakes reviews."},{id:"majority",label:"Majority",hint:"≥ ⅔ of lineages agree. Good default for code review."},{id:"any",label:"Any",hint:"≥1 lineage agrees. Useful for brainstorming where divergence is fine."}],K=[{id:"auto-finalize",label:"Auto-finalize"},{id:"ask-user",label:"Ask me"}],L=[{id:1,label:"Basics",icon:A},{id:2,label:"Phases",icon:B.A},{id:3,label:"Fallback",icon:C.A},{id:4,label:"Policy",icon:D.A}],M=["claude","codex","gemini","opencode","kimi","openrouter","local","grok"];function N(a){return a.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"untitled"}function O(a){var b;return v.stringify({id:(b=a).id||N(b.name),name:b.name||"Untitled template",description:b.description||"Describe what this template is for.",author:b.author||"chorus",agreementThreshold:void 0!==b.customThreshold?b.customThreshold:function(a){switch(a){case"unanimous":return 1;case"majority":return .66;case"any":return .34}}(b.threshold),onThresholdMet:b.onThresholdMetRaw??("auto-finalize"===b.onThresholdMet?"merge":"ask"),maxRounds:b.maxRounds,yoloDefault:b.yoloDefault,phases:b.phases.map(a=>{let b="review_only"===a.kind,c=a.reviewer.candidates.length>0?{require:a.reviewer.require,crossLineage:a.reviewer.crossLineage,candidates:a.reviewer.candidates.flatMap(b=>{let c=(a.reviewer.candidateModels?.[b]??[]).map(a=>a.trim()).filter(a=>a.length>0),d=a.reviewer.candidatePersonas?.[b],e=E[b]??"anthropic";if(0===c.length){let a=G[b]??"claude-opus-4-7",c=d?.[""];return[{lineage:e,models:[a],...c?{persona:c}:{}}]}return c.map(a=>{let b=d?.[a];return{lineage:e,models:[a],...b?{persona:b}:{}}})})}:void 0;return b?{id:a.id,kind:a.kind,title:a.name,description:a.description,reviewer:c,inputs:{include:a.inputs.include,exclude:a.inputs.exclude},artifact:{label:a.artifact?.label??"Artifact to review",hint:a.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact?.maxBytes??1048576}}:{id:a.id,kind:a.kind,title:a.name,description:a.description,doer:{lineage:E[a.doer.lineage]??"anthropic",models:a.doer.models.length>0?a.doer.models:[G[a.doer.lineage]??"claude-opus-4-7"],...a.doer.persona?{persona:a.doer.persona}:{}},reviewer:c,inputs:{include:a.inputs.include,exclude:a.inputs.exclude},iterate:{maxRounds:a.iterate.max,onDisagreement:"loopback"===a.iterate.onMax?"continue":"fail"===a.iterate.onMax?"accept-doer":"escalate",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}}}),...b.fallbackDoer.length>0||b.fallbackReviewer.length>0?{fallback:{...b.fallbackDoer.length>0?{doer:b.fallbackDoer.map(a=>({lineage:E[a.lineage]??"anthropic",models:[a.model],...a.persona?{persona:a.persona}:{}}))}:{},...b.fallbackReviewer.length>0?{reviewer:b.fallbackReviewer.map(a=>({lineage:E[a.lineage]??"anthropic",models:[a.model],...a.persona?{persona:a.persona}:{}}))}:{}}}:{}},{lineWidth:0})}let P=(0,z.A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Q=(0,z.A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);c(29843),c(11897);var R=c(31650),S=c(46728),T=c(41970),U=c(5616),V=c(83720),W=c(75619),X=c(14463),Y=c(6506);let Z={review:R.A,review_only:R.A,plan:S.A,spec:o.A,tests:T.A,implement:U.A,verify:V.A,pr:W.A,divergence:C.A,recon:X.A},$=[{id:"plan",label:"Plan"},{id:"spec",label:"Spec / API"},{id:"tests",label:"Tests"},{id:"implement",label:"Implement"},{id:"verify",label:"Verify"},{id:"pr",label:"Open PR"},{id:"review",label:"Review"},{id:"review_only",label:"Review only (artifact)"},{id:"divergence",label:"Divergence"},{id:"recon",label:"Recon"}],_=["claude","codex","gemini","opencode","kimi","openrouter","local","grok"].map(a=>({id:a,label:Y.m_[a],dot:Y.r2[a].dot})),aa=Y.x0;function ab(){let[a,b]=(0,e.useState)({byLineage:{},connectedLineages:new Set,loaded:!1});return a}let ac=(0,z.A)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ad=(0,z.A)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var ae=c(24961),af=c(72069),ag=c(95099);function ah({children:a,onClick:b,disabled:c,title:e,className:f}){return(0,d.jsx)("button",{type:"button",disabled:c,onClick:a=>{a.stopPropagation(),b()},title:e,className:(0,y.cn)("grid h-6 w-6 place-items-center rounded text-muted-foreground transition hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",f),children:a})}function ai({label:a,children:b}){return(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-1.5 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),b]})}function aj({on:a,tone:b,onClick:c,children:e}){return(0,d.jsx)("button",{type:"button",onClick:c,className:(0,y.cn)("rounded-md border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition",{emerald:a?"border-emerald-500/40 bg-emerald-500/15 text-emerald-200":"border-border bg-card/40 text-muted-foreground hover:border-emerald-500/30",rose:a?"border-rose-500/40 bg-rose-500/15 text-rose-200":"border-border bg-card/40 text-muted-foreground hover:border-rose-500/30"}[b]),children:e})}function ak({value:a,personas:b,onChange:c,inline:e,ariaLabel:f}){let g="__none__",h=b.some(b=>b.id===a);return(0,d.jsxs)("select",{value:a??g,onChange:a=>{let b=a.target.value;c(b===g?void 0:b)},className:(0,y.cn)("h-7 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none",e?"w-32 shrink-0":"w-full"),"aria-label":f??"Persona",children:[(0,d.jsx)("option",{value:g,children:"(no persona)"}),b.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id)),a&&!h&&(0,d.jsxs)("option",{value:a,children:[a," (missing)"]})]})}function al({lineage:a,value:b,options:c,onChange:f,defaultModel:g}){let h="__custom__",i=!b||c.includes(b),[j,k]=(0,e.useState)(!1);if(j)return(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:g?`default: ${g}`:`${a} model id`,className:"h-7 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none",autoFocus:!0}),(0,d.jsx)("button",{type:"button",onClick:()=>k(!1),className:"h-7 rounded-md border border-border bg-card/40 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"done"})]});if(0===c.length)return(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:g?`default: ${g}`:`${a} model id`,className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none"}),(0,d.jsxs)("p",{className:"text-[10px] text-amber-400/80",children:["No ",a," voices enabled. Configure in Connect to populate this dropdown."]})]});let l=i?c:[b,...c];return(0,d.jsxs)("select",{value:b,onChange:a=>{a.target.value===h?k(!0):f(a.target.value)},className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none",children:[!b&&(0,d.jsx)("option",{value:"",children:g?`default: ${g}`:"— pick a model —"}),l.map(a=>(0,d.jsxs)("option",{value:a,children:[a,c.includes(a)||b!==a?"":" (not enabled)"]},a)),(0,d.jsx)("option",{value:h,children:"+ custom (type a model id)…"})]})}function am(a){let b=[];for(let c of a.candidates){let d=a.candidateModels?.[c],e=a.candidatePersonas?.[c];if(d&&0!==d.length)for(let a of d)b.push({lineage:c,model:a,...e?.[a]?{persona:e[a]}:{}});else b.push({lineage:c,model:"",...e?.[""]?{persona:e[""]}:{}})}return b}function an({phase:a,connectedVoices:b,personas:c,onUpdate:e}){let f=am(a.reviewer),g=_.filter(a=>0===b.connectedLineages.size||b.connectedLineages.has(a.id));function h(b){e({reviewer:function(a,b){let c=[],d={},e={};for(let b of a)c.includes(b.lineage)||c.push(b.lineage),b.model&&(d[b.lineage]??=[]).push(b.model),b.persona&&((e[b.lineage]??={})[b.model]=b.persona);return{...b,candidates:c,candidateModels:d,...Object.keys(e).length>0?{candidatePersonas:e}:{candidatePersonas:void 0}}}(b,a.reviewer)})}function i(a,c){let d=f.map((b,d)=>d===a?{...b,...c}:b);if(c.lineage&&c.lineage!==f[a].lineage){let e=b.byLineage[c.lineage]??[];d[a].model=e[0]??aa[c.lineage]??""}h(d)}return(0,d.jsxs)("div",{className:"space-y-1.5",children:[0===f.length&&(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No reviewers yet. Click + add reviewer below."}),f.map((a,e)=>{let j=_.find(b=>b.id===a.lineage);return(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsxs)("select",{value:a.lineage,onChange:a=>i(e,{lineage:a.target.value}),className:"h-7 w-32 shrink-0 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none","aria-label":"Reviewer lineage",children:[g.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id)),!g.find(b=>b.id===a.lineage)&&(0,d.jsxs)("option",{value:a.lineage,children:[j?.label??a.lineage," (not connected)"]})]}),(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(al,{lineage:a.lineage,value:a.model,options:b.byLineage[a.lineage]??[],defaultModel:aa[a.lineage],onChange:a=>i(e,{model:a})})}),(0,d.jsx)(ak,{value:a.persona,personas:c,onChange:a=>i(e,{persona:a}),inline:!0,ariaLabel:"Reviewer persona"}),(0,d.jsx)("button",{type:"button",onClick:()=>{h(f.filter((a,b)=>b!==e))},"aria-label":"Remove reviewer",className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-border bg-card/40 text-muted-foreground hover:border-destructive/40 hover:text-destructive",children:(0,d.jsx)(p.A,{className:"h-3 w-3"})})]},e)}),(0,d.jsxs)("button",{type:"button",onClick:function(){let a=g[0]?.id??"claude",c=b.byLineage[a]??[],d=new Set(f.filter(b=>b.lineage===a).map(a=>a.model)),e=c.find(a=>!d.has(a))??aa[a]??"";h([...f,{lineage:a,model:e}])},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,d.jsx)(n.A,{className:"h-3 w-3"}),"Add another reviewer"]})]})}function ao({phase:a,onUpdate:b,connectedVoices:c,personas:e}){return(0,d.jsxs)(ai,{label:"Doer \xb7 the agent that writes this phase's output",children:[(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:_.filter(a=>0===c.connectedLineages.size||c.connectedLineages.has(a.id)).map(e=>(0,d.jsxs)("button",{type:"button",onClick:()=>{let a=(c.byLineage[e.id]??[])[0]??aa[e.id];b({doer:{lineage:e.id,models:a?[a]:[]}})},className:(0,y.cn)("flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition",a.doer.lineage===e.id?"border-primary/40 bg-primary/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",e.dot)}),(0,d.jsx)("span",{className:"text-xs",children:e.label}),a.doer.lineage===e.id&&(0,d.jsx)(af.A,{className:"ml-auto h-3 w-3 text-primary"})]},e.id))}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(al,{lineage:a.doer.lineage,value:a.doer.models[0]??"",options:c.byLineage[a.doer.lineage]??[],defaultModel:aa[a.doer.lineage],onChange:c=>b({doer:{...a.doer,models:c?[c]:[]}})})}),(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsx)("label",{className:"mb-1 block text-[10px] text-muted-foreground",children:"Persona (optional \xb7 prepends a worldview to the doer's prompt)"}),(0,d.jsx)(ak,{value:a.doer.persona,personas:e,onChange:c=>b({doer:c?{...a.doer,persona:c}:(()=>{let{persona:b,...c}=a.doer;return c})()}),ariaLabel:"Doer persona"})]})]})}function ap({phase:a,onUpdate:b}){let c={label:a.artifact?.label??"Artifact to review",hint:a.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact?.maxBytes??1048576};return(0,d.jsx)(ai,{label:"Artifact \xb7 what the user pastes when starting a chat",children:(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Label"}),(0,d.jsx)("input",{type:"text",value:c.label,onChange:a=>b({artifact:{...c,label:a.target.value}}),placeholder:"Artifact to review",className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Placeholder hint"}),(0,d.jsx)("textarea",{value:a.artifact?.hint??"",onChange:a=>b({artifact:{...c,hint:a.target.value}}),placeholder:"Paste a unified diff, a markdown draft, code, or any text blob.",rows:2,className:"mt-1 w-full resize-none rounded-md border border-border bg-background px-2.5 py-1.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max bytes (server-side cap)"}),(0,d.jsx)("input",{type:"number",min:1024,step:1024,value:c.maxBytes,onChange:a=>b({artifact:{...c,maxBytes:Math.max(1024,parseInt(a.target.value,10)||1048576)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 font-mono text-[11px] focus:border-primary/60 focus:outline-none"}),(0,d.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:"1 MiB = 1048576. Default if unset."})]})]})})}function aq({phase:a,onUpdate:b,connectedVoices:c,personas:e}){return(0,d.jsx)(ai,{label:"Reviewers \xb7 who gates this phase",children:(0,d.jsx)(an,{phase:a,connectedVoices:c,personas:e,onUpdate:b})})}function ar({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Approvals",children:(0,d.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,d.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["Require:",(0,d.jsx)("input",{type:"number",min:0,max:Math.max(1,am(a.reviewer).length),value:a.reviewer.require,onChange:c=>b({reviewer:{...a.reviewer,require:Math.max(0,parseInt(c.target.value,10)||0)}}),className:"h-6 w-12 rounded border border-border bg-background px-1.5 text-center font-mono text-[11px]"}),"approval",1===a.reviewer.require?"":"s"]}),"review_only"!==a.kind&&(0,d.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,d.jsx)("input",{type:"checkbox",checked:a.reviewer.crossLineage,onChange:c=>b({reviewer:{...a.reviewer,crossLineage:c.target.checked}}),className:"accent-primary"}),"Cross-lineage required"]})]})})}function as({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Reviewer execution \xb7 how multiple reviewers interact",children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b({execution:"parallel"}),className:(0,y.cn)("rounded-md border px-3 py-2.5 text-left transition","parallel"===a.execution?"border-emerald-500/40 bg-emerald-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Parallel independent",(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase text-emerald-300/80",children:"fast"})]}),(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"All reviewers see the same pack, work in isolation, vote. Catches single-reviewer mistakes via consensus. Risk: shared blind spots pass anyway."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b({execution:"sequential"}),className:(0,y.cn)("rounded-md border px-3 py-2.5 text-left transition","sequential"===a.execution?"border-amber-500/40 bg-amber-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Sequential hostile",(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase text-amber-300/80",children:"thorough"})]}),(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"Reviewers run in order. Each receives the already-hardened output and hunts what the prior reviewer missed. Slower; only works if the first reviewer's solution is sound."})]})]})})}function at({phase:a,onUpdate:b,priorPhases:c}){return(0,d.jsxs)(ai,{label:"Inputs \xb7 which prior phases this doer can read",children:[(0,d.jsx)("div",{className:"space-y-1.5",children:c.map(c=>{let e=a.inputs.include.includes(c),f=a.inputs.exclude.includes(c),g=f?"exclude":e?"include":"none";return(0,d.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-card/30 px-2.5 py-1.5",children:[(0,d.jsx)("code",{className:"font-mono text-[11px] text-foreground",children:c}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)(aj,{on:"include"===g,tone:"emerald",onClick:()=>b({inputs:{include:e?a.inputs.include.filter(a=>a!==c):[...a.inputs.include,c],exclude:a.inputs.exclude.filter(a=>a!==c)}}),children:"include"}),(0,d.jsx)(aj,{on:"exclude"===g,tone:"rose",onClick:()=>b({inputs:{include:a.inputs.include.filter(a=>a!==c),exclude:f?a.inputs.exclude.filter(a=>a!==c):[...a.inputs.exclude,c]}}),children:"exclude (blind)"})]})]},c)})}),(0,d.jsxs)("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] text-muted-foreground",children:[(0,d.jsx)(ag.A,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground/60"}),(0,d.jsxs)("span",{children:[(0,d.jsx)("span",{className:"font-mono text-rose-300",children:"exclude"}),"prevents this doer from seeing that phase's output. Used for info asymmetry — e.g. the implementer shouldn't see the tests."]})]})]})}function au({phase:a,onUpdate:b,priorPhases:c}){return(0,d.jsx)(ai,{label:"Iterate \xb7 what happens when reviewer rejects",children:(0,d.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max revise"}),(0,d.jsx)("input",{type:"number",min:1,max:10,value:a.iterate.max,onChange:c=>b({iterate:{...a.iterate,max:Math.max(1,parseInt(c.target.value,10)||1)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px]"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"On max"}),(0,d.jsxs)("select",{value:a.iterate.onMax,onChange:c=>b({iterate:{...a.iterate,onMax:c.target.value}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px]",children:[(0,d.jsx)("option",{value:"ask-user",children:"ask me"}),(0,d.jsx)("option",{value:"loopback",children:"loop back"}),(0,d.jsx)("option",{value:"fail",children:"fail"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Loop back to"}),(0,d.jsxs)("select",{disabled:"loopback"!==a.iterate.onMax,value:a.iterate.loopbackTo??"",onChange:c=>b({iterate:{...a.iterate,loopbackTo:c.target.value||void 0}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px] disabled:opacity-40",children:[(0,d.jsx)("option",{value:"",children:"—"}),c.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]})]})]})})}function av({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Gate \xb7 what happens when this phase finishes",children:(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b({gate:"auto"}),className:(0,y.cn)("rounded-md border px-2.5 py-1.5 text-left transition","auto"===a.gate?"border-emerald-500/40 bg-emerald-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Auto-proceed"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Continue to next phase without asking."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b({gate:"ask-user"}),className:(0,y.cn)("rounded-md border px-2.5 py-1.5 text-left transition","ask-user"===a.gate?"border-amber-500/40 bg-amber-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Checkpoint (ask me)"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Stop here, surface verdict, wait for click."})]})]})})}function aw({phase:a,index:b,total:c,allPhaseIds:f,connectedVoices:g,personas:i,onUpdate:j,onMoveUp:k,onMoveDown:l,onDelete:m}){let[n,o]=(0,e.useState)(0===b),p=Z[a.kind],q=f.slice(0,b);return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>o(a=>!a),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left",children:[(0,d.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:String(b+1).padStart(2,"0")}),(0,d.jsx)("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md bg-primary/15 text-primary",children:(0,d.jsx)(p,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.name||"Untitled phase"}),(0,d.jsx)("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:a.kind})]}),(0,d.jsx)(ax,{phase:a})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)(ah,{disabled:0===b,onClick:k,title:"Move up",children:(0,d.jsx)(ac,{className:"h-3 w-3"})}),(0,d.jsx)(ah,{disabled:b===c-1,onClick:l,title:"Move down",children:(0,d.jsx)(ad,{className:"h-3 w-3"})}),(0,d.jsx)(ah,{onClick:m,title:"Delete phase",className:"hover:text-rose-400",children:(0,d.jsx)(h.A,{className:"h-3 w-3"})}),(0,d.jsx)("span",{className:"ml-1 text-muted-foreground/60",children:n?(0,d.jsx)(ae.A,{className:"h-3.5 w-3.5"}):(0,d.jsx)(Q,{className:"h-3.5 w-3.5"})})]})]}),n&&(0,d.jsxs)("div",{className:"space-y-4 border-t border-border bg-background/40 px-3 py-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[1fr_140px] gap-2",children:[(0,d.jsx)(ai,{label:"Name",children:(0,d.jsx)("input",{type:"text",value:a.name,onChange:a=>j({name:a.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground focus:border-primary/60 focus:outline-none"})}),(0,d.jsx)(ai,{label:"Kind",children:(0,d.jsx)("select",{value:a.kind,onChange:a=>j({kind:a.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none",children:$.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id))})})]}),(0,d.jsx)(ai,{label:"Description",children:(0,d.jsx)("input",{type:"text",value:a.description,onChange:a=>j({description:a.target.value}),placeholder:"What this phase produces and why it exists.",className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})}),"review_only"!==a.kind&&(0,d.jsx)(ao,{phase:a,onUpdate:j,connectedVoices:g,personas:i}),"review_only"===a.kind&&(0,d.jsx)(ap,{phase:a,onUpdate:j}),(0,d.jsx)(aq,{phase:a,onUpdate:j,connectedVoices:g,personas:i}),(0,d.jsx)(ar,{phase:a,onUpdate:j}),(0,d.jsx)(as,{phase:a,onUpdate:j}),q.length>0&&(0,d.jsx)(at,{phase:a,onUpdate:j,priorPhases:q}),"review_only"!==a.kind&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(au,{phase:a,onUpdate:j,priorPhases:q}),(0,d.jsx)(av,{phase:a,onUpdate:j})]})]})]})}function ax({phase:a}){return(0,d.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:["review_only"!==a.kind&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",_.find(b=>b.id===a.doer.lineage)?.dot)}),"doer: ",a.doer.lineage]}),a.reviewer.candidates.length>0&&(0,d.jsxs)(d.Fragment,{children:["review_only"!==a.kind&&(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:["reviewers:",a.reviewer.candidates.map(a=>(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",_.find(b=>b.id===a)?.dot),title:a},a))]})]}),a.reviewer.crossLineage&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsx)("span",{className:"text-amber-300/90 font-mono text-[9px] uppercase",children:"cross-lineage"})]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsx)("span",{className:(0,y.cn)("font-mono text-[9px] uppercase","sequential"===a.execution?"text-amber-300/90":"text-emerald-300/80"),title:"sequential"===a.execution?"Sequential hostile — reviewers chain":"Parallel independent — reviewers vote",children:"sequential"===a.execution?"sequential":"parallel"}),a.inputs.exclude.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"text-rose-300/90 font-mono text-[9px]",children:["blind-to: ",a.inputs.exclude.join(",")]})]})]})}function ay({phases:a,onChange:b}){let c=ab(),{personas:f}=function(){let[a,b]=(0,e.useState)({personas:[],loaded:!1});return a}();function g(c,d){let e=c+d;if(e<0||e>=a.length)return;let f=[...a];[f[c],f[e]]=[f[e],f[c]],b(f)}let h=a.map(a=>a.id);return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,d.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:["Phases (",a.length,")"]}),(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"Each phase has a doer + reviewer. Adversarial by default."})]}),(0,d.jsx)("div",{className:"space-y-2",children:a.map((e,i)=>(0,d.jsx)(aw,{phase:e,index:i,total:a.length,allPhaseIds:h,connectedVoices:c,personas:f,onUpdate:c=>{b(a.map((a,b)=>b===i?{...a,...c}:a))},onMoveUp:()=>g(i,-1),onMoveDown:()=>g(i,1),onDelete:()=>{b(a.filter((a,b)=>b!==i))}},e.id))}),(0,d.jsxs)("button",{type:"button",onClick:function(){var c;b([...a,(c=a.length,{id:`phase-${c+1}`,name:`Phase ${c+1}`,description:"",kind:"review",gate:"auto",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:1,crossLineage:!0,candidates:["codex"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"sequential",builtin:!1})])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2.5 text-xs font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,d.jsx)(n.A,{className:"h-3.5 w-3.5"}),"Add phase"]})]})}function az({active:a,onClick:b,disabled:c,children:e}){return(0,d.jsxs)("button",{type:"button",onClick:b,disabled:c,className:(0,y.cn)("relative flex items-center gap-1.5 rounded-t-md px-3 py-2.5 text-sm font-medium transition-colors",c?"cursor-not-allowed text-muted-foreground/50":a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e,a&&!c&&(0,d.jsx)("span",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"})]})}function aA({label:a,htmlFor:b,hint:c,children:e}){return(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("label",{htmlFor:b,className:"block text-[13px] font-medium text-foreground",children:a}),e,c&&(0,d.jsx)("p",{className:"text-[11px] leading-snug text-muted-foreground/80",children:c})]})}function aB({active:a,onClick:b,children:c}){return(0,d.jsx)("button",{type:"button",onClick:b,className:(0,y.cn)("h-8 rounded-md border px-3 text-xs font-medium transition",a?"border-primary/60 bg-primary/15 text-primary":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30 hover:bg-accent/40 hover:text-foreground"),children:c})}function aC({form:a,setField:b,showErrors:c}){let e=c&&0===a.name.trim().length,f=c&&0===a.description.trim().length;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(aA,{label:"Name *",htmlFor:"tpl-name",children:[(0,d.jsx)("input",{id:"tpl-name",value:a.name,onChange:a=>b("name",a.target.value),placeholder:"security-audit","aria-invalid":e,className:(0,y.cn)("h-10 w-full rounded-md border bg-background px-3 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",e?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),e&&(0,d.jsx)("p",{className:"text-[11px] text-destructive",children:"Name is required."})]}),(0,d.jsxs)(aA,{label:"Description *",htmlFor:"tpl-desc",hint:"One sentence on when someone should reach for this template.",children:[(0,d.jsx)("textarea",{id:"tpl-desc",value:a.description,onChange:a=>b("description",a.target.value),placeholder:"Independent security audit from 3 model families…",rows:2,"aria-invalid":f,className:(0,y.cn)("w-full resize-none rounded-md border bg-background px-3 py-2 text-sm leading-relaxed placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",f?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),f&&(0,d.jsx)("p",{className:"text-[11px] text-destructive",children:"Description is required."})]}),(0,d.jsx)(aA,{label:"Category",children:(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:I.map(c=>(0,d.jsx)(aB,{active:c.id===a.category,onClick:()=>b("category",c.id),children:c.label},c.id))})})]})}function aD({form:a,setField:b}){let c=ab();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"rounded-md border border-border bg-card/40 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 text-foreground",children:[(0,d.jsx)(C.A,{className:"h-3 w-3"}),(0,d.jsx)("span",{className:"text-[12px] font-medium",children:"Template-level fallback chains"})]}),"Tried in order whenever a slot exhausts its own per-slot model chain. Cross-lineage swap supported — a codex slot can fall through to a claude or kimi entry. Strict",(0,d.jsx)("span",{className:"font-mono",children:" (lineage, model)"})," dedup keeps diversity: a fallback whose model already runs as another reviewer in this phase is skipped, so you never review the same code twice with the same voice. Order matters — list your most-preferred fallback first."]}),(0,d.jsx)(aE,{title:"Doer fallback",hint:"Engaged when the doer's primary + per-slot models all fail.",rows:a.fallbackDoer,onChange:a=>b("fallbackDoer",a),connectedVoices:c}),(0,d.jsx)(aE,{title:"Reviewer fallback",hint:"Engaged when any reviewer's primary + per-slot models all fail.",rows:a.fallbackReviewer,onChange:a=>b("fallbackReviewer",a),connectedVoices:c})]})}function aE({title:a,hint:b,rows:c,onChange:e,connectedVoices:f}){let g=(a,b)=>{e(c.map((c,d)=>d===a?{...c,...b}:c))};return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,d.jsx)("h4",{className:"text-[13px] font-semibold tracking-tight",children:a}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let a=M.find(a=>(f.byLineage[a]??[]).length>0)??"claude",b=f.byLineage[a]?.[0]??"";e([...c,{lineage:a,model:b}])},className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:text-primary",children:[(0,d.jsx)(n.A,{className:"h-3 w-3"}),"Add fallback"]})]}),(0,d.jsx)("p",{className:"mb-3 text-[11px] leading-snug text-muted-foreground/80",children:b}),0===c.length?(0,d.jsx)("p",{className:"rounded-md border border-dashed border-border/60 bg-background/30 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"None set — slot will fail its phase if the per-slot chain exhausts."}):(0,d.jsx)("ul",{className:"space-y-2",children:c.map((a,b)=>{let h=f.byLineage[a.lineage]??[],i=0===a.model.length||h.includes(a.model);return(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border bg-card font-mono text-[10px] text-muted-foreground",children:b+1}),(0,d.jsx)("select",{value:a.lineage,onChange:a=>{var d;let e,h;return d=a.target.value,e=f.byLineage[d]??[],h=c[b].model,void g(b,{lineage:d,model:e.includes(h)?h:e[0]??""})},className:"h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:M.map(a=>(0,d.jsx)("option",{value:a,children:a},a))}),(0,d.jsxs)("select",{value:a.model,onChange:a=>g(b,{model:a.target.value}),className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:[0===h.length&&(0,d.jsx)("option",{value:"",disabled:!0,children:f.loaded?`No ${a.lineage} models enabled — open Connect → ${a.lineage}`:"loading…"}),h.map(a=>(0,d.jsx)("option",{value:a,children:a},a)),!i&&a.model.length>0&&(0,d.jsxs)("option",{value:a.model,children:[a.model," (stored)"]})]}),(0,d.jsx)("button",{type:"button",onClick:()=>{e(c.filter((a,c)=>c!==b))},"aria-label":`Remove fallback ${b+1}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-destructive/40 hover:text-destructive",children:(0,d.jsx)(p.A,{className:"h-3 w-3"})})]},b)})})]})}function aF({form:a,setField:b}){return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,d.jsx)("h3",{className:"mb-3 text-[13px] font-semibold tracking-tight",children:"Across all phases"}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"Agreement threshold (per review-style phase)"}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:J.map(c=>(0,d.jsx)("button",{type:"button",onClick:()=>b("threshold",c.id),className:(0,y.cn)("rounded-md border px-3 py-2 text-left transition",a.threshold===c.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,d.jsx)("div",{className:"text-xs font-medium",children:c.label})},c.id))}),(0,d.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/80",children:J.find(b=>b.id===a.threshold)?.hint})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"When threshold is met"}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2",children:K.map(c=>(0,d.jsx)("button",{type:"button",onClick:()=>b("onThresholdMet",c.id),className:(0,y.cn)("rounded-md border px-3 py-2 text-left transition",a.onThresholdMet===c.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,d.jsx)("div",{className:"text-xs font-medium",children:c.label})},c.id))})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Max revise rounds (per phase)"}),(0,d.jsx)("span",{className:"font-mono text-xs text-foreground",children:a.maxRounds})]}),(0,d.jsx)("input",{type:"range",min:1,max:5,step:1,value:a.maxRounds,onChange:a=>b("maxRounds",parseInt(a.target.value,10)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-muted accent-primary"})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b("yoloDefault",!a.yoloDefault),className:(0,y.cn)("flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition",a.yoloDefault?"border-rose-500/40 bg-rose-500/5":"border-border bg-card hover:border-foreground/30"),children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-xs font-medium text-foreground",children:"\uD83D\uDE80 Yolo by default"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Auto-approve every gate. Only flip on for trusted templates or trivial fixes. Cost cap still enforced."})]}),(0,d.jsx)("span",{className:(0,y.cn)("flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition",a.yoloDefault?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"),children:(0,d.jsx)("span",{className:(0,y.cn)("h-3.5 w-3.5 rounded-full transition-transform",a.yoloDefault?"translate-x-4 bg-rose-400":"bg-muted-foreground/50")})})]})]})}function aG(a,b){let c=[];if(1===a)b.name&&0!==b.name.trim().length?b.name.length>80&&c.push("Name is too long (max 80 chars)."):c.push("Name is required."),b.description&&0!==b.description.trim().length||c.push("Description is required — one line on when to use this template.");else if(2===a)for(let a of(0===b.phases.length&&c.push("At least one phase is required."),b.phases))a.id&&0!==a.id.trim().length||c.push(`Phase "${a.name||"(unnamed)"}" needs an id.`),"review_only"===a.kind||a.doer.lineage&&0!==a.doer.models.length||c.push(`Phase "${a.name||a.id}" needs a doer lineage + model.`),0===a.reviewer.candidates.length&&c.push(`Phase "${a.name||a.id}" needs at least one reviewer.`);return c}function aH({form:a,setField:b}){let[c,f]=(0,e.useState)(1),[g,h]=(0,e.useState)(!1),i=aG(c,a),j=0===i.length;return(0,d.jsxs)("div",{className:"flex h-full flex-col px-6 py-6",children:[(0,d.jsx)(aI,{currentStep:c,onJump:b=>{if(b<=c){h(!1),f(b);return}for(let d=c;d<b;d++)if(aG(d,a).length>0)return void h(!0);h(!1),f(b)},form:a}),(0,d.jsxs)("div",{className:"mt-6 flex-1 space-y-6",children:[1===c&&(0,d.jsx)(aC,{form:a,setField:b,showErrors:g}),2===c&&(0,d.jsx)(aJ,{form:a,setField:b,showErrors:g}),3===c&&(0,d.jsx)(aD,{form:a,setField:b}),4===c&&(0,d.jsx)(aF,{form:a,setField:b})]}),g&&i.length>0&&(0,d.jsxs)("div",{className:"mt-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[(0,d.jsx)("div",{className:"mb-1 font-medium",children:"Resolve these to continue:"}),(0,d.jsx)("ul",{className:"space-y-0.5 pl-4",children:i.map(a=>(0,d.jsx)("li",{className:"list-disc",children:a},a))})]}),(0,d.jsxs)("div",{className:"mt-6 flex items-center justify-between border-t border-border pt-4",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>{h(!1),c>1&&f(c-1)},disabled:1===c,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[(0,d.jsx)(P,{className:"h-3.5 w-3.5"}),"Back"]}),(0,d.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Step ",c," of 4 \xb7 ",L[c-1].label]}),c<4?(0,d.jsxs)("button",{type:"button",onClick:()=>{j?(h(!1),c<4&&f(c+1)):h(!0)},className:(0,y.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium shadow-sm transition",j?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-muted text-muted-foreground/60"),children:["Next",(0,d.jsx)(Q,{className:"h-3.5 w-3.5"})]}):(0,d.jsxs)("span",{className:"text-[11px] text-emerald-300",children:[(0,d.jsx)(s.A,{className:"mr-1 inline-block h-3 w-3"}),"Save in the footer below"]})]})]})}function aI({currentStep:a,onJump:b,form:c}){return(0,d.jsx)("div",{className:"flex items-stretch gap-2",children:L.map(e=>{let f=e.icon,g=e.id===a,h=0===aG(e.id,c).length,i=e.id<a;return(0,d.jsxs)("button",{type:"button",onClick:()=>b(e.id),className:(0,y.cn)("flex flex-1 items-center gap-2 rounded-md border px-3 py-2 text-left transition",g?"border-primary/60 bg-primary/10":i&&!h?"border-destructive/40 bg-destructive/5":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,d.jsx)("span",{className:(0,y.cn)("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-mono",g?"bg-primary text-primary-foreground":i&&h?"bg-emerald-500/20 text-emerald-300":i&&!h?"bg-destructive/20 text-destructive":"bg-muted text-muted-foreground"),children:i&&h?"✓":e.id}),(0,d.jsx)(f,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"hidden text-xs font-medium sm:inline",children:e.label})]},e.id)})})}function aJ({form:a,setField:b,showErrors:c}){let e=aG(2,a);return(0,d.jsxs)(d.Fragment,{children:[c&&e.length>0&&(0,d.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:e[0]}),(0,d.jsx)(ay,{phases:a.phases,onChange:a=>b("phases",a)})]})}function aK(a){return Array.isArray(a)?a.flatMap(a=>{let b=F[a.lineage??""]??"claude",c=(a.models??[]).filter(a=>"string"==typeof a&&a.trim().length>0);return 0===c.length?[]:c.map(c=>({lineage:b,model:c,...a.persona?{persona:a.persona}:{}}))}):[]}let aL=["plan","spec","tests","implement","review","verify","divergence","review_only"];function aM(a,b){let c,d,e,f,g=[];try{c=v.parse(a)??{}}catch{return{form:{...H,id:b},formLossy:!0,lossyReasons:["YAML failed to parse — only YAML mode is available."]}}c.ship?.enabled&&g.push("Template has `ship.enabled: true` — form mode can't edit ship config.");let h=[];for(let a of c.phases??[]){let{phase:b,reasons:c}=function(a){let b=[];void 0!==a.timeoutMs&&b.push(`Phase ${a.id??"?"} has \`timeoutMs\` — not exposed in form mode.`);let c="review_only"===a.kind,d=c?"claude":F[a.doer?.lineage??""]??"claude",e={},f={},g=new Set,h=[],i=[];for(let b of a.reviewer?.candidates??[]){let a=F[b.lineage??""];if(!a)continue;g.has(a)||(g.add(a),h.push(a));let c=(b.models??[]).map(a=>(a??"").trim()).filter(a=>a.length>0),d=b.persona&&b.persona.trim().length>0?b.persona:void 0,j=b=>{if(!d)return;let c=f[a]??={},e=c[b];void 0!==e&&e!==d&&i.push(`${a}/${b||"(no model)"}: "${e}" vs "${d}"`),c[b]=d};if(0===c.length)j("");else for(let b of c)(e[a]??=[]).push(b),j(b)}i.length>0&&b.push(`Phase ${a.id??"?"} has overlapping reviewer candidates with conflicting personas (${i.join("; ")}) — form mode would silently last-write-wins; edit in YAML to disambiguate.`);let j=aL.includes(a.kind)?a.kind:"review";return a.kind&&!aL.includes(a.kind)&&b.push(`Phase ${a.id??"?"} has unknown kind \`${a.kind}\` — form mode would coerce it to \`review\`.`),{phase:{id:a.id??"phase",name:a.title??a.name??a.id??"Phase",description:a.description??"",kind:j,gate:"auto",doer:{lineage:d,models:a.doer?.models&&a.doer.models.length>0?a.doer.models:[G[d]??"claude-opus-4-7"],...a.doer?.persona&&a.doer.persona.trim().length>0?{persona:a.doer.persona.trim()}:{}},reviewer:{require:a.reviewer?.require??1,crossLineage:a.reviewer?.crossLineage??!0,candidates:h,candidateModels:e,...Object.keys(f).length>0?{candidatePersonas:f}:{}},inputs:{include:a.inputs?.include??[],exclude:a.inputs?.exclude??[]},iterate:{max:a.iterate?.maxRounds??2,onMax:(a.iterate?.onDisagreement??"continue")==="continue"?"loopback":a.iterate?.onDisagreement==="accept-doer"?"fail":"ask-user"},blindSpots:[],execution:"parallel",builtin:!1,...c&&a.artifact?{artifact:{label:a.artifact.label??"Artifact to review",hint:a.artifact.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact.maxBytes??1048576}}:c?{artifact:{label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}}:{}},reasons:b}}(a);h.push(b),g.push(...c)}if("number"==typeof c.agreementThreshold){var i;d=(i=c.agreementThreshold)>=.99?"unanimous":i>=.5?"majority":"any",new Set([1,.66,.34]).has(c.agreementThreshold)||(e=c.agreementThreshold,g.push(`Custom \`agreementThreshold: ${c.agreementThreshold}\` — form mode only offers 1.0 / 0.66 / 0.34 presets.`))}else d=c.agreementThreshold??"majority";let j="review"===c.onThresholdMet?"review":void 0;return"review"===j&&g.push("`onThresholdMet: review` — form mode only offers auto-finalize / ask-user."),{form:{id:c.id??b,name:c.name??"",description:c.description??"",author:c.author??"chorus",category:(f=(c.id??b).toLowerCase()).includes("bug")||f.includes("debug")||f.includes("diagnose")?"debug":f.includes("plan")||f.includes("architect")?"plan":f.includes("decide")||f.includes("decision")?"decide":"review",phases:h.length>0?h:H.phases,threshold:d,...void 0!==e?{customThreshold:e}:{},onThresholdMet:"merge"===c.onThresholdMet?"auto-finalize":"ask-user",...j?{onThresholdMetRaw:j}:{},maxRounds:c.maxRounds??3,yoloDefault:c.yoloDefault??!1,fallbackDoer:aK(c.fallback?.doer),fallbackReviewer:aK(c.fallback?.reviewer)},formLossy:g.length>0,lossyReasons:g}}function aN({yaml:a,filename:b,issues:c,onChange:e}){return(0,d.jsxs)("div",{className:"flex h-full min-h-[400px] flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-card/40 px-6 py-2.5",children:[(0,d.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:b}),(0,d.jsx)(aO,{issues:c})]}),(0,d.jsx)("textarea",{value:a,onChange:a=>e(a.target.value),spellCheck:!1,className:"flex-1 resize-none border-0 bg-background px-6 py-4 font-mono text-[12px] leading-relaxed text-foreground focus:outline-none"}),c.length>0&&(0,d.jsx)("ul",{className:"border-t border-border bg-destructive/5 px-6 py-2.5 text-[11px] text-destructive",children:c.map((a,b)=>(0,d.jsxs)("li",{className:"flex items-start gap-1.5 leading-snug",children:[(0,d.jsx)(r.A,{className:"mt-[1px] h-3 w-3 shrink-0"}),(0,d.jsxs)("span",{children:[(0,d.jsx)("span",{className:"font-mono",children:a.path}),"number"==typeof a.line&&` (line ${a.line})`,": ",a.message]})]},b))})]})}function aO({issues:a}){return 0===a.length?(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:[(0,d.jsx)(s.A,{className:"h-3 w-3"}),"Valid"]}):(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:[(0,d.jsx)(r.A,{className:"h-3 w-3"}),a.length," ",1===a.length?"issue":"issues"]})}function aP({editing:a,trigger:b,onSaved:c}){var h;let[i,j]=(0,e.useState)(!1),k=!!a,l=(0,e.useMemo)(()=>{if(!a)return{form:H,yaml:O(H),lossy:!1,reasons:[]};let b=aM(a.yaml,a.id);return{form:b.form,yaml:a.yaml,lossy:b.formLossy,reasons:b.lossyReasons}},[a?.id,a?.yaml]),[m,z]=(0,e.useState)(l.form),[A,B]=(0,e.useState)(l.yaml),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,I]=(0,e.useState)(l.lossy?"yaml":"form"),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(null),[P,Q]=(0,e.useState)([]),R=(0,e.useRef)(l),S=(h={yamlDirty:C,tab:G,formDirty:E,yamlText:A,formYaml:O(m),initialYaml:l.yaml}).yamlDirty||"yaml"===h.tab?h.yamlText:h.formDirty?h.formYaml:h.initialYaml,T=(0,e.useMemo)(()=>(function(a){let b;if(0===a.trim().length)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML is empty."}]};try{b=v.parse(a)}catch(c){let a=c instanceof Error?c.message:String(c),b=c.linePos?.[0];return{valid:!1,issues:[{path:"<yaml>",message:a,...b?{line:b.line,col:b.col}:{}}]}}if(null==b)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML parsed to null — at minimum it must define id, name, and phases."}]};let c=w._i.safeParse(b);return c.success?x:{valid:!1,issues:c.error.issues.map(a=>({path:a.path.length>0?a.path.join("."):"<root>",message:a.message}))}})(S),[S]);function U(a){if("form"===a&&C){let a=aM(A,m.id);if(a.formLossy)return;z(a.form),D(!1),F(!0)}I(a)}function V(){let a=R.current;z(a.form),B(a.yaml),D(!1),F(!1),I(a.lossy?"yaml":"form"),K(!1),M(null),Q([])}function W(a){j(a),a||setTimeout(V,200)}async function X(){if(!T.valid||J)return;let b=k?a.id:m.id||N(m.name)||"untitled";K(!0),M(null),Q([]);try{let a=await (0,u.AI)({id:b,yaml:S});c?.(a.id),W(!1)}catch(a){a instanceof u.$v?(M(a.message),Q(a.details?.issues??[])):M(a instanceof Error?a.message:"Save failed (unknown error)")}finally{K(!1)}}let Y=T.valid&&!J,Z=b??(0,d.jsxs)("button",{type:"button","aria-label":k?"Edit template":"New template",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90",children:[k?(0,d.jsx)(f.A,{className:"h-4 w-4"}):(0,d.jsx)(n.A,{className:"h-4 w-4"}),(0,d.jsx)("span",{className:"hidden sm:inline",children:k?"Edit":"New template"})]});return(0,d.jsxs)(t.lG,{open:i,onOpenChange:W,children:[(0,d.jsx)(t.zM,{asChild:!0,children:Z}),(0,d.jsxs)(t.Cf,{showCloseButton:!1,className:"flex max-h-[85vh] w-[min(96vw,720px)] flex-col gap-0 overflow-hidden border-border bg-card p-0 shadow-2xl sm:max-w-none",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-6 py-4",children:[(0,d.jsx)("div",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-md bg-primary/15 text-primary ring-1 ring-primary/20",children:(0,d.jsx)(o.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)(t.L3,{className:"text-[15px] font-semibold leading-tight tracking-tight",children:k?`Edit template — ${a.name}`:"New template"}),(0,d.jsx)(t.rr,{className:"mt-0.5 text-xs text-muted-foreground",children:k?"Edit the YAML directly or use the form. Validation runs live.":"A reusable review workflow. Edit visually below or paste raw YAML."})]}),(0,d.jsx)("button",{type:"button",onClick:()=>W(!1),className:"grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition hover:bg-accent hover:text-foreground","aria-label":"Close",children:(0,d.jsx)(p.A,{className:"h-4 w-4"})})]}),(0,d.jsx)("div",{className:"border-b border-border bg-card/40 px-6",children:(0,d.jsxs)("div",{className:"-mb-px flex items-center gap-1",children:[(0,d.jsxs)(az,{active:"form"===G,onClick:()=>!l.lossy&&U("form"),disabled:l.lossy,children:[(0,d.jsx)(q.A,{className:"h-3.5 w-3.5"}),"Form",l.lossy&&(0,d.jsx)("span",{className:"ml-1 rounded bg-muted px-1 text-[9px] font-medium text-muted-foreground",children:"YAML only"})]}),(0,d.jsxs)(az,{active:"yaml"===G,onClick:()=>U("yaml"),children:[(0,d.jsx)(o.A,{className:"h-3.5 w-3.5"}),"YAML",!T.valid&&"form"===G&&(0,d.jsx)("span",{className:"ml-1 h-1.5 w-1.5 rounded-full bg-destructive"})]})]})}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[l.lossy&&"yaml"===G&&(0,d.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/5 px-6 py-2.5 text-[11px] text-amber-200",children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)(r.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-medium",children:"Form editing disabled for this template"}),(0,d.jsx)("ul",{className:"mt-1 space-y-0.5 leading-snug",children:l.reasons.map((a,b)=>(0,d.jsxs)("li",{children:["\xb7 ",a]},b))})]})]})}),"form"===G?(0,d.jsx)(aH,{form:m,setField:function(a,b){let c={...m,[a]:b};z(c),F(!0),C||B(O(c))}}):(0,d.jsx)(aN,{yaml:A,filename:`${m.id||N(m.name)||"untitled"}.yaml`,issues:T.issues,onChange:a=>{B(a),D(!0)}})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border bg-card/40 px-6 py-3",children:[L&&(0,d.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:(0,d.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,d.jsx)(r.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-medium",children:"Save failed"}),(0,d.jsx)("div",{className:"mt-0.5 leading-snug",children:L}),P.length>0&&(0,d.jsx)("ul",{className:"mt-1 space-y-0.5",children:P.slice(0,5).map((a,b)=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"font-mono",children:a.path}),":"," ",a.message]},b))})]})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:T.valid?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.A,{className:"h-3 w-3 text-emerald-400"}),(0,d.jsx)("span",{children:"Ready to save"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(r.A,{className:"h-3 w-3 text-destructive/80"}),(0,d.jsxs)("span",{children:[T.issues.length," ",1===T.issues.length?"issue":"issues"," to resolve"]})]})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:()=>W(!1),className:"h-9 rounded-md border border-border bg-card px-4 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground",children:"Cancel"}),(0,d.jsxs)("button",{type:"button",disabled:!Y,onClick:X,className:(0,y.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-4 text-sm font-medium shadow-sm transition",Y?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-muted text-muted-foreground/60 shadow-none"),children:[J&&(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}),J?"Saving…":k?"Save changes":"Save template"]})]})]})]})]})]})}let aQ=Object.fromEntries(Object.entries(Y.r2).map(([a,b])=>[a,b.dot])),aR=[{id:"all",label:"All"},{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}];function aS(){let[a,b]=(0,e.useState)([]),[c,n]=(0,e.useState)(null),[o,p]=(0,e.useState)("all"),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(null),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(null),z=(0,e.useCallback)(async a=>{try{let c=await (0,u.eG)();b(c),a&&c.find(b=>b.id===a)?r(a):c.length>0&&!q&&r(c[0].id)}catch(a){n(a instanceof u.$v?a.message:"Failed to load templates")}},[q]);async function A(a){if(!v&&"builtin"!==a.source){if(s!==a.id){t(a.id),y(null),setTimeout(()=>{t(b=>b===a.id?null:b)},8e3);return}w(a.id),y(null);try{await (0,u.I7)(a.id),t(null),q===a.id&&r(""),await z()}catch(a){y(a instanceof u.$v||a instanceof Error?a.message:"Delete failed (unknown error)"),t(null)}finally{w(null)}}}let B="all"===o?a:a.filter(a=>a.category===o),C=a.find(a=>a.id===q)??a[0]??null;return c?(0,d.jsx)(i.G,{children:(0,d.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,d.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,d.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:c})]})})}):(0,d.jsx)(i.G,{children:(0,d.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,d.jsx)(l.z,{eyebrow:"Templates",title:"Reusable review workflows",subtitle:"Each template defines the driver, reviewers, prompts, and quorum rule for a kind of task. Fork, edit, share.",action:(0,d.jsx)(aP,{onSaved:a=>z(a)})}),x&&(0,d.jsx)("div",{className:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:x}),(0,d.jsx)("div",{className:"mb-4 flex items-center gap-1 border-b border-border",children:aR.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>p(a.id),className:`relative px-3 py-2 text-sm transition ${a.id===o?"text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[a.label,a.id===o&&(0,d.jsx)("span",{className:"absolute inset-x-3 bottom-0 h-0.5 bg-primary"})]},a.id))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1fr_1fr]",children:[(0,d.jsx)("div",{className:"flex min-w-0 flex-col gap-2",children:B.map(a=>(0,d.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>r(a.id),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),r(a.id))},className:`group relative cursor-pointer rounded-xl text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${a.id===q?"ring-2 ring-primary/60 ring-offset-2 ring-offset-background":""}`,children:[(0,d.jsxs)(j.Zp,{className:"bg-card p-4 transition group-hover:border-muted-foreground/30",children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("span",{className:"text-sm font-semibold",children:a.name}),(0,d.jsx)(k.E,{variant:"outline",className:"border-border text-[10px] capitalize",children:a.category}),!1===a.isComplete&&(0,d.jsx)(k.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:!1===a.isComplete?"Some slots couldn't be filled from your installed CLIs. Edit the YAML to pick models for each slot.":a.description})]})}),a.phases[0]?.reviewer?.candidates.length?(0,d.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[a.phases[0]?.kind!=="review_only"&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"doer"]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"→"})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[a.phases[0]?.reviewer?.candidates.map(a=>(0,d.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${aQ[a]}`,title:a},a)),(0,d.jsxs)("span",{children:[a.phases[0]?.reviewer?.candidates.length," ",a.phases[0]?.reviewer?.candidates.length===1?"reviewer":"reviewers"]})]}),a.phases.length>1&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"font-mono text-[10px]",children:[a.phases.length," phases"]})]})]}):null]}),(0,d.jsxs)("div",{className:`absolute bottom-3 right-3 flex items-center gap-1.5 transition ${a.id===q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,onClick:b=>{b.stopPropagation(),r(a.id)},onKeyDown:a=>a.stopPropagation(),children:[(0,d.jsx)(aP,{editing:a,onSaved:a=>z(a),trigger:(0,d.jsx)("button",{type:"button","aria-label":`Edit ${a.name}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-muted-foreground/40 hover:bg-accent/60 hover:text-foreground",children:(0,d.jsx)(f.A,{className:"h-3.5 w-3.5"})})}),"builtin"!==a.source&&(0,d.jsx)("button",{type:"button","aria-label":s===a.id?`Confirm delete ${a.name}`:`Delete ${a.name}`,title:s===a.id?"Click again to confirm":"Delete",disabled:v===a.id,onClick:()=>A(a),className:`grid h-7 w-7 place-items-center rounded-md border transition disabled:cursor-not-allowed disabled:opacity-50 ${s===a.id?"border-destructive bg-destructive/15 text-destructive":"border-border bg-card text-muted-foreground hover:border-destructive/50 hover:text-destructive"}`,children:v===a.id?(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(h.A,{className:"h-3.5 w-3.5"})})]})]},a.id))}),C?(0,d.jsx)("div",{className:"lg:sticky lg:top-6 lg:max-h-[calc(100vh-10rem)] lg:h-[calc(100vh-10rem)]",children:(0,d.jsx)(m.N,{filename:`${C.id}.yaml`,charCount:C.yaml.length,maxHeightClassName:"h-full",footer:(0,d.jsxs)("span",{children:["by ",C.authorHandle]}),children:C.yaml})}):(0,d.jsx)(j.Zp,{className:"bg-card p-4 text-center text-muted-foreground",children:(0,d.jsx)("p",{children:"Select a template to view details"})})]})]})})}},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41970:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("test-tube-diagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]])},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},45036:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(96600).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/ubuntu/dev/chorus/src/app/templates/page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/ubuntu/dev/chorus/src/app/templates/page.tsx","default")},46728:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]])},50133:(a,b,c)=>{"use strict";c.d(b,{Zp:()=>f});var d=c(66722);c(31131);var e=c(16276);function f({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"card",className:(0,e.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",a),...b})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},68598:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},72069:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},75619:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("git-pull-request",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]])},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},79428:a=>{"use strict";a.exports=require("buffer")},80282:(a,b,c)=>{"use strict";c.d(b,{G:()=>g});var d=c(66722),e=c(24188),f=c(86095);function g({children:a}){return(0,d.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,d.jsx)(e.AppSidebar,{}),(0,d.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,d.jsx)(f.MobileTopBar,{}),(0,d.jsx)("main",{className:"flex-1 overflow-y-auto",children:a})]})]})}},83720:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]])},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},91458:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]])},91887:(a,b,c)=>{"use strict";c.d(b,{z:()=>e});var d=c(66722);function e({eyebrow:a,title:b,subtitle:c,action:f}){return(0,d.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:a}),(0,d.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:b}),c&&(0,d.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:c})]}),f&&(0,d.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:f})]})}},94248:(a,b,c)=>{Promise.resolve().then(c.bind(c,36500))},95099:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},98947:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(15828),e=c(97067),f=c(38261),g=c(94322),h=c(64428),i=c(85126),j=c(48669),k=c(98846),l=c(6916),m=c(9958),n=c(50248),o=c(414),p=c(90667),q=c(261),r=c(8399),s=c(47796),t=c(26713),u=c(53846),v=c(65275),w=c(17695),x=c(33608),y=c(67040),z=c(54908),A=c(74840),B=c(86439),C=c(77068),D=c(72308),E=c(71708),F=c(91957),G=c(70722),H=c(4804),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["templates",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,45036)),"/home/ubuntu/dev/chorus/src/app/templates/page.tsx"]}]},{"global-error":[()=>Promise.resolve().then(c.t.bind(c,10312,23)),"next/dist/client/components/builtin/global-error.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,11305))).default(a),async a=>(await Promise.resolve().then(c.bind(c,89796))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]},{layout:[()=>Promise.resolve().then(c.bind(c,65979)),"/home/ubuntu/dev/chorus/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,10312,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,43790,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,27431,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,6906,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,11305))).default(a),async a=>(await Promise.resolve().then(c.bind(c,89796))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/templates/page",pathname:"/templates",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/templates/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(58965).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
|
|
1
|
+
(()=>{var a={};a.id=814,a.ids=[814],a.modules={261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},3295:a=>{"use strict";a.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},4602:(a,b,c)=>{"use strict";c.d(b,{E:()=>i});var d=c(66722);c(31131);var e=c(82786),f=c(29399),g=c(16276);let h=(0,e.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function i({className:a,variant:b="default",asChild:c=!1,...e}){let j=c?f.bL:"span";return(0,d.jsx)(j,{"data-slot":"badge","data-variant":b,className:(0,g.cn)(h({variant:b}),a),...e})}},7400:(a,b,c)=>{Promise.resolve().then(c.bind(c,45036))},10846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},14463:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]])},15213:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("file-code-corner",[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]])},17891:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/get-segment-param")},19121:a=>{"use strict";a.exports=require("next/dist/server/app-render/action-async-storage.external.js")},19771:a=>{"use strict";a.exports=require("process")},24961:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},26516:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},26713:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/is-bot")},28354:a=>{"use strict";a.exports=require("util")},29294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},31006:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("sliders-vertical",[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]])},31650:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},33873:a=>{"use strict";a.exports=require("path")},33911:(a,b,c)=>{"use strict";c.d(b,{N:()=>f});var d=c(66722),e=c(5616);function f({filename:a,charCount:b,footer:c,maxHeightClassName:g="max-h-[70vh]",children:h}){return(0,d.jsxs)("div",{className:"flex h-full min-w-0 flex-col overflow-hidden rounded-lg border border-border bg-card",children:[(0,d.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border bg-card/60 px-4 py-2.5",children:[(0,d.jsxs)("div",{className:"flex min-w-0 items-center gap-2 font-mono text-[11px] text-muted-foreground",children:[(0,d.jsx)(e.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:a})]}),"number"==typeof b&&(0,d.jsxs)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:[b.toLocaleString()," chars"]})]}),(0,d.jsx)("pre",{className:`${g} min-h-0 flex-1 overflow-auto whitespace-pre-wrap break-words bg-background px-5 py-4 font-mono text-[12px] leading-relaxed text-foreground/90`,children:h}),c&&(0,d.jsx)("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border bg-card/60 px-4 py-2.5 text-[11px] text-muted-foreground",children:c})]})}},36500:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>aS});var d=c(66722),e=c(31131),f=c(26516),g=c(66635),h=c(78770),i=c(80282),j=c(50133),k=c(4602),l=c(91887),m=c(33911),n=c(62435),o=c(15213),p=c(90057),q=c(68598),r=c(65850),s=c(55932),t=c(64519),u=c(66152),v=c(11022),w=c(94755);let x=Object.freeze({valid:!0,issues:[]});var y=c(16276),z=c(52449);let A=(0,z.A)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);var B=c(89629),C=c(91458),D=c(31006);let E={claude:"anthropic",codex:"openai",gemini:"google",opencode:"opencode",kimi:"moonshot",openrouter:"openrouter",local:"local",grok:"grok",antigravity:"antigravity"},F={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",openrouter:"openrouter",xai:"opencode",local:"local",grok:"grok",antigravity:"antigravity"},G={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-2.5-pro",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:"",local:"",grok:"grok-build",antigravity:"gemini-3.5-flash"},H={id:"",name:"",description:"",author:"you",category:"review",phases:[{id:"review",name:"Review",description:"Three independent critiques.",kind:"review",gate:"ask-user",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:3,crossLineage:!0,candidates:["codex","gemini","opencode"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!1}],threshold:"unanimous",onThresholdMet:"ask-user",maxRounds:3,yoloDefault:!1,fallbackDoer:[],fallbackReviewer:[]},I=[{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}],J=[{id:"unanimous",label:"Unanimous",hint:"All lineages must agree. Strictest — best for high-stakes reviews."},{id:"majority",label:"Majority",hint:"≥ ⅔ of lineages agree. Good default for code review."},{id:"any",label:"Any",hint:"≥1 lineage agrees. Useful for brainstorming where divergence is fine."}],K=[{id:"auto-finalize",label:"Auto-finalize"},{id:"ask-user",label:"Ask me"}],L=[{id:1,label:"Basics",icon:A},{id:2,label:"Phases",icon:B.A},{id:3,label:"Fallback",icon:C.A},{id:4,label:"Policy",icon:D.A}],M=["claude","codex","gemini","opencode","kimi","openrouter","local","grok","antigravity"];function N(a){return a.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"untitled"}function O(a){var b;return v.stringify({id:(b=a).id||N(b.name),name:b.name||"Untitled template",description:b.description||"Describe what this template is for.",author:b.author||"chorus",agreementThreshold:void 0!==b.customThreshold?b.customThreshold:function(a){switch(a){case"unanimous":return 1;case"majority":return .66;case"any":return .34}}(b.threshold),onThresholdMet:b.onThresholdMetRaw??("auto-finalize"===b.onThresholdMet?"merge":"ask"),maxRounds:b.maxRounds,yoloDefault:b.yoloDefault,phases:b.phases.map(a=>{let b="review_only"===a.kind,c=a.reviewer.candidates.length>0?{require:a.reviewer.require,crossLineage:a.reviewer.crossLineage,candidates:a.reviewer.candidates.flatMap(b=>{let c=(a.reviewer.candidateModels?.[b]??[]).map(a=>a.trim()).filter(a=>a.length>0),d=a.reviewer.candidatePersonas?.[b],e=E[b]??"anthropic";if(0===c.length){let a=G[b]??"claude-opus-4-7",c=d?.[""];return[{lineage:e,models:[a],...c?{persona:c}:{}}]}return c.map(a=>{let b=d?.[a];return{lineage:e,models:[a],...b?{persona:b}:{}}})})}:void 0;return b?{id:a.id,kind:a.kind,title:a.name,description:a.description,reviewer:c,inputs:{include:a.inputs.include,exclude:a.inputs.exclude},artifact:{label:a.artifact?.label??"Artifact to review",hint:a.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact?.maxBytes??1048576}}:{id:a.id,kind:a.kind,title:a.name,description:a.description,doer:{lineage:E[a.doer.lineage]??"anthropic",models:a.doer.models.length>0?a.doer.models:[G[a.doer.lineage]??"claude-opus-4-7"],...a.doer.persona?{persona:a.doer.persona}:{}},reviewer:c,inputs:{include:a.inputs.include,exclude:a.inputs.exclude},iterate:{maxRounds:a.iterate.max,onDisagreement:"loopback"===a.iterate.onMax?"continue":"fail"===a.iterate.onMax?"accept-doer":"escalate",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}}}),...b.fallbackDoer.length>0||b.fallbackReviewer.length>0?{fallback:{...b.fallbackDoer.length>0?{doer:b.fallbackDoer.map(a=>({lineage:E[a.lineage]??"anthropic",models:[a.model],...a.persona?{persona:a.persona}:{}}))}:{},...b.fallbackReviewer.length>0?{reviewer:b.fallbackReviewer.map(a=>({lineage:E[a.lineage]??"anthropic",models:[a.model],...a.persona?{persona:a.persona}:{}}))}:{}}}:{}},{lineWidth:0})}let P=(0,z.A)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),Q=(0,z.A)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);c(29843),c(11897);var R=c(31650),S=c(46728),T=c(41970),U=c(5616),V=c(83720),W=c(75619),X=c(14463),Y=c(6506);let Z={review:R.A,review_only:R.A,plan:S.A,spec:o.A,tests:T.A,implement:U.A,verify:V.A,pr:W.A,divergence:C.A,recon:X.A},$=[{id:"plan",label:"Plan"},{id:"spec",label:"Spec / API"},{id:"tests",label:"Tests"},{id:"implement",label:"Implement"},{id:"verify",label:"Verify"},{id:"pr",label:"Open PR"},{id:"review",label:"Review"},{id:"review_only",label:"Review only (artifact)"},{id:"divergence",label:"Divergence"},{id:"recon",label:"Recon"}],_=["claude","codex","gemini","opencode","kimi","openrouter","local","grok","antigravity"].map(a=>({id:a,label:Y.m_[a],dot:Y.r2[a].dot})),aa=Y.x0;function ab(){let[a,b]=(0,e.useState)({byLineage:{},connectedLineages:new Set,loaded:!1});return a}let ac=(0,z.A)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),ad=(0,z.A)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);var ae=c(24961),af=c(72069),ag=c(95099);function ah({children:a,onClick:b,disabled:c,title:e,className:f}){return(0,d.jsx)("button",{type:"button",disabled:c,onClick:a=>{a.stopPropagation(),b()},title:e,className:(0,y.cn)("grid h-6 w-6 place-items-center rounded text-muted-foreground transition hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",f),children:a})}function ai({label:a,children:b}){return(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"mb-1.5 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:a}),b]})}function aj({on:a,tone:b,onClick:c,children:e}){return(0,d.jsx)("button",{type:"button",onClick:c,className:(0,y.cn)("rounded-md border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition",{emerald:a?"border-emerald-500/40 bg-emerald-500/15 text-emerald-200":"border-border bg-card/40 text-muted-foreground hover:border-emerald-500/30",rose:a?"border-rose-500/40 bg-rose-500/15 text-rose-200":"border-border bg-card/40 text-muted-foreground hover:border-rose-500/30"}[b]),children:e})}function ak({value:a,personas:b,onChange:c,inline:e,ariaLabel:f}){let g="__none__",h=b.some(b=>b.id===a);return(0,d.jsxs)("select",{value:a??g,onChange:a=>{let b=a.target.value;c(b===g?void 0:b)},className:(0,y.cn)("h-7 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none",e?"w-32 shrink-0":"w-full"),"aria-label":f??"Persona",children:[(0,d.jsx)("option",{value:g,children:"(no persona)"}),b.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id)),a&&!h&&(0,d.jsxs)("option",{value:a,children:[a," (missing)"]})]})}function al({lineage:a,value:b,options:c,onChange:f,defaultModel:g}){let h="__custom__",i=!b||c.includes(b),[j,k]=(0,e.useState)(!1);if(j)return(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:g?`default: ${g}`:`${a} model id`,className:"h-7 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none",autoFocus:!0}),(0,d.jsx)("button",{type:"button",onClick:()=>k(!1),className:"h-7 rounded-md border border-border bg-card/40 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"done"})]});if(0===c.length)return(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("input",{type:"text",value:b,onChange:a=>f(a.target.value),placeholder:g?`default: ${g}`:`${a} model id`,className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none"}),(0,d.jsxs)("p",{className:"text-[10px] text-amber-400/80",children:["No ",a," voices enabled. Configure in Connect to populate this dropdown."]})]});let l=i?c:[b,...c];return(0,d.jsxs)("select",{value:b,onChange:a=>{a.target.value===h?k(!0):f(a.target.value)},className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none",children:[!b&&(0,d.jsx)("option",{value:"",children:g?`default: ${g}`:"— pick a model —"}),l.map(a=>(0,d.jsxs)("option",{value:a,children:[a,c.includes(a)||b!==a?"":" (not enabled)"]},a)),(0,d.jsx)("option",{value:h,children:"+ custom (type a model id)…"})]})}function am(a){let b=[];for(let c of a.candidates){let d=a.candidateModels?.[c],e=a.candidatePersonas?.[c];if(d&&0!==d.length)for(let a of d)b.push({lineage:c,model:a,...e?.[a]?{persona:e[a]}:{}});else b.push({lineage:c,model:"",...e?.[""]?{persona:e[""]}:{}})}return b}function an({phase:a,connectedVoices:b,personas:c,onUpdate:e}){let f=am(a.reviewer),g=_.filter(a=>0===b.connectedLineages.size||b.connectedLineages.has(a.id));function h(b){e({reviewer:function(a,b){let c=[],d={},e={};for(let b of a)c.includes(b.lineage)||c.push(b.lineage),b.model&&(d[b.lineage]??=[]).push(b.model),b.persona&&((e[b.lineage]??={})[b.model]=b.persona);return{...b,candidates:c,candidateModels:d,...Object.keys(e).length>0?{candidatePersonas:e}:{candidatePersonas:void 0}}}(b,a.reviewer)})}function i(a,c){let d=f.map((b,d)=>d===a?{...b,...c}:b);if(c.lineage&&c.lineage!==f[a].lineage){let e=b.byLineage[c.lineage]??[];d[a].model=e[0]??aa[c.lineage]??""}h(d)}return(0,d.jsxs)("div",{className:"space-y-1.5",children:[0===f.length&&(0,d.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No reviewers yet. Click + add reviewer below."}),f.map((a,e)=>{let j=_.find(b=>b.id===a.lineage);return(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsxs)("select",{value:a.lineage,onChange:a=>i(e,{lineage:a.target.value}),className:"h-7 w-32 shrink-0 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none","aria-label":"Reviewer lineage",children:[g.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id)),!g.find(b=>b.id===a.lineage)&&(0,d.jsxs)("option",{value:a.lineage,children:[j?.label??a.lineage," (not connected)"]})]}),(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)(al,{lineage:a.lineage,value:a.model,options:b.byLineage[a.lineage]??[],defaultModel:aa[a.lineage],onChange:a=>i(e,{model:a})})}),(0,d.jsx)(ak,{value:a.persona,personas:c,onChange:a=>i(e,{persona:a}),inline:!0,ariaLabel:"Reviewer persona"}),(0,d.jsx)("button",{type:"button",onClick:()=>{h(f.filter((a,b)=>b!==e))},"aria-label":"Remove reviewer",className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-border bg-card/40 text-muted-foreground hover:border-destructive/40 hover:text-destructive",children:(0,d.jsx)(p.A,{className:"h-3 w-3"})})]},e)}),(0,d.jsxs)("button",{type:"button",onClick:function(){let a=g[0]?.id??"claude",c=b.byLineage[a]??[],d=new Set(f.filter(b=>b.lineage===a).map(a=>a.model)),e=c.find(a=>!d.has(a))??aa[a]??"";h([...f,{lineage:a,model:e}])},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,d.jsx)(n.A,{className:"h-3 w-3"}),"Add another reviewer"]})]})}function ao({phase:a,onUpdate:b,connectedVoices:c,personas:e}){return(0,d.jsxs)(ai,{label:"Doer \xb7 the agent that writes this phase's output",children:[(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:_.filter(a=>0===c.connectedLineages.size||c.connectedLineages.has(a.id)).map(e=>(0,d.jsxs)("button",{type:"button",onClick:()=>{let a=(c.byLineage[e.id]??[])[0]??aa[e.id];b({doer:{lineage:e.id,models:a?[a]:[]}})},className:(0,y.cn)("flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition",a.doer.lineage===e.id?"border-primary/40 bg-primary/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",e.dot)}),(0,d.jsx)("span",{className:"text-xs",children:e.label}),a.doer.lineage===e.id&&(0,d.jsx)(af.A,{className:"ml-auto h-3 w-3 text-primary"})]},e.id))}),(0,d.jsx)("div",{className:"mt-2",children:(0,d.jsx)(al,{lineage:a.doer.lineage,value:a.doer.models[0]??"",options:c.byLineage[a.doer.lineage]??[],defaultModel:aa[a.doer.lineage],onChange:c=>b({doer:{...a.doer,models:c?[c]:[]}})})}),(0,d.jsxs)("div",{className:"mt-2",children:[(0,d.jsx)("label",{className:"mb-1 block text-[10px] text-muted-foreground",children:"Persona (optional \xb7 prepends a worldview to the doer's prompt)"}),(0,d.jsx)(ak,{value:a.doer.persona,personas:e,onChange:c=>b({doer:c?{...a.doer,persona:c}:(()=>{let{persona:b,...c}=a.doer;return c})()}),ariaLabel:"Doer persona"})]})]})}function ap({phase:a,onUpdate:b}){let c={label:a.artifact?.label??"Artifact to review",hint:a.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact?.maxBytes??1048576};return(0,d.jsx)(ai,{label:"Artifact \xb7 what the user pastes when starting a chat",children:(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Label"}),(0,d.jsx)("input",{type:"text",value:c.label,onChange:a=>b({artifact:{...c,label:a.target.value}}),placeholder:"Artifact to review",className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Placeholder hint"}),(0,d.jsx)("textarea",{value:a.artifact?.hint??"",onChange:a=>b({artifact:{...c,hint:a.target.value}}),placeholder:"Paste a unified diff, a markdown draft, code, or any text blob.",rows:2,className:"mt-1 w-full resize-none rounded-md border border-border bg-background px-2.5 py-1.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max bytes (server-side cap)"}),(0,d.jsx)("input",{type:"number",min:1024,step:1024,value:c.maxBytes,onChange:a=>b({artifact:{...c,maxBytes:Math.max(1024,parseInt(a.target.value,10)||1048576)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 font-mono text-[11px] focus:border-primary/60 focus:outline-none"}),(0,d.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:"1 MiB = 1048576. Default if unset."})]})]})})}function aq({phase:a,onUpdate:b,connectedVoices:c,personas:e}){return(0,d.jsx)(ai,{label:"Reviewers \xb7 who gates this phase",children:(0,d.jsx)(an,{phase:a,connectedVoices:c,personas:e,onUpdate:b})})}function ar({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Approvals",children:(0,d.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,d.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["Require:",(0,d.jsx)("input",{type:"number",min:0,max:Math.max(1,am(a.reviewer).length),value:a.reviewer.require,onChange:c=>b({reviewer:{...a.reviewer,require:Math.max(0,parseInt(c.target.value,10)||0)}}),className:"h-6 w-12 rounded border border-border bg-background px-1.5 text-center font-mono text-[11px]"}),"approval",1===a.reviewer.require?"":"s"]}),"review_only"!==a.kind&&(0,d.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,d.jsx)("input",{type:"checkbox",checked:a.reviewer.crossLineage,onChange:c=>b({reviewer:{...a.reviewer,crossLineage:c.target.checked}}),className:"accent-primary"}),"Cross-lineage required"]})]})})}function as({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Reviewer execution \xb7 how multiple reviewers interact",children:(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b({execution:"parallel"}),className:(0,y.cn)("rounded-md border px-3 py-2.5 text-left transition","parallel"===a.execution?"border-emerald-500/40 bg-emerald-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Parallel independent",(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase text-emerald-300/80",children:"fast"})]}),(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"All reviewers see the same pack, work in isolation, vote. Catches single-reviewer mistakes via consensus. Risk: shared blind spots pass anyway."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b({execution:"sequential"}),className:(0,y.cn)("rounded-md border px-3 py-2.5 text-left transition","sequential"===a.execution?"border-amber-500/40 bg-amber-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Sequential hostile",(0,d.jsx)("span",{className:"font-mono text-[9px] uppercase text-amber-300/80",children:"thorough"})]}),(0,d.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"Reviewers run in order. Each receives the already-hardened output and hunts what the prior reviewer missed. Slower; only works if the first reviewer's solution is sound."})]})]})})}function at({phase:a,onUpdate:b,priorPhases:c}){return(0,d.jsxs)(ai,{label:"Inputs \xb7 which prior phases this doer can read",children:[(0,d.jsx)("div",{className:"space-y-1.5",children:c.map(c=>{let e=a.inputs.include.includes(c),f=a.inputs.exclude.includes(c),g=f?"exclude":e?"include":"none";return(0,d.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-card/30 px-2.5 py-1.5",children:[(0,d.jsx)("code",{className:"font-mono text-[11px] text-foreground",children:c}),(0,d.jsxs)("div",{className:"flex items-center gap-1",children:[(0,d.jsx)(aj,{on:"include"===g,tone:"emerald",onClick:()=>b({inputs:{include:e?a.inputs.include.filter(a=>a!==c):[...a.inputs.include,c],exclude:a.inputs.exclude.filter(a=>a!==c)}}),children:"include"}),(0,d.jsx)(aj,{on:"exclude"===g,tone:"rose",onClick:()=>b({inputs:{include:a.inputs.include.filter(a=>a!==c),exclude:f?a.inputs.exclude.filter(a=>a!==c):[...a.inputs.exclude,c]}}),children:"exclude (blind)"})]})]},c)})}),(0,d.jsxs)("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] text-muted-foreground",children:[(0,d.jsx)(ag.A,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground/60"}),(0,d.jsxs)("span",{children:[(0,d.jsx)("span",{className:"font-mono text-rose-300",children:"exclude"}),"prevents this doer from seeing that phase's output. Used for info asymmetry — e.g. the implementer shouldn't see the tests."]})]})]})}function au({phase:a,onUpdate:b,priorPhases:c}){return(0,d.jsx)(ai,{label:"Iterate \xb7 what happens when reviewer rejects",children:(0,d.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max revise"}),(0,d.jsx)("input",{type:"number",min:1,max:10,value:a.iterate.max,onChange:c=>b({iterate:{...a.iterate,max:Math.max(1,parseInt(c.target.value,10)||1)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px]"})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"On max"}),(0,d.jsxs)("select",{value:a.iterate.onMax,onChange:c=>b({iterate:{...a.iterate,onMax:c.target.value}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px]",children:[(0,d.jsx)("option",{value:"ask-user",children:"ask me"}),(0,d.jsx)("option",{value:"loopback",children:"loop back"}),(0,d.jsx)("option",{value:"fail",children:"fail"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Loop back to"}),(0,d.jsxs)("select",{disabled:"loopback"!==a.iterate.onMax,value:a.iterate.loopbackTo??"",onChange:c=>b({iterate:{...a.iterate,loopbackTo:c.target.value||void 0}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px] disabled:opacity-40",children:[(0,d.jsx)("option",{value:"",children:"—"}),c.map(a=>(0,d.jsx)("option",{value:a,children:a},a))]})]})]})})}function av({phase:a,onUpdate:b}){return(0,d.jsx)(ai,{label:"Gate \xb7 what happens when this phase finishes",children:(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>b({gate:"auto"}),className:(0,y.cn)("rounded-md border px-2.5 py-1.5 text-left transition","auto"===a.gate?"border-emerald-500/40 bg-emerald-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Auto-proceed"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Continue to next phase without asking."})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b({gate:"ask-user"}),className:(0,y.cn)("rounded-md border px-2.5 py-1.5 text-left transition","ask-user"===a.gate?"border-amber-500/40 bg-amber-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,d.jsx)("div",{className:"text-xs font-medium",children:"Checkpoint (ask me)"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Stop here, surface verdict, wait for click."})]})]})})}function aw({phase:a,index:b,total:c,allPhaseIds:f,connectedVoices:g,personas:i,onUpdate:j,onMoveUp:k,onMoveDown:l,onDelete:m}){let[n,o]=(0,e.useState)(0===b),p=Z[a.kind],q=f.slice(0,b);return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>o(a=>!a),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left",children:[(0,d.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:String(b+1).padStart(2,"0")}),(0,d.jsx)("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md bg-primary/15 text-primary",children:(0,d.jsx)(p,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:a.name||"Untitled phase"}),(0,d.jsx)("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:a.kind})]}),(0,d.jsx)(ax,{phase:a})]}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)(ah,{disabled:0===b,onClick:k,title:"Move up",children:(0,d.jsx)(ac,{className:"h-3 w-3"})}),(0,d.jsx)(ah,{disabled:b===c-1,onClick:l,title:"Move down",children:(0,d.jsx)(ad,{className:"h-3 w-3"})}),(0,d.jsx)(ah,{onClick:m,title:"Delete phase",className:"hover:text-rose-400",children:(0,d.jsx)(h.A,{className:"h-3 w-3"})}),(0,d.jsx)("span",{className:"ml-1 text-muted-foreground/60",children:n?(0,d.jsx)(ae.A,{className:"h-3.5 w-3.5"}):(0,d.jsx)(Q,{className:"h-3.5 w-3.5"})})]})]}),n&&(0,d.jsxs)("div",{className:"space-y-4 border-t border-border bg-background/40 px-3 py-3",children:[(0,d.jsxs)("div",{className:"grid grid-cols-[1fr_140px] gap-2",children:[(0,d.jsx)(ai,{label:"Name",children:(0,d.jsx)("input",{type:"text",value:a.name,onChange:a=>j({name:a.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground focus:border-primary/60 focus:outline-none"})}),(0,d.jsx)(ai,{label:"Kind",children:(0,d.jsx)("select",{value:a.kind,onChange:a=>j({kind:a.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none",children:$.map(a=>(0,d.jsx)("option",{value:a.id,children:a.label},a.id))})})]}),(0,d.jsx)(ai,{label:"Description",children:(0,d.jsx)("input",{type:"text",value:a.description,onChange:a=>j({description:a.target.value}),placeholder:"What this phase produces and why it exists.",className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})}),"review_only"!==a.kind&&(0,d.jsx)(ao,{phase:a,onUpdate:j,connectedVoices:g,personas:i}),"review_only"===a.kind&&(0,d.jsx)(ap,{phase:a,onUpdate:j}),(0,d.jsx)(aq,{phase:a,onUpdate:j,connectedVoices:g,personas:i}),(0,d.jsx)(ar,{phase:a,onUpdate:j}),(0,d.jsx)(as,{phase:a,onUpdate:j}),q.length>0&&(0,d.jsx)(at,{phase:a,onUpdate:j,priorPhases:q}),"review_only"!==a.kind&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(au,{phase:a,onUpdate:j,priorPhases:q}),(0,d.jsx)(av,{phase:a,onUpdate:j})]})]})]})}function ax({phase:a}){return(0,d.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:["review_only"!==a.kind&&(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",_.find(b=>b.id===a.doer.lineage)?.dot)}),"doer: ",a.doer.lineage]}),a.reviewer.candidates.length>0&&(0,d.jsxs)(d.Fragment,{children:["review_only"!==a.kind&&(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:["reviewers:",a.reviewer.candidates.map(a=>(0,d.jsx)("span",{className:(0,y.cn)("h-1.5 w-1.5 rounded-full",_.find(b=>b.id===a)?.dot),title:a},a))]})]}),a.reviewer.crossLineage&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsx)("span",{className:"text-amber-300/90 font-mono text-[9px] uppercase",children:"cross-lineage"})]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsx)("span",{className:(0,y.cn)("font-mono text-[9px] uppercase","sequential"===a.execution?"text-amber-300/90":"text-emerald-300/80"),title:"sequential"===a.execution?"Sequential hostile — reviewers chain":"Parallel independent — reviewers vote",children:"sequential"===a.execution?"sequential":"parallel"}),a.inputs.exclude.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"text-rose-300/90 font-mono text-[9px]",children:["blind-to: ",a.inputs.exclude.join(",")]})]})]})}function ay({phases:a,onChange:b}){let c=ab(),{personas:f}=function(){let[a,b]=(0,e.useState)({personas:[],loaded:!1});return a}();function g(c,d){let e=c+d;if(e<0||e>=a.length)return;let f=[...a];[f[c],f[e]]=[f[e],f[c]],b(f)}let h=a.map(a=>a.id);return(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,d.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:["Phases (",a.length,")"]}),(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"Each phase has a doer + reviewer. Adversarial by default."})]}),(0,d.jsx)("div",{className:"space-y-2",children:a.map((e,i)=>(0,d.jsx)(aw,{phase:e,index:i,total:a.length,allPhaseIds:h,connectedVoices:c,personas:f,onUpdate:c=>{b(a.map((a,b)=>b===i?{...a,...c}:a))},onMoveUp:()=>g(i,-1),onMoveDown:()=>g(i,1),onDelete:()=>{b(a.filter((a,b)=>b!==i))}},e.id))}),(0,d.jsxs)("button",{type:"button",onClick:function(){var c;b([...a,(c=a.length,{id:`phase-${c+1}`,name:`Phase ${c+1}`,description:"",kind:"review",gate:"auto",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:1,crossLineage:!0,candidates:["codex"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"sequential",builtin:!1})])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2.5 text-xs font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,d.jsx)(n.A,{className:"h-3.5 w-3.5"}),"Add phase"]})]})}function az({active:a,onClick:b,disabled:c,children:e}){return(0,d.jsxs)("button",{type:"button",onClick:b,disabled:c,className:(0,y.cn)("relative flex items-center gap-1.5 rounded-t-md px-3 py-2.5 text-sm font-medium transition-colors",c?"cursor-not-allowed text-muted-foreground/50":a?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[e,a&&!c&&(0,d.jsx)("span",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"})]})}function aA({label:a,htmlFor:b,hint:c,children:e}){return(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("label",{htmlFor:b,className:"block text-[13px] font-medium text-foreground",children:a}),e,c&&(0,d.jsx)("p",{className:"text-[11px] leading-snug text-muted-foreground/80",children:c})]})}function aB({active:a,onClick:b,children:c}){return(0,d.jsx)("button",{type:"button",onClick:b,className:(0,y.cn)("h-8 rounded-md border px-3 text-xs font-medium transition",a?"border-primary/60 bg-primary/15 text-primary":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30 hover:bg-accent/40 hover:text-foreground"),children:c})}function aC({form:a,setField:b,showErrors:c}){let e=c&&0===a.name.trim().length,f=c&&0===a.description.trim().length;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(aA,{label:"Name *",htmlFor:"tpl-name",children:[(0,d.jsx)("input",{id:"tpl-name",value:a.name,onChange:a=>b("name",a.target.value),placeholder:"security-audit","aria-invalid":e,className:(0,y.cn)("h-10 w-full rounded-md border bg-background px-3 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",e?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),e&&(0,d.jsx)("p",{className:"text-[11px] text-destructive",children:"Name is required."})]}),(0,d.jsxs)(aA,{label:"Description *",htmlFor:"tpl-desc",hint:"One sentence on when someone should reach for this template.",children:[(0,d.jsx)("textarea",{id:"tpl-desc",value:a.description,onChange:a=>b("description",a.target.value),placeholder:"Independent security audit from 3 model families…",rows:2,"aria-invalid":f,className:(0,y.cn)("w-full resize-none rounded-md border bg-background px-3 py-2 text-sm leading-relaxed placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",f?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),f&&(0,d.jsx)("p",{className:"text-[11px] text-destructive",children:"Description is required."})]}),(0,d.jsx)(aA,{label:"Category",children:(0,d.jsx)("div",{className:"flex flex-wrap gap-2",children:I.map(c=>(0,d.jsx)(aB,{active:c.id===a.category,onClick:()=>b("category",c.id),children:c.label},c.id))})})]})}function aD({form:a,setField:b}){let c=ab();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"rounded-md border border-border bg-card/40 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 text-foreground",children:[(0,d.jsx)(C.A,{className:"h-3 w-3"}),(0,d.jsx)("span",{className:"text-[12px] font-medium",children:"Template-level fallback chains"})]}),"Tried in order whenever a slot exhausts its own per-slot model chain. Cross-lineage swap supported — a codex slot can fall through to a claude or kimi entry. Strict",(0,d.jsx)("span",{className:"font-mono",children:" (lineage, model)"})," dedup keeps diversity: a fallback whose model already runs as another reviewer in this phase is skipped, so you never review the same code twice with the same voice. Order matters — list your most-preferred fallback first."]}),(0,d.jsx)(aE,{title:"Doer fallback",hint:"Engaged when the doer's primary + per-slot models all fail.",rows:a.fallbackDoer,onChange:a=>b("fallbackDoer",a),connectedVoices:c}),(0,d.jsx)(aE,{title:"Reviewer fallback",hint:"Engaged when any reviewer's primary + per-slot models all fail.",rows:a.fallbackReviewer,onChange:a=>b("fallbackReviewer",a),connectedVoices:c})]})}function aE({title:a,hint:b,rows:c,onChange:e,connectedVoices:f}){let g=(a,b)=>{e(c.map((c,d)=>d===a?{...c,...b}:c))};return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,d.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,d.jsx)("h4",{className:"text-[13px] font-semibold tracking-tight",children:a}),(0,d.jsxs)("button",{type:"button",onClick:()=>{let a=M.find(a=>(f.byLineage[a]??[]).length>0)??"claude",b=f.byLineage[a]?.[0]??"";e([...c,{lineage:a,model:b}])},className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:text-primary",children:[(0,d.jsx)(n.A,{className:"h-3 w-3"}),"Add fallback"]})]}),(0,d.jsx)("p",{className:"mb-3 text-[11px] leading-snug text-muted-foreground/80",children:b}),0===c.length?(0,d.jsx)("p",{className:"rounded-md border border-dashed border-border/60 bg-background/30 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"None set — slot will fail its phase if the per-slot chain exhausts."}):(0,d.jsx)("ul",{className:"space-y-2",children:c.map((a,b)=>{let h=f.byLineage[a.lineage]??[],i=0===a.model.length||h.includes(a.model);return(0,d.jsxs)("li",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border bg-card font-mono text-[10px] text-muted-foreground",children:b+1}),(0,d.jsx)("select",{value:a.lineage,onChange:a=>{var d;let e,h;return d=a.target.value,e=f.byLineage[d]??[],h=c[b].model,void g(b,{lineage:d,model:e.includes(h)?h:e[0]??""})},className:"h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:M.map(a=>(0,d.jsx)("option",{value:a,children:a},a))}),(0,d.jsxs)("select",{value:a.model,onChange:a=>g(b,{model:a.target.value}),className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:[0===h.length&&(0,d.jsx)("option",{value:"",disabled:!0,children:f.loaded?`No ${a.lineage} models enabled — open Connect → ${a.lineage}`:"loading…"}),h.map(a=>(0,d.jsx)("option",{value:a,children:a},a)),!i&&a.model.length>0&&(0,d.jsxs)("option",{value:a.model,children:[a.model," (stored)"]})]}),(0,d.jsx)("button",{type:"button",onClick:()=>{e(c.filter((a,c)=>c!==b))},"aria-label":`Remove fallback ${b+1}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-destructive/40 hover:text-destructive",children:(0,d.jsx)(p.A,{className:"h-3 w-3"})})]},b)})})]})}function aF({form:a,setField:b}){return(0,d.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,d.jsx)("h3",{className:"mb-3 text-[13px] font-semibold tracking-tight",children:"Across all phases"}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"Agreement threshold (per review-style phase)"}),(0,d.jsx)("div",{className:"grid grid-cols-3 gap-2",children:J.map(c=>(0,d.jsx)("button",{type:"button",onClick:()=>b("threshold",c.id),className:(0,y.cn)("rounded-md border px-3 py-2 text-left transition",a.threshold===c.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,d.jsx)("div",{className:"text-xs font-medium",children:c.label})},c.id))}),(0,d.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/80",children:J.find(b=>b.id===a.threshold)?.hint})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"When threshold is met"}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-2",children:K.map(c=>(0,d.jsx)("button",{type:"button",onClick:()=>b("onThresholdMet",c.id),className:(0,y.cn)("rounded-md border px-3 py-2 text-left transition",a.onThresholdMet===c.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,d.jsx)("div",{className:"text-xs font-medium",children:c.label})},c.id))})]}),(0,d.jsxs)("div",{className:"mb-4",children:[(0,d.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Max revise rounds (per phase)"}),(0,d.jsx)("span",{className:"font-mono text-xs text-foreground",children:a.maxRounds})]}),(0,d.jsx)("input",{type:"range",min:1,max:5,step:1,value:a.maxRounds,onChange:a=>b("maxRounds",parseInt(a.target.value,10)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-muted accent-primary"})]}),(0,d.jsxs)("button",{type:"button",onClick:()=>b("yoloDefault",!a.yoloDefault),className:(0,y.cn)("flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition",a.yoloDefault?"border-rose-500/40 bg-rose-500/5":"border-border bg-card hover:border-foreground/30"),children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{className:"text-xs font-medium text-foreground",children:"\uD83D\uDE80 Yolo by default"}),(0,d.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Auto-approve every gate. Only flip on for trusted templates or trivial fixes. Cost cap still enforced."})]}),(0,d.jsx)("span",{className:(0,y.cn)("flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition",a.yoloDefault?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"),children:(0,d.jsx)("span",{className:(0,y.cn)("h-3.5 w-3.5 rounded-full transition-transform",a.yoloDefault?"translate-x-4 bg-rose-400":"bg-muted-foreground/50")})})]})]})}function aG(a,b){let c=[];if(1===a)b.name&&0!==b.name.trim().length?b.name.length>80&&c.push("Name is too long (max 80 chars)."):c.push("Name is required."),b.description&&0!==b.description.trim().length||c.push("Description is required — one line on when to use this template.");else if(2===a)for(let a of(0===b.phases.length&&c.push("At least one phase is required."),b.phases))a.id&&0!==a.id.trim().length||c.push(`Phase "${a.name||"(unnamed)"}" needs an id.`),"review_only"===a.kind||a.doer.lineage&&0!==a.doer.models.length||c.push(`Phase "${a.name||a.id}" needs a doer lineage + model.`),0===a.reviewer.candidates.length&&c.push(`Phase "${a.name||a.id}" needs at least one reviewer.`);return c}function aH({form:a,setField:b}){let[c,f]=(0,e.useState)(1),[g,h]=(0,e.useState)(!1),i=aG(c,a),j=0===i.length;return(0,d.jsxs)("div",{className:"flex h-full flex-col px-6 py-6",children:[(0,d.jsx)(aI,{currentStep:c,onJump:b=>{if(b<=c){h(!1),f(b);return}for(let d=c;d<b;d++)if(aG(d,a).length>0)return void h(!0);h(!1),f(b)},form:a}),(0,d.jsxs)("div",{className:"mt-6 flex-1 space-y-6",children:[1===c&&(0,d.jsx)(aC,{form:a,setField:b,showErrors:g}),2===c&&(0,d.jsx)(aJ,{form:a,setField:b,showErrors:g}),3===c&&(0,d.jsx)(aD,{form:a,setField:b}),4===c&&(0,d.jsx)(aF,{form:a,setField:b})]}),g&&i.length>0&&(0,d.jsxs)("div",{className:"mt-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[(0,d.jsx)("div",{className:"mb-1 font-medium",children:"Resolve these to continue:"}),(0,d.jsx)("ul",{className:"space-y-0.5 pl-4",children:i.map(a=>(0,d.jsx)("li",{className:"list-disc",children:a},a))})]}),(0,d.jsxs)("div",{className:"mt-6 flex items-center justify-between border-t border-border pt-4",children:[(0,d.jsxs)("button",{type:"button",onClick:()=>{h(!1),c>1&&f(c-1)},disabled:1===c,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[(0,d.jsx)(P,{className:"h-3.5 w-3.5"}),"Back"]}),(0,d.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Step ",c," of 4 \xb7 ",L[c-1].label]}),c<4?(0,d.jsxs)("button",{type:"button",onClick:()=>{j?(h(!1),c<4&&f(c+1)):h(!0)},className:(0,y.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium shadow-sm transition",j?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-muted text-muted-foreground/60"),children:["Next",(0,d.jsx)(Q,{className:"h-3.5 w-3.5"})]}):(0,d.jsxs)("span",{className:"text-[11px] text-emerald-300",children:[(0,d.jsx)(s.A,{className:"mr-1 inline-block h-3 w-3"}),"Save in the footer below"]})]})]})}function aI({currentStep:a,onJump:b,form:c}){return(0,d.jsx)("div",{className:"flex items-stretch gap-2",children:L.map(e=>{let f=e.icon,g=e.id===a,h=0===aG(e.id,c).length,i=e.id<a;return(0,d.jsxs)("button",{type:"button",onClick:()=>b(e.id),className:(0,y.cn)("flex flex-1 items-center gap-2 rounded-md border px-3 py-2 text-left transition",g?"border-primary/60 bg-primary/10":i&&!h?"border-destructive/40 bg-destructive/5":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,d.jsx)("span",{className:(0,y.cn)("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-mono",g?"bg-primary text-primary-foreground":i&&h?"bg-emerald-500/20 text-emerald-300":i&&!h?"bg-destructive/20 text-destructive":"bg-muted text-muted-foreground"),children:i&&h?"✓":e.id}),(0,d.jsx)(f,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,d.jsx)("span",{className:"hidden text-xs font-medium sm:inline",children:e.label})]},e.id)})})}function aJ({form:a,setField:b,showErrors:c}){let e=aG(2,a);return(0,d.jsxs)(d.Fragment,{children:[c&&e.length>0&&(0,d.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:e[0]}),(0,d.jsx)(ay,{phases:a.phases,onChange:a=>b("phases",a)})]})}function aK(a){return Array.isArray(a)?a.flatMap(a=>{let b=F[a.lineage??""]??"claude",c=(a.models??[]).filter(a=>"string"==typeof a&&a.trim().length>0);return 0===c.length?[]:c.map(c=>({lineage:b,model:c,...a.persona?{persona:a.persona}:{}}))}):[]}let aL=["plan","spec","tests","implement","review","verify","divergence","review_only"];function aM(a,b){let c,d,e,f,g=[];try{c=v.parse(a)??{}}catch{return{form:{...H,id:b},formLossy:!0,lossyReasons:["YAML failed to parse — only YAML mode is available."]}}c.ship?.enabled&&g.push("Template has `ship.enabled: true` — form mode can't edit ship config.");let h=[];for(let a of c.phases??[]){let{phase:b,reasons:c}=function(a){let b=[];void 0!==a.timeoutMs&&b.push(`Phase ${a.id??"?"} has \`timeoutMs\` — not exposed in form mode.`);let c="review_only"===a.kind,d=c?"claude":F[a.doer?.lineage??""]??"claude",e={},f={},g=new Set,h=[],i=[];for(let b of a.reviewer?.candidates??[]){let a=F[b.lineage??""];if(!a)continue;g.has(a)||(g.add(a),h.push(a));let c=(b.models??[]).map(a=>(a??"").trim()).filter(a=>a.length>0),d=b.persona&&b.persona.trim().length>0?b.persona:void 0,j=b=>{if(!d)return;let c=f[a]??={},e=c[b];void 0!==e&&e!==d&&i.push(`${a}/${b||"(no model)"}: "${e}" vs "${d}"`),c[b]=d};if(0===c.length)j("");else for(let b of c)(e[a]??=[]).push(b),j(b)}i.length>0&&b.push(`Phase ${a.id??"?"} has overlapping reviewer candidates with conflicting personas (${i.join("; ")}) — form mode would silently last-write-wins; edit in YAML to disambiguate.`);let j=aL.includes(a.kind)?a.kind:"review";return a.kind&&!aL.includes(a.kind)&&b.push(`Phase ${a.id??"?"} has unknown kind \`${a.kind}\` — form mode would coerce it to \`review\`.`),{phase:{id:a.id??"phase",name:a.title??a.name??a.id??"Phase",description:a.description??"",kind:j,gate:"auto",doer:{lineage:d,models:a.doer?.models&&a.doer.models.length>0?a.doer.models:[G[d]??"claude-opus-4-7"],...a.doer?.persona&&a.doer.persona.trim().length>0?{persona:a.doer.persona.trim()}:{}},reviewer:{require:a.reviewer?.require??1,crossLineage:a.reviewer?.crossLineage??!0,candidates:h,candidateModels:e,...Object.keys(f).length>0?{candidatePersonas:f}:{}},inputs:{include:a.inputs?.include??[],exclude:a.inputs?.exclude??[]},iterate:{max:a.iterate?.maxRounds??2,onMax:(a.iterate?.onDisagreement??"continue")==="continue"?"loopback":a.iterate?.onDisagreement==="accept-doer"?"fail":"ask-user"},blindSpots:[],execution:"parallel",builtin:!1,...c&&a.artifact?{artifact:{label:a.artifact.label??"Artifact to review",hint:a.artifact.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:a.artifact.maxBytes??1048576}}:c?{artifact:{label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}}:{}},reasons:b}}(a);h.push(b),g.push(...c)}if("number"==typeof c.agreementThreshold){var i;d=(i=c.agreementThreshold)>=.99?"unanimous":i>=.5?"majority":"any",new Set([1,.66,.34]).has(c.agreementThreshold)||(e=c.agreementThreshold,g.push(`Custom \`agreementThreshold: ${c.agreementThreshold}\` — form mode only offers 1.0 / 0.66 / 0.34 presets.`))}else d=c.agreementThreshold??"majority";let j="review"===c.onThresholdMet?"review":void 0;return"review"===j&&g.push("`onThresholdMet: review` — form mode only offers auto-finalize / ask-user."),{form:{id:c.id??b,name:c.name??"",description:c.description??"",author:c.author??"chorus",category:(f=(c.id??b).toLowerCase()).includes("bug")||f.includes("debug")||f.includes("diagnose")?"debug":f.includes("plan")||f.includes("architect")?"plan":f.includes("decide")||f.includes("decision")?"decide":"review",phases:h.length>0?h:H.phases,threshold:d,...void 0!==e?{customThreshold:e}:{},onThresholdMet:"merge"===c.onThresholdMet?"auto-finalize":"ask-user",...j?{onThresholdMetRaw:j}:{},maxRounds:c.maxRounds??3,yoloDefault:c.yoloDefault??!1,fallbackDoer:aK(c.fallback?.doer),fallbackReviewer:aK(c.fallback?.reviewer)},formLossy:g.length>0,lossyReasons:g}}function aN({yaml:a,filename:b,issues:c,onChange:e}){return(0,d.jsxs)("div",{className:"flex h-full min-h-[400px] flex-col",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-card/40 px-6 py-2.5",children:[(0,d.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:b}),(0,d.jsx)(aO,{issues:c})]}),(0,d.jsx)("textarea",{value:a,onChange:a=>e(a.target.value),spellCheck:!1,className:"flex-1 resize-none border-0 bg-background px-6 py-4 font-mono text-[12px] leading-relaxed text-foreground focus:outline-none"}),c.length>0&&(0,d.jsx)("ul",{className:"border-t border-border bg-destructive/5 px-6 py-2.5 text-[11px] text-destructive",children:c.map((a,b)=>(0,d.jsxs)("li",{className:"flex items-start gap-1.5 leading-snug",children:[(0,d.jsx)(r.A,{className:"mt-[1px] h-3 w-3 shrink-0"}),(0,d.jsxs)("span",{children:[(0,d.jsx)("span",{className:"font-mono",children:a.path}),"number"==typeof a.line&&` (line ${a.line})`,": ",a.message]})]},b))})]})}function aO({issues:a}){return 0===a.length?(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:[(0,d.jsx)(s.A,{className:"h-3 w-3"}),"Valid"]}):(0,d.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:[(0,d.jsx)(r.A,{className:"h-3 w-3"}),a.length," ",1===a.length?"issue":"issues"]})}function aP({editing:a,trigger:b,onSaved:c}){var h;let[i,j]=(0,e.useState)(!1),k=!!a,l=(0,e.useMemo)(()=>{if(!a)return{form:H,yaml:O(H),lossy:!1,reasons:[]};let b=aM(a.yaml,a.id);return{form:b.form,yaml:a.yaml,lossy:b.formLossy,reasons:b.lossyReasons}},[a?.id,a?.yaml]),[m,z]=(0,e.useState)(l.form),[A,B]=(0,e.useState)(l.yaml),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,I]=(0,e.useState)(l.lossy?"yaml":"form"),[J,K]=(0,e.useState)(!1),[L,M]=(0,e.useState)(null),[P,Q]=(0,e.useState)([]),R=(0,e.useRef)(l),S=(h={yamlDirty:C,tab:G,formDirty:E,yamlText:A,formYaml:O(m),initialYaml:l.yaml}).yamlDirty||"yaml"===h.tab?h.yamlText:h.formDirty?h.formYaml:h.initialYaml,T=(0,e.useMemo)(()=>(function(a){let b;if(0===a.trim().length)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML is empty."}]};try{b=v.parse(a)}catch(c){let a=c instanceof Error?c.message:String(c),b=c.linePos?.[0];return{valid:!1,issues:[{path:"<yaml>",message:a,...b?{line:b.line,col:b.col}:{}}]}}if(null==b)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML parsed to null — at minimum it must define id, name, and phases."}]};let c=w._i.safeParse(b);return c.success?x:{valid:!1,issues:c.error.issues.map(a=>({path:a.path.length>0?a.path.join("."):"<root>",message:a.message}))}})(S),[S]);function U(a){if("form"===a&&C){let a=aM(A,m.id);if(a.formLossy)return;z(a.form),D(!1),F(!0)}I(a)}function V(){let a=R.current;z(a.form),B(a.yaml),D(!1),F(!1),I(a.lossy?"yaml":"form"),K(!1),M(null),Q([])}function W(a){j(a),a||setTimeout(V,200)}async function X(){if(!T.valid||J)return;let b=k?a.id:m.id||N(m.name)||"untitled";K(!0),M(null),Q([]);try{let a=await (0,u.AI)({id:b,yaml:S});c?.(a.id),W(!1)}catch(a){a instanceof u.$v?(M(a.message),Q(a.details?.issues??[])):M(a instanceof Error?a.message:"Save failed (unknown error)")}finally{K(!1)}}let Y=T.valid&&!J,Z=b??(0,d.jsxs)("button",{type:"button","aria-label":k?"Edit template":"New template",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90",children:[k?(0,d.jsx)(f.A,{className:"h-4 w-4"}):(0,d.jsx)(n.A,{className:"h-4 w-4"}),(0,d.jsx)("span",{className:"hidden sm:inline",children:k?"Edit":"New template"})]});return(0,d.jsxs)(t.lG,{open:i,onOpenChange:W,children:[(0,d.jsx)(t.zM,{asChild:!0,children:Z}),(0,d.jsxs)(t.Cf,{showCloseButton:!1,className:"flex max-h-[85vh] w-[min(96vw,720px)] flex-col gap-0 overflow-hidden border-border bg-card p-0 shadow-2xl sm:max-w-none",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-6 py-4",children:[(0,d.jsx)("div",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-md bg-primary/15 text-primary ring-1 ring-primary/20",children:(0,d.jsx)(o.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)(t.L3,{className:"text-[15px] font-semibold leading-tight tracking-tight",children:k?`Edit template — ${a.name}`:"New template"}),(0,d.jsx)(t.rr,{className:"mt-0.5 text-xs text-muted-foreground",children:k?"Edit the YAML directly or use the form. Validation runs live.":"A reusable review workflow. Edit visually below or paste raw YAML."})]}),(0,d.jsx)("button",{type:"button",onClick:()=>W(!1),className:"grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition hover:bg-accent hover:text-foreground","aria-label":"Close",children:(0,d.jsx)(p.A,{className:"h-4 w-4"})})]}),(0,d.jsx)("div",{className:"border-b border-border bg-card/40 px-6",children:(0,d.jsxs)("div",{className:"-mb-px flex items-center gap-1",children:[(0,d.jsxs)(az,{active:"form"===G,onClick:()=>!l.lossy&&U("form"),disabled:l.lossy,children:[(0,d.jsx)(q.A,{className:"h-3.5 w-3.5"}),"Form",l.lossy&&(0,d.jsx)("span",{className:"ml-1 rounded bg-muted px-1 text-[9px] font-medium text-muted-foreground",children:"YAML only"})]}),(0,d.jsxs)(az,{active:"yaml"===G,onClick:()=>U("yaml"),children:[(0,d.jsx)(o.A,{className:"h-3.5 w-3.5"}),"YAML",!T.valid&&"form"===G&&(0,d.jsx)("span",{className:"ml-1 h-1.5 w-1.5 rounded-full bg-destructive"})]})]})}),(0,d.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[l.lossy&&"yaml"===G&&(0,d.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/5 px-6 py-2.5 text-[11px] text-amber-200",children:(0,d.jsxs)("div",{className:"flex items-start gap-2",children:[(0,d.jsx)(r.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-medium",children:"Form editing disabled for this template"}),(0,d.jsx)("ul",{className:"mt-1 space-y-0.5 leading-snug",children:l.reasons.map((a,b)=>(0,d.jsxs)("li",{children:["\xb7 ",a]},b))})]})]})}),"form"===G?(0,d.jsx)(aH,{form:m,setField:function(a,b){let c={...m,[a]:b};z(c),F(!0),C||B(O(c))}}):(0,d.jsx)(aN,{yaml:A,filename:`${m.id||N(m.name)||"untitled"}.yaml`,issues:T.issues,onChange:a=>{B(a),D(!0)}})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border bg-card/40 px-6 py-3",children:[L&&(0,d.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:(0,d.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,d.jsx)(r.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("div",{className:"font-medium",children:"Save failed"}),(0,d.jsx)("div",{className:"mt-0.5 leading-snug",children:L}),P.length>0&&(0,d.jsx)("ul",{className:"mt-1 space-y-0.5",children:P.slice(0,5).map((a,b)=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"font-mono",children:a.path}),":"," ",a.message]},b))})]})]})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,d.jsx)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:T.valid?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(s.A,{className:"h-3 w-3 text-emerald-400"}),(0,d.jsx)("span",{children:"Ready to save"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(r.A,{className:"h-3 w-3 text-destructive/80"}),(0,d.jsxs)("span",{children:[T.issues.length," ",1===T.issues.length?"issue":"issues"," to resolve"]})]})}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{type:"button",onClick:()=>W(!1),className:"h-9 rounded-md border border-border bg-card px-4 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground",children:"Cancel"}),(0,d.jsxs)("button",{type:"button",disabled:!Y,onClick:X,className:(0,y.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-4 text-sm font-medium shadow-sm transition",Y?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-muted text-muted-foreground/60 shadow-none"),children:[J&&(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}),J?"Saving…":k?"Save changes":"Save template"]})]})]})]})]})]})}let aQ=Object.fromEntries(Object.entries(Y.r2).map(([a,b])=>[a,b.dot])),aR=[{id:"all",label:"All"},{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}];function aS(){let[a,b]=(0,e.useState)([]),[c,n]=(0,e.useState)(null),[o,p]=(0,e.useState)("all"),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(null),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(null),z=(0,e.useCallback)(async a=>{try{let c=await (0,u.eG)();b(c),a&&c.find(b=>b.id===a)?r(a):c.length>0&&!q&&r(c[0].id)}catch(a){n(a instanceof u.$v?a.message:"Failed to load templates")}},[q]);async function A(a){if(!v&&"builtin"!==a.source){if(s!==a.id){t(a.id),y(null),setTimeout(()=>{t(b=>b===a.id?null:b)},8e3);return}w(a.id),y(null);try{await (0,u.I7)(a.id),t(null),q===a.id&&r(""),await z()}catch(a){y(a instanceof u.$v||a instanceof Error?a.message:"Delete failed (unknown error)"),t(null)}finally{w(null)}}}let B="all"===o?a:a.filter(a=>a.category===o),C=a.find(a=>a.id===q)??a[0]??null;return c?(0,d.jsx)(i.G,{children:(0,d.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,d.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,d.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:c})]})})}):(0,d.jsx)(i.G,{children:(0,d.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,d.jsx)(l.z,{eyebrow:"Templates",title:"Reusable review workflows",subtitle:"Each template defines the driver, reviewers, prompts, and quorum rule for a kind of task. Fork, edit, share.",action:(0,d.jsx)(aP,{onSaved:a=>z(a)})}),x&&(0,d.jsx)("div",{className:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:x}),(0,d.jsx)("div",{className:"mb-4 flex items-center gap-1 border-b border-border",children:aR.map(a=>(0,d.jsxs)("button",{type:"button",onClick:()=>p(a.id),className:`relative px-3 py-2 text-sm transition ${a.id===o?"text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[a.label,a.id===o&&(0,d.jsx)("span",{className:"absolute inset-x-3 bottom-0 h-0.5 bg-primary"})]},a.id))}),(0,d.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1fr_1fr]",children:[(0,d.jsx)("div",{className:"flex min-w-0 flex-col gap-2",children:B.map(a=>(0,d.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>r(a.id),onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),r(a.id))},className:`group relative cursor-pointer rounded-xl text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${a.id===q?"ring-2 ring-primary/60 ring-offset-2 ring-offset-background":""}`,children:[(0,d.jsxs)(j.Zp,{className:"bg-card p-4 transition group-hover:border-muted-foreground/30",children:[(0,d.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,d.jsx)("span",{className:"text-sm font-semibold",children:a.name}),(0,d.jsx)(k.E,{variant:"outline",className:"border-border text-[10px] capitalize",children:a.category}),!1===a.isComplete&&(0,d.jsx)(k.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:!1===a.isComplete?"Some slots couldn't be filled from your installed CLIs. Edit the YAML to pick models for each slot.":a.description})]})}),a.phases[0]?.reviewer?.candidates.length?(0,d.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[a.phases[0]?.kind!=="review_only"&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[(0,d.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"doer"]}),(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"→"})]}),(0,d.jsxs)("span",{className:"flex items-center gap-1",children:[a.phases[0]?.reviewer?.candidates.map(a=>(0,d.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${aQ[a]}`,title:a},a)),(0,d.jsxs)("span",{children:[a.phases[0]?.reviewer?.candidates.length," ",a.phases[0]?.reviewer?.candidates.length===1?"reviewer":"reviewers"]})]}),a.phases.length>1&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,d.jsxs)("span",{className:"font-mono text-[10px]",children:[a.phases.length," phases"]})]})]}):null]}),(0,d.jsxs)("div",{className:`absolute bottom-3 right-3 flex items-center gap-1.5 transition ${a.id===q?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,onClick:b=>{b.stopPropagation(),r(a.id)},onKeyDown:a=>a.stopPropagation(),children:[(0,d.jsx)(aP,{editing:a,onSaved:a=>z(a),trigger:(0,d.jsx)("button",{type:"button","aria-label":`Edit ${a.name}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-muted-foreground/40 hover:bg-accent/60 hover:text-foreground",children:(0,d.jsx)(f.A,{className:"h-3.5 w-3.5"})})}),"builtin"!==a.source&&(0,d.jsx)("button",{type:"button","aria-label":s===a.id?`Confirm delete ${a.name}`:`Delete ${a.name}`,title:s===a.id?"Click again to confirm":"Delete",disabled:v===a.id,onClick:()=>A(a),className:`grid h-7 w-7 place-items-center rounded-md border transition disabled:cursor-not-allowed disabled:opacity-50 ${s===a.id?"border-destructive bg-destructive/15 text-destructive":"border-border bg-card text-muted-foreground hover:border-destructive/50 hover:text-destructive"}`,children:v===a.id?(0,d.jsx)(g.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,d.jsx)(h.A,{className:"h-3.5 w-3.5"})})]})]},a.id))}),C?(0,d.jsx)("div",{className:"lg:sticky lg:top-6 lg:max-h-[calc(100vh-10rem)] lg:h-[calc(100vh-10rem)]",children:(0,d.jsx)(m.N,{filename:`${C.id}.yaml`,charCount:C.yaml.length,maxHeightClassName:"h-full",footer:(0,d.jsxs)("span",{children:["by ",C.authorHandle]}),children:C.yaml})}):(0,d.jsx)(j.Zp,{className:"bg-card p-4 text-center text-muted-foreground",children:(0,d.jsx)("p",{children:"Select a template to view details"})})]})]})})}},41025:a=>{"use strict";a.exports=require("next/dist/server/app-render/dynamic-access-async-storage.external.js")},41970:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("test-tube-diagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]])},43954:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/interception-routes")},45036:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>d});let d=(0,c(96600).registerClientReference)(function(){throw Error("Attempted to call the default export of \"/home/ubuntu/dev/chorus/src/app/templates/page.tsx\" from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/ubuntu/dev/chorus/src/app/templates/page.tsx","default")},46728:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]])},50133:(a,b,c)=>{"use strict";c.d(b,{Zp:()=>f});var d=c(66722);c(31131);var e=c(16276);function f({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"card",className:(0,e.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",a),...b})}},63033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},68598:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},70722:a=>{"use strict";a.exports=require("next/dist/shared/lib/invariant-error")},72069:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},75619:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("git-pull-request",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]])},77068:a=>{"use strict";a.exports=require("next/dist/shared/lib/size-limit")},79428:a=>{"use strict";a.exports=require("buffer")},80282:(a,b,c)=>{"use strict";c.d(b,{G:()=>g});var d=c(66722),e=c(24188),f=c(86095);function g({children:a}){return(0,d.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,d.jsx)(e.AppSidebar,{}),(0,d.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,d.jsx)(f.MobileTopBar,{}),(0,d.jsx)("main",{className:"flex-1 overflow-y-auto",children:a})]})]})}},83720:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]])},86439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")},91458:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]])},91887:(a,b,c)=>{"use strict";c.d(b,{z:()=>e});var d=c(66722);function e({eyebrow:a,title:b,subtitle:c,action:f}){return(0,d.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,d.jsxs)("div",{className:"min-w-0",children:[(0,d.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:a}),(0,d.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:b}),c&&(0,d.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:c})]}),f&&(0,d.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:f})]})}},94248:(a,b,c)=>{Promise.resolve().then(c.bind(c,36500))},95099:(a,b,c)=>{"use strict";c.d(b,{A:()=>d});let d=(0,c(52449).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},98947:(a,b,c)=>{"use strict";c.r(b),c.d(b,{__next_app__:()=>M,handler:()=>O,routeModule:()=>N});var d=c(15828),e=c(97067),f=c(38261),g=c(94322),h=c(64428),i=c(85126),j=c(48669),k=c(98846),l=c(6916),m=c(9958),n=c(50248),o=c(414),p=c(90667),q=c(261),r=c(8399),s=c(47796),t=c(26713),u=c(53846),v=c(65275),w=c(17695),x=c(33608),y=c(67040),z=c(54908),A=c(74840),B=c(86439),C=c(77068),D=c(72308),E=c(71708),F=c(91957),G=c(70722),H=c(4804),I=c(43954),J=c(17891),K={};for(let a in E)0>["default","__next_app__","routeModule","handler"].indexOf(a)&&(K[a]=()=>E[a]);c.d(b,K);let L={children:["",{children:["templates",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(c.bind(c,45036)),"/home/ubuntu/dev/chorus/src/app/templates/page.tsx"]}]},{"global-error":[()=>Promise.resolve().then(c.t.bind(c,10312,23)),"next/dist/client/components/builtin/global-error.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,11305))).default(a),async a=>(await Promise.resolve().then(c.bind(c,89796))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]},{layout:[()=>Promise.resolve().then(c.bind(c,65979)),"/home/ubuntu/dev/chorus/src/app/layout.tsx"],"global-error":[()=>Promise.resolve().then(c.t.bind(c,10312,23)),"next/dist/client/components/builtin/global-error.js"],"not-found":[()=>Promise.resolve().then(c.t.bind(c,43790,23)),"next/dist/client/components/builtin/not-found.js"],forbidden:[()=>Promise.resolve().then(c.t.bind(c,27431,23)),"next/dist/client/components/builtin/forbidden.js"],unauthorized:[()=>Promise.resolve().then(c.t.bind(c,6906,23)),"next/dist/client/components/builtin/unauthorized.js"],metadata:{icon:[async a=>(await Promise.resolve().then(c.bind(c,11305))).default(a),async a=>(await Promise.resolve().then(c.bind(c,89796))).default(a)],apple:[],openGraph:[],twitter:[],manifest:void 0}},[]]}.children,M={require:c,loadChunk:()=>Promise.resolve()},N=new d.AppPageRouteModule({definition:{kind:e.RouteKind.APP_PAGE,page:"/templates/page",pathname:"/templates",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:L},distDir:".next",relativeProjectDir:""});async function O(a,b,d){var K,P,Q,R,S;d.requestMeta&&(0,h.setRequestMeta)(a,d.requestMeta),N.isDev&&(0,h.addRequestMeta)(a,"devRequestTimingInternalsEnd",process.hrtime.bigint());let T=!!(0,h.getRequestMeta)(a,"minimalMode"),U="/templates/page";"/index"===U&&(U="/");let V=await N.prepare(a,b,{srcPage:U,multiZoneDraftMode:!1});if(!V)return b.statusCode=400,b.end("Bad Request"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let{buildId:W,query:X,params:Y,pageIsDynamic:Z,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,serverActionsManifest:ab,clientReferenceManifest:ac,subresourceIntegrityManifest:ad,prerenderManifest:ae,isDraftMode:af,resolvedPathname:ag,revalidateOnlyGenerated:ah,routerServerContext:ai,nextConfig:aj,parsedUrl:ak,interceptionRoutePatterns:al,deploymentId:am,clientAssetToken:an}=V,ao=(0,q.normalizeAppPath)(U),{isOnDemandRevalidate:ap}=V,aq=aj.experimental.ppr&&!aj.cacheComponents&&(0,I.isInterceptionRouteAppPath)(ag)?null:N.match(ag,ae),ar=(null==aq?void 0:aq.route)??null,as=!!ae.routes[ag],at=a.headers["user-agent"]||"",au=(0,t.getBotType)(at),av=(0,p.isHtmlBotRequest)(a),aw=(0,h.getRequestMeta)(a,"isPrefetchRSCRequest")??"1"===a.headers[s.NEXT_ROUTER_PREFETCH_HEADER],ax=(0,h.getRequestMeta)(a,"isRSCRequest")??!!a.headers[s.RSC_HEADER],ay=(0,r.getIsPossibleServerAction)(a),az=(0,m.checkIsAppPPREnabled)(aj.experimental.ppr),aA=a.headers[x.NEXT_RESUME_STATE_LENGTH_HEADER];if(!(0,h.getRequestMeta)(a,"postponed")&&T&&az&&ay&&aA&&"string"==typeof aA){let e=parseInt(aA,10),{maxPostponedStateSize:f,maxPostponedStateSizeBytes:g}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize);if(!isNaN(e)&&e>0){if(e>g)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(f)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let i="1 MB",j=(null==(S=aj.experimental.serverActions)?void 0:S.bodySizeLimit)??i,k=e+(j!==i?c(58965).parse(j):1048576),l=await (0,D.readBodyWithSizeLimit)(a,k);if(null===l)return b.statusCode=413,b.end("Request body exceeded limit. To configure the body size limit for Server Actions, see: https://nextjs.org/docs/app/api-reference/next-config-js/serverActions#bodysizelimit"),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;if(l.length>=e){let b=l.subarray(0,e).toString("utf8");(0,h.addRequestMeta)(a,"postponed",b);let c=l.subarray(e);(0,h.addRequestMeta)(a,"actionBody",c)}else throw Object.defineProperty(Error(`invariant: expected ${e} bytes of postponed state but only received ${l.length} bytes`),"__NEXT_ERROR_CODE",{value:"E979",enumerable:!1,configurable:!0})}}if(!(0,h.getRequestMeta)(a,"postponed")&&az&&"1"===a.headers[x.NEXT_RESUME_HEADER]&&"POST"===a.method){let{maxPostponedStateSize:c,maxPostponedStateSizeBytes:e}=(0,D.getMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize),f=await (0,D.readBodyWithSizeLimit)(a,e);if(null===f)return b.statusCode=413,b.end((0,D.getPostponedStateExceededErrorMessage)(c)),null==d.waitUntil||d.waitUntil.call(d,Promise.resolve()),null;let g=f.toString("utf8");(0,h.addRequestMeta)(a,"postponed",g)}let aB=!0===N.isDev||!0===aj.experimental.exposeTestingApiInProductionBuild,aC=aB&&("1"===a.headers[s.NEXT_INSTANT_PREFETCH_HEADER]||void 0===a.headers[s.RSC_HEADER]&&"string"==typeof a.headers.cookie&&a.headers.cookie.includes(s.NEXT_INSTANT_TEST_COOKIE+"=")),aD=(az||aC)&&((null==(K=ae.routes[ao]??ae.dynamicRoutes[ao])?void 0:K.renderingMode)==="PARTIALLY_STATIC"||aC&&(aB||(null==ai?void 0:ai.experimentalTestProxy)===!0)),aE=aC&&aD,aF=aE&&!0===N.isDev,aG=!1,aH=aD?(0,h.getRequestMeta)(a,"postponed"):void 0,aI=null==(P=ae.routes[ag])?void 0:P.prefetchDataRoute,aJ=aD&&ax&&!aw&&!aI;T&&(aJ=aJ&&!!aH);let aK=(0,h.getRequestMeta)(a,"segmentPrefetchRSCRequest"),aL=(!au||!aD)&&(!at||(0,p.shouldServeStreamingMetadata)(at,aj.htmlLimitedBots)),aM=!!((ar||as||ae.routes[ao])&&!(au&&aD)),aN=aD&&!0===aj.cacheComponents,aO=!0===N.isDev||!aM||"string"==typeof aH||(aN&&(0,h.getRequestMeta)(a,"onCacheEntryV2")?aJ&&!T:aJ),aP=!!au&&aD,aQ=(null==ar?void 0:ar.remainingPrerenderableParams)??[],aR=(null==ar?void 0:ar.fallback)===null&&((null==(Q=ar.fallbackRootParams)?void 0:Q.length)??0)>0,aS=null;if(!af&&aM&&!aO&&!ay&&!aH&&!aJ){let a=aq?"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:aq.source:null;if(!0===aj.experimental.partialFallbacks&&a&&(null==ar?void 0:ar.fallbackRouteParams)&&!aR){if(aQ.length>0){let b,c=(b=new Map(aQ.map(a=>[a.paramName,a])),a.split("/").map(a=>{let c=(0,J.getSegmentParam)(a);if(!c)return a;let d=b.get(c.paramName);if(!d)return a;let e=null==Y?void 0:Y[d.paramName];if(!e)return a;let f=Array.isArray(e)?e.map(a=>encodeURIComponent(a)).join("/"):encodeURIComponent(e);return a.replace(function(a){let{repeat:b,optional:c}=(0,J.getParamProperties)(a.paramType);return c?`[[...${a.paramName}]]`:b?`[...${a.paramName}]`:`[${a.paramName}]`}(d),f)}).join("/")||"/");aS=c!==a?c:null}}else aS=ag}let aT=aS;!aT&&(N.isDev||aM&&Z&&(null==ar?void 0:ar.fallbackRouteParams)&&!ay)&&(aT=ag),N.isDev||af||!aM||!ax||aJ||(0,k.d)(a.headers);let aU={...E,tree:L,handler:O,routeModule:N,__next_app__:M};ab&&ac&&(0,o.setManifestsSingleton)({page:U,clientReferenceManifest:ac,serverActionsManifest:ab});let aV=a.method||"GET",aW=(0,g.getTracer)(),aX=aW.getActiveScopeSpan(),aY=!!(null==ai?void 0:ai.isWrappedByNextServer),aZ=!0===aj.experimental.partialFallbacks&&aQ.length>0?(null==ar||null==(R=ar.fallbackRouteParams)?void 0:R.filter(a=>!aQ.some(b=>b.paramName===a.paramName)))??[]:[],a$=async()=>((null==ai?void 0:ai.render404)?await ai.render404(a,b,ak,!1):b.end("This page could not be found"),null);try{let k,m=N.getVaryHeader(ag,al);b.setHeader("Vary",m);let o=async(c,d)=>{let e=new l.NodeNextRequest(a),f=new l.NodeNextResponse(b);return N.render(e,f,d).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let a=aW.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==i.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let d=a.get("next.route");if(d){let a=`${aV} ${d}`;c.setAttributes({"next.route":d,"http.route":d,"next.span_name":a}),c.updateName(a),k&&k!==c&&(k.setAttribute("http.route",d),k.updateName(a))}else c.updateName(`${aV} ${U}`)})},p=(0,h.getRequestMeta)(a,"incrementalCache")||await N.getIncrementalCache(a,aj,ae,T);null==p||p.resetRequestCache(),globalThis.__incrementalCache=p;let q=async({span:e,postponed:f,fallbackRouteParams:g,forceStaticRender:i})=>{let k={query:X,params:Y,page:ao,sharedContext:{buildId:W,deploymentId:am,clientAssetToken:an},serverComponentsHmrCache:(0,h.getRequestMeta)(a,"serverComponentsHmrCache"),fallbackRouteParams:g,renderOpts:{App:()=>null,Document:()=>null,pageConfig:{},ComponentMod:aU,Component:(0,j.T)(aU),params:Y,routeModule:N,page:U,postponed:f,shouldWaitOnAllReady:aP,serveStreamingMetadata:aL,supportsDynamicResponse:"string"==typeof f||aO,buildManifest:$,nextFontManifest:_,reactLoadableManifest:aa,subresourceIntegrityManifest:ad,setCacheStatus:null==ai?void 0:ai.setCacheStatus,setIsrStatus:null==ai?void 0:ai.setIsrStatus,setReactDebugChannel:null==ai?void 0:ai.setReactDebugChannel,sendErrorsToBrowser:null==ai?void 0:ai.sendErrorsToBrowser,dir:c(33873).join(process.cwd(),N.relativeProjectDir),isDraftMode:af,botType:au,isOnDemandRevalidate:ap,isPossibleServerAction:ay,assetPrefix:aj.assetPrefix,nextConfigOutput:aj.output,crossOrigin:aj.crossOrigin,trailingSlash:aj.trailingSlash,images:aj.images,previewProps:ae.preview,enableTainting:aj.experimental.taint,htmlLimitedBots:aj.htmlLimitedBots,reactMaxHeadersLength:aj.reactMaxHeadersLength,multiZoneDraftMode:!1,incrementalCache:p,cacheLifeProfiles:aj.cacheLife,basePath:aj.basePath,serverActions:aj.experimental.serverActions,logServerFunctions:"object"==typeof aj.logging&&!!aj.logging.serverFunctions,...aE||aF||aG?{isBuildTimePrerendering:!0,supportsDynamicResponse:!1,isStaticGeneration:!0,isDebugDynamicAccesses:aF}:{},cacheComponents:!!aj.cacheComponents,experimental:{isRoutePPREnabled:aD,expireTime:aj.expireTime,staleTimes:aj.experimental.staleTimes,dynamicOnHover:!!aj.experimental.dynamicOnHover,optimisticRouting:!!aj.experimental.optimisticRouting,inlineCss:!!aj.experimental.inlineCss,prefetchInlining:aj.experimental.prefetchInlining??!1,authInterrupts:!!aj.experimental.authInterrupts,cachedNavigations:!!aj.experimental.cachedNavigations,clientTraceMetadata:aj.experimental.clientTraceMetadata||[],clientParamParsingOrigins:aj.experimental.clientParamParsingOrigins,maxPostponedStateSizeBytes:(0,C.parseMaxPostponedStateSize)(aj.experimental.maxPostponedStateSize)},waitUntil:d.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:()=>{},onInstrumentationRequestError:(b,c,d,e)=>N.onRequestError(a,b,d,e,ai),err:(0,h.getRequestMeta)(a,"invokeError")}};i&&(k.renderOpts.supportsDynamicResponse=!1);let l=await o(e,k),{metadata:m}=l,{cacheControl:n,headers:q={},fetchTags:r,fetchMetrics:s}=m;if(r&&(q[x.NEXT_CACHE_TAGS_HEADER]=r),a.fetchMetrics=s,aM&&(null==n?void 0:n.revalidate)===0&&!N.isDev&&!aD){let a=m.staticBailoutInfo,b=Object.defineProperty(Error(`Page changed from static to dynamic at runtime ${ag}${(null==a?void 0:a.description)?`, reason: ${a.description}`:""}
|
|
2
2
|
see more here https://nextjs.org/docs/messages/app-static-to-dynamic-error`),"__NEXT_ERROR_CODE",{value:"E132",enumerable:!1,configurable:!0});if(null==a?void 0:a.stack){let c=a.stack;b.stack=b.message+c.substring(c.indexOf("\n"))}throw b}return{value:{kind:u.CachedRouteKind.APP_PAGE,html:l,headers:q,rscData:m.flightData,postponed:m.postponed,status:m.statusCode,segmentData:m.segmentData},cacheControl:n}},r=async({hasResolved:c,previousCacheEntry:g,isRevalidating:i,span:j,forceStaticRender:k=!1})=>{let l=!1===N.isDev,m=c||b.writableEnded;try{let f;if(ap&&ah&&!g&&!T)return(null==ai?void 0:ai.render404)?await ai.render404(a,b):(b.statusCode=404,b.end("This page could not be found")),null;if(ar&&(f=(0,v.parseFallbackField)(ar.fallback)),!0===aj.experimental.partialFallbacks&&(null==ar?void 0:ar.fallback)===null&&!aR&&aQ.length>0&&(f=v.FallbackMode.PRERENDER),f===v.FallbackMode.PRERENDER&&(0,t.isBot)(at)&&(!aD||av)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),(null==g?void 0:g.isStale)===-1&&(ap=!0),ap&&(f!==v.FallbackMode.NOT_FOUND||g)&&(f=v.FallbackMode.BLOCKING_STATIC_RENDER),!T&&f!==v.FallbackMode.BLOCKING_STATIC_RENDER&&aT&&!m&&!af&&Z&&(l||!as)){if((l||ar)&&f===v.FallbackMode.NOT_FOUND){if(aj.adapterPath)return await a$();throw new B.NoFallbackError}if(aD&&(aj.cacheComponents?!aJ:!ax)){let b=l&&"string"==typeof(null==ar?void 0:ar.fallback)?ar.fallback:ao,f=(l||aE)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;aE&&f&&(0,h.addRequestMeta)(a,"fallbackParams",f);let g=await N.handleResponse({cacheKey:b,req:a,nextConfig:aj,routeKind:e.RouteKind.APP_PAGE,isFallback:!0,prerenderManifest:ae,isRoutePPREnabled:aD,responseGenerator:async()=>q({span:j,postponed:void 0,fallbackRouteParams:f,forceStaticRender:!0}),waitUntil:d.waitUntil,isMinimalMode:T});if(null===g)return null;if(g)return T||!aD||!(aQ.length>0)||!0!==aj.experimental.partialFallbacks||!aS||!p||ap||aG||aB||aC||aw||(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(aS,p,aD,!1,a=>q({span:a.span,postponed:void 0,fallbackRouteParams:aZ.length>0?(0,n.createOpaqueFallbackRouteParams)(aZ):null,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}),delete g.cacheControl,g}}let o=ap||i||!aH?void 0:aH;if(aN&&!T&&p&&(aJ||ay)&&!k){let b=await p.get(ag,{kind:u.IncrementalCacheKind.APP_PAGE,isRoutePPREnabled:!0,isFallback:!1});b&&b.value&&b.value.kind===u.CachedRouteKind.APP_PAGE&&(o=b.value.postponed,b&&(-1===b.isStale||!0===b.isStale)&&(0,H.scheduleOnNextTick)(async()=>{let b=N.getResponseCache(a);try{await b.revalidate(ag,p,aD,!1,a=>r({...a,forceStaticRender:!0}),null,c,d.waitUntil)}catch(a){console.error("Error revalidating the page in the background",a)}}))}if((aE||aF)&&void 0!==o)return{cacheControl:{revalidate:1,expire:void 0},value:{kind:u.CachedRouteKind.PAGES,html:w.default.EMPTY,pageData:{},headers:void 0,status:void 0}};let s=(l&&(0,h.getRequestMeta)(a,"renderFallbackShell")||aE&&!as)&&(null==ar?void 0:ar.fallbackRouteParams)?(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams):aG?(0,n.getFallbackRouteParams)(ao,N):null;if((l||aE)&&aj.cacheComponents&&!as&&(null==ar?void 0:ar.fallbackRouteParams)){let b=(0,n.createOpaqueFallbackRouteParams)(ar.fallbackRouteParams);b&&(0,h.addRequestMeta)(a,"fallbackParams",b)}return q({span:j,postponed:o,fallbackRouteParams:s,forceStaticRender:k})}catch(b){throw(null==g?void 0:g.isStale)&&await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}},D=async c=>{var f,g,i,j,k;let l,m=await N.handleResponse({cacheKey:aS,responseGenerator:a=>r({span:c,...a}),routeKind:e.RouteKind.APP_PAGE,isOnDemandRevalidate:ap,isRoutePPREnabled:aD,req:a,nextConfig:aj,prerenderManifest:ae,waitUntil:d.waitUntil,isMinimalMode:T});if(af&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate"),N.isDev&&b.setHeader("Cache-Control","no-cache, must-revalidate"),!m){if(aS)throw Object.defineProperty(Error("invariant: cache entry required but not generated"),"__NEXT_ERROR_CODE",{value:"E62",enumerable:!1,configurable:!0});return null}if((null==(f=m.value)?void 0:f.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant app-page handler received invalid cache entry ${null==(i=m.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E707",enumerable:!1,configurable:!0});let n="string"==typeof m.value.postponed;ax&&!ay&&am&&b.setHeader(x.NEXT_NAV_DEPLOYMENT_ID_HEADER,am),aM&&!aJ&&(!n||aw)&&(T||b.setHeader("x-nextjs-cache",ap?"REVALIDATED":m.isMiss?"MISS":m.isStale?"STALE":"HIT"),b.setHeader(s.NEXT_IS_PRERENDER_HEADER,"1"));let{value:o}=m;if(aH)l={revalidate:0,expire:void 0};else if(aJ)l={revalidate:0,expire:void 0};else if(!N.isDev)if(af)l={revalidate:0,expire:void 0};else if(aM){if(m.cacheControl)if("number"==typeof m.cacheControl.revalidate){if(m.cacheControl.revalidate<1)throw Object.defineProperty(Error(`Invalid revalidate configuration provided: ${m.cacheControl.revalidate} < 1`),"__NEXT_ERROR_CODE",{value:"E22",enumerable:!1,configurable:!0});l={revalidate:m.cacheControl.revalidate,expire:(null==(j=m.cacheControl)?void 0:j.expire)??aj.expireTime}}else l={revalidate:x.CACHE_ONE_YEAR_SECONDS,expire:void 0}}else b.getHeader("Cache-Control")||(l={revalidate:0,expire:void 0});if(m.cacheControl=l,"string"==typeof aK&&(null==o?void 0:o.kind)===u.CachedRouteKind.APP_PAGE&&o.segmentData){b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"2");let c=null==(k=o.headers)?void 0:k[x.NEXT_CACHE_TAGS_HEADER];T&&aM&&c&&"string"==typeof c&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,c);let d=o.segmentData.get(aK);return void 0!==d?(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(d,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl}):(b.statusCode=204,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl}))}let p=aN?(0,h.getRequestMeta)(a,"onCacheEntryV2")??(0,h.getRequestMeta)(a,"onCacheEntry"):(0,h.getRequestMeta)(a,"onCacheEntry");if(p&&await p(m,{url:(0,h.getRequestMeta)(a,"initURL")??a.url}))return null;if(o.headers){let a={...o.headers};for(let[c,d]of(T&&aM||delete a[x.NEXT_CACHE_TAGS_HEADER],Object.entries(a)))if(void 0!==d)if(Array.isArray(d))for(let a of d)b.appendHeader(c,a);else"number"==typeof d&&(d=d.toString()),b.appendHeader(c,d)}let t=null==(g=o.headers)?void 0:g[x.NEXT_CACHE_TAGS_HEADER];if(T&&aM&&t&&"string"==typeof t&&b.setHeader(x.NEXT_CACHE_TAGS_HEADER,t),!o.status||ax&&aD||(b.statusCode=o.status),!T&&o.status&&F.RedirectStatusCode[o.status]&&ax&&(b.statusCode=200),n&&!aJ&&b.setHeader(s.NEXT_DID_POSTPONE_HEADER,"1"),ax&&!af){if(void 0===o.rscData){if(o.html.contentType!==s.RSC_CONTENT_TYPE_HEADER)if(aj.cacheComponents)return b.statusCode=404,(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.EMPTY,cacheControl:m.cacheControl});else throw Object.defineProperty(new G.InvariantError(`Expected RSC response, got ${o.html.contentType}`),"__NEXT_ERROR_CODE",{value:"E789",enumerable:!1,configurable:!0});return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:o.html,cacheControl:m.cacheControl})}return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:w.default.fromStatic(o.rscData,s.RSC_CONTENT_TYPE_HEADER),cacheControl:m.cacheControl})}let v=o.html;if(aC&&aE){let c=!0===N.isDev?crypto.randomUUID():null;return v.pipeThrough((0,z.createInstantTestScriptInsertionTransformStream)(c)),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})}if(!n||T||ax)return(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:m.cacheControl});if(aE||aF)return v.push(new ReadableStream({start(a){a.enqueue(y.ENCODED_TAGS.CLOSED.BODY_AND_HTML),a.close()}})),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}});let B=new TransformStream;return v.push(B.readable),q({span:c,postponed:o.postponed,fallbackRouteParams:null,forceStaticRender:!1}).then(async a=>{var b,c;if(!a)throw Object.defineProperty(Error("Invariant: expected a result to be returned"),"__NEXT_ERROR_CODE",{value:"E463",enumerable:!1,configurable:!0});if((null==(b=a.value)?void 0:b.kind)!==u.CachedRouteKind.APP_PAGE)throw Object.defineProperty(Error(`Invariant: expected a page response, got ${null==(c=a.value)?void 0:c.kind}`),"__NEXT_ERROR_CODE",{value:"E305",enumerable:!1,configurable:!0});await a.value.html.pipeTo(B.writable)}).catch(a=>{B.writable.abort(a).catch(a=>{console.error("couldn't abort transformer",a)})}),(0,A.sendRenderResult)({req:a,res:b,generateEtags:aj.generateEtags,poweredByHeader:aj.poweredByHeader,result:v,cacheControl:{revalidate:0,expire:void 0}})};if(!aY||!aX)return k=aW.getActiveScopeSpan(),await aW.withPropagatedContext(a.headers,()=>aW.trace(i.BaseServerSpan.handleRequest,{spanName:`${aV} ${U}`,kind:g.SpanKind.SERVER,attributes:{"http.method":aV,"http.target":a.url}},D),void 0,!aY);await D(aX)}catch(b){throw b instanceof B.NoFallbackError||await N.onRequestError(a,b,{routerKind:"App Router",routePath:U,routeType:"render",revalidateReason:(0,f.c)({isStaticGeneration:aM,isOnDemandRevalidate:ap})},!1,ai),b}}}};var b=require("../../webpack-runtime.js");b.C(a);var c=b.X(0,[332,451,504,385,541,681,95,642],()=>b(b.s=98947));module.exports=c})();
|