cherry-works 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -80,7 +80,7 @@ The link points at your checkout. After you change the sources, run
80
80
  Inside the git repository you want to govern:
81
81
 
82
82
  ```bash
83
- cw init # asks which agent to compile for, then scaffolds .cw/charter/
83
+ cw init # asks which agent to compile for (claude, selected), scaffolds .cw/charter/ and builds
84
84
  cw kinds guide # what a guide requires
85
85
  cw add guide no-any --header description="No any in TypeScript." --header globs="src/**/*.ts"
86
86
  cw edit guide:no-any # write the body in $VISUAL or $EDITOR
@@ -137,7 +137,7 @@ agent reads it.
137
137
 
138
138
  | Command | What it does |
139
139
  |---|---|
140
- | `cw init [--agent]` | Set the repository up under a charter |
140
+ | `cw init [--agent]` | Set the repository up under a charter, and build it |
141
141
  | `cw build [--preview]` | Compile the charter, or show what a build would write |
142
142
  | `cw list [--kind] [--min]` | List what the charter holds |
143
143
  | `cw kinds [kind]` | List the kinds, or the fields one of them requires |
@@ -276,7 +276,8 @@ tool of a place, or `mcp:<id>:<tool>` for one of them.
276
276
 
277
277
  ## Your agent can write rules too
278
278
 
279
- Every governed repository gets a built-in skill, `skill:cw-author`. It teaches
279
+ Every governed repository gets a built-in skill, `skill:cw-author`, in the
280
+ agent's hands from the moment `cw init` finishes. It teaches
280
281
  the agent to ask `cw kinds` what a kind requires and to write primitives with
281
282
  `cw add`, instead of copying fields from memory.
282
283
 
package/dist/cw.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "cherry-works",
6
- version: "0.2.0",
6
+ version: "0.2.1",
7
7
  description: "The charter engine: resolves a charter and compiles it into what a coding agent reads.",
8
8
  keywords: [
9
9
  "claude-code",
package/dist/main.js CHANGED
@@ -6,7 +6,7 @@ import { pathToFileURL as pathToFileURL2 } from "url";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "cherry-works",
9
- version: "0.2.0",
9
+ version: "0.2.1",
10
10
  description: "The charter engine: resolves a charter and compiles it into what a coding agent reads.",
11
11
  keywords: [
12
12
  "claude-code",
@@ -1513,13 +1513,26 @@ var InitCommand = class {
1513
1513
  options = OPTIONS4;
1514
1514
  async run({ charterAuthoringApp: charterAuthoringApp2 }, { agent }) {
1515
1515
  const agents = await whichAgents(charterAuthoringApp2, agent);
1516
- await charterAuthoringApp2.init({ agents });
1516
+ const planSummaryDTO2 = await charterAuthoringApp2.init({ agents });
1517
+ const setUp = ["Set up this repository under a charter.", `Compiling for: ${agents.join(", ")}.`];
1518
+ if (planSummaryDTO2.type === "FaultsByFile") {
1519
+ const noOfFiles = Object.keys(planSummaryDTO2.data.files).length;
1520
+ return {
1521
+ code: EXIT_FAILURE,
1522
+ result: [...setUp, ""].join("\n"),
1523
+ problem: `Nothing was built: ${noOfFiles} file${noOfFiles === 1 ? " has" : "s have"} errors.
1524
+ Run "cw doctor" to see what is wrong with them.
1525
+ `
1526
+ };
1527
+ }
1528
+ const { added, edited } = planSummaryDTO2.data;
1529
+ const wrote = added.length + edited.length;
1517
1530
  return {
1518
1531
  code: EXIT_OK,
1519
1532
  result: [
1520
- "Set up this repository under a charter.",
1521
- `Compiling for: ${agents.join(", ")}.`,
1522
- 'Author your first rule under .cw/charter/guide/, then run "cw build".',
1533
+ ...setUp,
1534
+ `Built ${wrote} file${wrote === 1 ? "" : "s"}: ${added.length} added, ${edited.length} changed.`,
1535
+ 'Author your first rule under .cw/charter/guide/, or ask your agent to write one, then run "cw build".',
1523
1536
  ""
1524
1537
  ].join("\n")
1525
1538
  };
@@ -1535,13 +1548,14 @@ async function whichAgents(charterAuthoringApp2, typed) {
1535
1548
  return [typed];
1536
1549
  }
1537
1550
  const agentsInSettings = (await charterAuthoringApp2.settings()).data.agents.filter(isAgentProvider);
1551
+ const defaultAgents = agentsInSettings.length > 0 ? agentsInSettings : AGENT_PROVIDERS.length === 1 ? AGENT_PROVIDERS : [];
1538
1552
  if (!process.stdin.isTTY) {
1539
- if (agentsInSettings.length === 0)
1553
+ if (defaultAgents.length === 0)
1540
1554
  throw new DomainFault(
1541
1555
  "Nobody is at the terminal to choose an agent, and this repository has none chosen yet.",
1542
1556
  `Run "cw init --agent <name>", naming one of: ${AGENT_PROVIDERS.join(", ")}.`
1543
1557
  );
1544
- return agentsInSettings;
1558
+ return defaultAgents;
1545
1559
  }
1546
1560
  const { chosen } = await prompts2({
1547
1561
  type: "multiselect",
@@ -1550,8 +1564,9 @@ async function whichAgents(charterAuthoringApp2, typed) {
1550
1564
  // What the settings already name arrives ticked, so a return keeps what this
1551
1565
  // repository is already running under and a second run is rechoosing rather
1552
1566
  // than starting over (FR-038). Nothing named yet — a repository being set up
1553
- // for the first time — arrives with nothing ticked.
1554
- choices: AGENT_PROVIDERS.map((one) => ({ title: one, value: one, selected: agentsInSettings.includes(one) })),
1567
+ // for the first time — arrives with the one agent ticked where this engine
1568
+ // compiles for one, and with nothing ticked otherwise (FR-055).
1569
+ choices: AGENT_PROVIDERS.map((one) => ({ title: one, value: one, selected: defaultAgents.includes(one) })),
1555
1570
  // Ticking none of them is not an answer: a charter compiles for at least one
1556
1571
  // agent, so the prompt holds the submit until one is ticked (FR-033).
1557
1572
  min: 1
@@ -4295,10 +4310,10 @@ var CharterAuthoring = class {
4295
4310
  * agent it runs reads (FR-033).
4296
4311
  *
4297
4312
  * Then the two things setup owns — what the repository configured itself
4298
- * with, and a directory per kind for a charter to be authored in — and
4299
- * nothing more: compiling is `build`'s, run once there is a charter to
4300
- * compile (FR-037). What comes back is that it is set up; what stops it is
4301
- * raised.
4313
+ * with, and a directory per kind for a charter to be authored in — and a
4314
+ * build over them, so the skill the engine brings is in the agent's hands
4315
+ * before anything is authored (FR-057, FR-096). What comes back is what that
4316
+ * build did, or what refused it; what stops setup itself is raised.
4302
4317
  *
4303
4318
  * Nothing is written into an ignore file: everything under the workspace is
4304
4319
  * committed, what a vendor installed included, so a checkout of this
@@ -4324,7 +4339,7 @@ var CharterAuthoring = class {
4324
4339
  `);
4325
4340
  const kindFolders = KINDS.map((kind) => `${CHARTER_DIRECTORY}/${kind}/.gitkeep`);
4326
4341
  for (const path of kindFolders) await this.#fileWriter.write(new URL(path, this.#repoPath), "");
4327
- return true;
4342
+ return this.build();
4328
4343
  }
4329
4344
  };
4330
4345
 
@@ -136,7 +136,7 @@ ${this.parser.parse(t)}</blockquote>
136
136
  ${t}</tr>
137
137
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),a=t.header?"th":"td";return(t.align?`<${a} align="${t.align}">`:`<${a}>`)+e+`</${a}>
138
138
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Tr(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,text:a,tokens:r,autolink:n}){let i=n?Tr(a,!0):this.parser.parseInline(r),o=F5(t);if(o===null)return i;t=Tr(o,n);let s='<a href="'+t+'"';return e&&(s+=' title="'+Tr(e)+'"'),s+=">"+i+"</a>",s}image({href:t,title:e,text:a,tokens:r}){r&&(a=this.parser.parseInline(r,this.parser.textRenderer));let n=F5(t);if(n===null)return Tr(a);t=n;let i=`<img src="${Tr(t)}" alt="${Tr(a)}"`;return e&&(i+=` title="${Tr(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Tr(t.text)}},vC=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},$n=class hC{options;renderer;textRenderer;constructor(e){this.options=e||Kl,this.options.renderer=this.options.renderer||new s0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new vC}static parse(e,a){return new hC(a).parse(e)}static parseInline(e,a){return new hC(a).parseInline(e)}parse(e){this.renderer.parser=this;let a="";for(let r=0;r<e.length;r++){let n=e[r];if(this.options.extensions?.renderers?.[n.type]){let o=n,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(o.type)){a+=s||"";continue}}let i=n;switch(i.type){case"space":{a+=this.renderer.space(i);break}case"hr":{a+=this.renderer.hr(i);break}case"heading":{a+=this.renderer.heading(i);break}case"code":{a+=this.renderer.code(i);break}case"table":{a+=this.renderer.table(i);break}case"blockquote":{a+=this.renderer.blockquote(i);break}case"list":{a+=this.renderer.list(i);break}case"checkbox":{a+=this.renderer.checkbox(i);break}case"html":{a+=this.renderer.html(i);break}case"def":{a+=this.renderer.def(i);break}case"paragraph":{a+=this.renderer.paragraph(i);break}case"text":{a+=this.renderer.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return a}parseInline(e,a=this.renderer){this.renderer.parser=this;let r="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let s=this.options.extensions.renderers[i.type].call({parser:this},i);if(s!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){r+=s||"";continue}}let o=i;switch(o.type){case"escape":{r+=a.text(o);break}case"html":{r+=a.html(o);break}case"link":{r+=a.link(o);break}case"image":{r+=a.image(o);break}case"checkbox":{r+=a.checkbox(o);break}case"strong":{r+=a.strong(o);break}case"em":{r+=a.em(o);break}case"codespan":{r+=a.codespan(o);break}case"br":{r+=a.br(o);break}case"del":{r+=a.del(o);break}case"text":{r+=a.text(o);break}default:{let s='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return r}},Eh=class{options;block;constructor(t){this.options=t||Kl}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Dn.lex:Dn.lexInline}provideParser(t=this.block){return t?$n.parse:$n.parseInline}},SC=class{defaults=pC();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=$n;Renderer=s0;TextRenderer=vC;Lexer=Dn;Tokenizer=o0;Hooks=Eh;constructor(...t){this.use(...t)}walkTokens(t,e){let a=[];for(let r of t)switch(a=a.concat(e.call(this,r)),r.type){case"table":{let n=r;for(let i of n.header)a=a.concat(this.walkTokens(i.tokens,e));for(let i of n.rows)for(let o of i)a=a.concat(this.walkTokens(o.tokens,e));break}case"list":{let n=r;a=a.concat(this.walkTokens(n.items,e));break}default:{let n=r;this.defaults.extensions?.childTokens?.[n.type]?this.defaults.extensions.childTokens[n.type].forEach(i=>{let o=n[i].flat(1/0);a=a.concat(this.walkTokens(o,e))}):n.tokens&&(a=a.concat(this.walkTokens(n.tokens,e)))}}return a}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(a=>{let r={...a};if(r.async=this.defaults.async||r.async||!1,a.extensions&&(a.extensions.forEach(n=>{if(!n.name)throw new Error("extension name required");if("renderer"in n){let i=e.renderers[n.name];i?e.renderers[n.name]=function(...o){let s=n.renderer.apply(this,o);return s===!1&&(s=i.apply(this,o)),s}:e.renderers[n.name]=n.renderer}if("tokenizer"in n){if(!n.level||n.level!=="block"&&n.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[n.level];i?i.unshift(n.tokenizer):e[n.level]=[n.tokenizer],n.start&&(n.level==="block"?e.startBlock?e.startBlock.push(n.start):e.startBlock=[n.start]:n.level==="inline"&&(e.startInline?e.startInline.push(n.start):e.startInline=[n.start]))}"childTokens"in n&&n.childTokens&&(e.childTokens[n.name]=n.childTokens)}),r.extensions=e),a.renderer){let n=this.defaults.renderer||new s0(this.defaults);for(let i in a.renderer){if(!(i in n))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,s=a.renderer[o],l=n[o];n[o]=(...u)=>{let c=s.apply(n,u);return c===!1&&(c=l.apply(n,u)),c||""}}r.renderer=n}if(a.tokenizer){let n=this.defaults.tokenizer||new o0(this.defaults);for(let i in a.tokenizer){if(!(i in n))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,s=a.tokenizer[o],l=n[o];n[o]=(...u)=>{let c=s.apply(n,u);return c===!1&&(c=l.apply(n,u)),c}}r.tokenizer=n}if(a.hooks){let n=this.defaults.hooks||new Eh;for(let i in a.hooks){if(!(i in n))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,s=a.hooks[o],l=n[o];Eh.passThroughHooks.has(i)?n[o]=u=>{if(this.defaults.async&&Eh.passThroughHooksRespectAsync.has(i))return(async()=>{let f=await s.call(n,u);return l.call(n,f)})();let c=s.call(n,u);return l.call(n,c)}:n[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await s.apply(n,u);return f===!1&&(f=await l.apply(n,u)),f})();let c=s.apply(n,u);return c===!1&&(c=l.apply(n,u)),c}}r.hooks=n}if(a.walkTokens){let n=this.defaults.walkTokens,i=a.walkTokens;r.walkTokens=function(o){let s=[];return s.push(i.call(this,o)),n&&(s=s.concat(n.call(this,o))),s}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Dn.lex(t,e??this.defaults)}parser(t,e){return $n.parse(t,e??this.defaults)}parseMarkdown(t){return(e,a)=>{let r={...a},n={...this.defaults,...r},i=this.onError(!!n.silent,!!n.async);if(this.defaults.async===!0&&r.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=t),n.async)return(async()=>{let o=n.hooks?await n.hooks.preprocess(e):e,s=await(n.hooks?await n.hooks.provideLexer(t):t?Dn.lex:Dn.lexInline)(o,n),l=n.hooks?await n.hooks.processAllTokens(s):s;n.walkTokens&&await Promise.all(this.walkTokens(l,n.walkTokens));let u=await(n.hooks?await n.hooks.provideParser(t):t?$n.parse:$n.parseInline)(l,n);return n.hooks?await n.hooks.postprocess(u):u})().catch(i);try{n.hooks&&(e=n.hooks.preprocess(e));let o=(n.hooks?n.hooks.provideLexer(t):t?Dn.lex:Dn.lexInline)(e,n);n.hooks&&(o=n.hooks.processAllTokens(o)),n.walkTokens&&this.walkTokens(o,n.walkTokens);let s=(n.hooks?n.hooks.provideParser(t):t?$n.parse:$n.parseInline)(o,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(o){return i(o)}}}onError(t,e){return a=>{if(a.message+=`
139
- Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Tr(a.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(a);throw a}}},Wl=new SC;function it(t,e){return Wl.parse(t,e)}it.options=it.setOptions=function(t){return Wl.setOptions(t),it.defaults=Wl.defaults,K5(it.defaults),it};it.getDefaults=pC;it.defaults=Kl;function G8(...t){return Wl.use(...t),it.defaults=Wl.defaults,K5(it.defaults),it}it.use=G8;it.walkTokens=function(t,e){return Wl.walkTokens(t,e)};it.parseInline=Wl.parseInline;it.Parser=$n;it.parser=$n.parse;it.Renderer=s0;it.TextRenderer=vC;it.Lexer=Dn;it.lexer=Dn.lex;it.Tokenizer=o0;it.Hooks=Eh;it.parse=it;var Qse=it.options,Mse=it.setOptions,Ese=it.walkTokens,Dse=it.parseInline;var $se=$n.parse,Bse=Dn.lex;var Vse=L(F(),1);var zh=L(G(),1);function l0({className:t,orientation:e="horizontal",...a}){return(0,zh.jsx)(Cl.Root,{"data-slot":"tabs","data-orientation":e,orientation:e,className:pe("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...a})}var Y8=oi("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function u0({className:t,variant:e="default",...a}){return(0,zh.jsx)(Cl.List,{"data-slot":"tabs-list","data-variant":e,className:pe(Y8({variant:e}),t),...a})}function _h({className:t,...e}){return(0,zh.jsx)(Cl.Trigger,{"data-slot":"tabs-trigger",className:pe("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...e})}function Jl({className:t,...e}){return(0,zh.jsx)(Cl.Content,{"data-slot":"tabs-content",className:pe("flex-1 outline-none",t),...e})}var or=L(G(),1),W8=new SC({renderer:{html:({text:t})=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},walkTokens:t=>{(t.type==="link"||t.type==="image")&&/^\s*(javascript|vbscript|data):/i.test(t.href)&&(t.href="#")}}),sz="h-auto flex-none cursor-pointer rounded-md px-[11px] py-[5px] text-[11.5px] font-semibold text-zinc-500 data-[state=active]:shadow-[0_1px_2px_rgba(0,0,0,0.08)]";function wC({body:t,onChange:e}){return(0,or.jsxs)(l0,{defaultValue:e===void 0?"preview":"source",className:"gap-0 overflow-hidden rounded-xl border bg-background",children:[(0,or.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-[#f0f0f0] px-[13px] py-[9px]",children:[(0,or.jsx)("span",{className:"text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Body"}),(0,or.jsx)("span",{className:"font-mono text-[10.5px] text-zinc-400",children:"markdown"}),(0,or.jsxs)(u0,{className:"ml-auto h-auto gap-0.5 rounded-lg bg-[#f0f0f2] p-[3px]",children:[(0,or.jsx)(_h,{value:"source",className:sz,children:"Source"}),(0,or.jsx)(_h,{value:"preview",className:sz,children:"Preview"})]})]}),(0,or.jsx)(Jl,{value:"source",className:"h-[300px] flex-none",children:(0,or.jsx)(K8,{body:t,onChange:e})}),(0,or.jsx)(Jl,{value:"preview",children:(0,or.jsx)("div",{className:"min-h-32 px-[18px] py-4 text-[12.5px] leading-[1.65] text-zinc-700 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-xs [&_h1]:mb-[7px] [&_h1]:text-[15px] [&_h1]:font-bold [&_h1]:text-foreground [&_h2]:mt-4 [&_h2]:mb-[7px] [&_h2]:text-[13px] [&_h2]:font-bold [&_h2]:text-foreground [&_strong]:font-semibold [&_strong]:text-foreground [&_li]:ml-5 [&_ol]:list-decimal [&_p]:mb-2 [&_ul]:list-disc",dangerouslySetInnerHTML:{__html:W8.parse(t,{async:!1})}})})]})}function K8({body:t,onChange:e}){let a=(0,lz.useCallback)(r=>{let n=new oe({parent:r,doc:t,extensions:[q5(),j$(F$),iB(),zl.of([...DB,...uB]),oe.lineWrapping,oe.editable.of(e!==void 0),oe.updateListener.of(i=>{i.docChanged&&e?.(i.state.doc.toString())})]});return()=>n.destroy()},[]);return(0,or.jsx)("div",{className:"h-full",ref:a})}var ale=L(F(),1);var uz=L(G(),1);function eu({className:t,type:e,...a}){return(0,uz.jsx)("input",{type:e,"data-slot":"input",className:pe("h-[30px] w-full min-w-0 rounded-lg border border-input bg-background px-[11px] py-1 font-mono text-[11.5px] text-foreground transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30","focus-visible:border-[#d92f45]","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",t),...a})}var ile=L(F(),1);var cz=L(G(),1);function Nh({className:t,...e}){return(0,cz.jsx)(Eg.Root,{"data-slot":"label",className:pe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}var ule=L(F(),1);var Rt=L(G(),1);function CC({...t}){return(0,Rt.jsx)(Ea.Root,{"data-slot":"select",...t})}function kC({...t}){return(0,Rt.jsx)(Ea.Value,{"data-slot":"select-value",...t})}function LC({className:t,size:e="default",children:a,...r}){return(0,Rt.jsxs)(Ea.Trigger,{"data-slot":"select-trigger","data-size":e,className:pe("flex w-fit cursor-pointer items-center justify-between gap-2 rounded-lg border border-input bg-background px-[11px] py-1 font-mono text-[11.5px] whitespace-nowrap text-foreground transition-[color,box-shadow] outline-none focus-visible:border-[#d92f45] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-[30px] data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...r,children:[a,(0,Rt.jsx)(Ea.Icon,{asChild:!0,children:(0,Rt.jsx)(Oc,{className:"size-4 opacity-50"})})]})}function TC({className:t,children:e,position:a="item-aligned",align:r="center",...n}){return(0,Rt.jsx)(Ea.Portal,{children:(0,Rt.jsxs)(Ea.Content,{"data-slot":"select-content",className:pe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,align:r,...n,children:[(0,Rt.jsx)(J8,{}),(0,Rt.jsx)(Ea.Viewport,{className:pe("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),(0,Rt.jsx)(eW,{})]})})}function PC({className:t,children:e,...a}){return(0,Rt.jsxs)(Ea.Item,{"data-slot":"select-item",className:pe("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...a,children:[(0,Rt.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,Rt.jsx)(Ea.ItemIndicator,{children:(0,Rt.jsx)(Sd,{className:"size-4"})})}),(0,Rt.jsx)(Ea.ItemText,{children:e})]})}function J8({className:t,...e}){return(0,Rt.jsx)(Ea.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:pe("flex cursor-default items-center justify-center py-1",t),...e,children:(0,Rt.jsx)(wd,{className:"size-4"})})}function eW({className:t,...e}){return(0,Rt.jsx)(Ea.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:pe("flex cursor-default items-center justify-center py-1",t),...e,children:(0,Rt.jsx)(Oc,{className:"size-4"})})}var K=L(G(),1);function RC({identity:t,newKind:e,onDone:a,onClose:r}){let{data:n}=wA(t);if(t===void 0)return(0,K.jsx)(fz,{primitiveSnapshot:null,entityTag:"",newKind:e??"",onDone:a,onClose:r});if(n===void 0)return null;let{answer:i,entityTag:o}=n;return i.type==="Fault"?(0,K.jsx)(hz,{faults:[i]}):i.data.scopedPrimitive.data.scope!=="repo"?(0,K.jsx)(tW,{primitiveSnapshot:i}):(0,K.jsx)(fz,{primitiveSnapshot:i,entityTag:o,newKind:"",onDone:a,onClose:r})}function fz({primitiveSnapshot:t,entityTag:e,newKind:a,onDone:r,onClose:n}){let i=t?.data.scopedPrimitive.data,[o,s]=(0,ff.useState)(i?.kind??a),[l,u]=(0,ff.useState)(i===void 0?"":String(i.headers.id)),[c,f]=(0,ff.useState)(()=>Object.fromEntries(Object.entries(i?.headers??{}).filter(([R])=>R!=="id").map(([R,B])=>[R,typeof B=="string"?B:[...B]]))),[d,h]=(0,ff.useState)(t?.data.body??""),[p,m]=(0,ff.useState)([]),{data:x}=xc(),{data:g}=CA(o),{data:O}=ni(),y=kA(),b=LA(),v=TA(),S=x===void 0?[]:Object.keys(x.data),w=g?.type==="PrimitiveRequirements"?g.data.headers:[],k=O?.type==="ScopedPrimitives"?O.data.primitives.filter(({data:R})=>R.kind==="corpus").map(({data:R})=>R.identity):[],T=Object.fromEntries(w.flatMap(({data:{field:R}})=>{let B=c[R],W=typeof B=="string"?B.trim():(B??[]).map($=>$.trim()).filter($=>$!=="");return W.length===0?[]:[[R,W]]})),Q=R=>m(R.type==="Faults"?R.data.faults:[R]),D=async()=>{let R=t===null?await y.mutateAsync({kind:o,id:l,headers:T,body:d}):await b.mutateAsync({param:{identity:t.data.scopedPrimitive.data.identity},header:{"if-match":e},json:{headers:T,body:d}});if(R.type!=="ScopedPrimitive")return Q(R);r(t===null?"Primitive created":"Primitive saved",`${R.data.file} \xB7 nothing compiled until the next build`)},A=async()=>{if(t===null)return;let R=await v.mutateAsync(t.data.scopedPrimitive.data.identity);if(R!==null)return Q(R);r("Primitive deleted",`${t.data.scopedPrimitive.data.file} \xB7 what still names it is reported by Doctor`)};return(0,K.jsxs)("div",{className:"space-y-3.5",children:[(0,K.jsxs)("div",{className:dz,children:[t===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(co,{label:"kind",htmlFor:"primitive-kind",children:(0,K.jsxs)(CC,{value:o,onValueChange:s,children:[(0,K.jsx)(LC,{id:"primitive-kind",className:"w-full",children:(0,K.jsx)(kC,{})}),(0,K.jsx)(TC,{children:S.map(R=>(0,K.jsx)(PC,{value:R,children:R},R))})]})}),(0,K.jsx)(co,{label:"id",htmlFor:"primitive-id",hint:`.cw/charter/${o}/${l||"<id>"}.md`,children:(0,K.jsx)(eu,{id:"primitive-id",value:l,placeholder:"no-any",spellCheck:!1,onChange:R=>u(R.currentTarget.value)})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(co,{label:"kind",hint:"the identity is the file \u2014 rename by creating a new primitive and deleting this one",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:o})}),(0,K.jsx)(co,{label:"id",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:l})})]}),w.map(({data:{field:R,shape:B,required:W,allowedValues:$}})=>(0,K.jsx)(co,{label:R,htmlFor:`header-${R}`,hint:W?"required":void 0,children:B==="list"?(0,K.jsx)(aW,{field:R,entries:Array.isArray(c[R])?c[R]:[],onChange:q=>f({...c,[R]:q})}):$!==void 0?(0,K.jsxs)(CC,{value:typeof c[R]=="string"?c[R]:"",onValueChange:q=>f({...c,[R]:q}),children:[(0,K.jsx)(LC,{id:`header-${R}`,className:"w-full",children:(0,K.jsx)(kC,{placeholder:"\u2014"})}),(0,K.jsx)(TC,{children:$.map(q=>(0,K.jsx)(PC,{value:q,children:q},q))})]}):(0,K.jsx)(eu,{id:`header-${R}`,spellCheck:!1,autoComplete:"off",value:typeof c[R]=="string"?c[R]:"",list:R==="rationale"?"corpus-identities":void 0,onChange:q=>f({...c,[R]:q.currentTarget.value})})},R))]}),(0,K.jsx)("datalist",{id:"corpus-identities",children:k.map(R=>(0,K.jsx)("option",{value:R},R))}),(0,K.jsx)(wC,{body:d,onChange:h}),p.length>0&&(0,K.jsx)(hz,{faults:p}),(0,K.jsxs)("div",{className:li,children:[(0,K.jsx)(Ae,{onClick:()=>{D()},children:t===null?"Create primitive":"Save"}),(0,K.jsx)(Ae,{variant:"outline",onClick:n,children:"Cancel"}),t!==null&&(0,K.jsx)(Ae,{variant:"destructive",className:"ml-auto",onClick:()=>{A()},children:"Delete"})]})]})}function tW({primitiveSnapshot:t}){let{kind:e,description:a,file:r,scope:n,headers:i}=t.data.scopedPrimitive.data;return(0,K.jsxs)("div",{className:"space-y-3.5",children:[(0,K.jsxs)(Ur,{className:"rounded-xl border-[#7c3aed33] bg-[#f6f2ff]",children:[(0,K.jsx)(jr,{className:"text-[12.5px] font-bold",children:n==="vendor"?"Installed from a vendor, and read-only here.":"Built into cw, and read-only here."}),(0,K.jsx)(Fr,{className:"text-[11.5px] text-zinc-600",children:"To differ from it, author a primitive of your own under an identity of its own."})]}),(0,K.jsxs)("div",{className:dz,children:[(0,K.jsx)(co,{label:"kind",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:e})}),(0,K.jsx)(co,{label:"file",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:r})}),(0,K.jsx)(co,{label:"description",children:(0,K.jsx)("span",{className:"text-xs",children:a})}),Object.entries(i).filter(([o])=>o!=="id"&&o!=="description").map(([o,s])=>(0,K.jsx)(co,{label:o,children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:typeof s=="string"?s:s.join(", ")})},o))]}),(0,K.jsx)(wC,{body:t.data.body})]})}var dz="overflow-hidden rounded-[11px] border border-[#f0f0f0] bg-background divide-y divide-zinc-100";function co({label:t,htmlFor:e,hint:a,children:r}){return(0,K.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,K.jsx)(Nh,{htmlFor:e,className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:t}),(0,K.jsx)("div",{className:"min-w-0 flex-1",children:r}),a!==void 0&&(0,K.jsx)("span",{className:"max-w-[45%] shrink text-right text-[11.5px] text-zinc-400",children:a})]})}function aW({field:t,entries:e,onChange:a}){let r=e.length===0?[""]:e;return(0,K.jsxs)("div",{className:"flex flex-col gap-1.5",children:[r.map((n,i)=>(0,K.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,K.jsx)(eu,{id:i===0?`header-${t}`:void 0,"aria-label":`${t} ${i+1}`,spellCheck:!1,value:n,onChange:o=>a(r.map((s,l)=>l===i?o.currentTarget.value:s))}),r.length>1&&(0,K.jsx)(Ae,{variant:"outline",size:"icon",className:"size-[26px] shrink-0 rounded-[7px] text-zinc-400 [&_svg:not([class*='size-'])]:size-[11px]","aria-label":`Remove this ${t} entry`,onClick:()=>a(r.filter((o,s)=>s!==i)),children:(0,K.jsx)(sl,{})})]},i)),(0,K.jsxs)(Ae,{variant:"outline",size:"sm",className:"h-auto self-start rounded-[7px] border-dashed border-zinc-300 px-2.5 py-[5px] text-[11px] font-normal text-zinc-500",onClick:()=>a([...r,""]),children:["Add ",t]})]})}function hz({faults:t}){return(0,K.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,K.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was written"}),(0,K.jsx)(Fr,{children:t.map(({data:{message:e,fix:a}})=>(0,K.jsxs)("p",{className:"whitespace-pre-line",children:[e," ",(0,K.jsx)("span",{className:"text-muted-foreground",children:a})]},e))})]})}var c0=L(F(),1);var pt=L(G(),1);function pz({onDone:t,onClose:e}){let[a,r]=(0,c0.useState)(""),[n,i]=(0,c0.useState)(""),[o,s]=(0,c0.useState)(null),l=xc(),u=AA(),c=async()=>{let f=n.trim(),d=await u.mutateAsync({source:a.trim(),...f===""?{}:{version:f}});if(d!==null)return s(d);t("Vendor source added",`${a.trim()}${f===""?"":` @ ${f}`} \xB7 run Build to compile what it adds`)};return(0,pt.jsxs)("div",{className:"space-y-3.5",children:[(0,pt.jsx)("p",{className:"text-[13px] leading-[1.65] text-zinc-700",children:"A vendor source is a repository of primitives laid out by kind."}),(0,pt.jsxs)("div",{className:"divide-y divide-zinc-100 overflow-hidden rounded-[11px] border border-[#f0f0f0]",children:[(0,pt.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,pt.jsx)(Nh,{htmlFor:"vendor-source",className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"source"}),(0,pt.jsx)(eu,{id:"vendor-source",value:a,spellCheck:!1,onChange:f=>r(f.target.value)})]}),(0,pt.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,pt.jsx)(Nh,{htmlFor:"vendor-version",className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"version"}),(0,pt.jsx)(eu,{id:"vendor-version",value:n,spellCheck:!1,onChange:f=>i(f.target.value)}),(0,pt.jsx)("span",{className:"max-w-[45%] shrink text-right text-[11.5px] text-zinc-400",children:"a tag, branch or commit; left empty, the source's default"})]})]}),(0,pt.jsxs)("div",{className:"rounded-[11px] border bg-zinc-50 px-3.5 py-3","aria-label":"Reserved directories",children:[(0,pt.jsx)("div",{className:"mb-1 text-[11px] font-bold tracking-[0.07em] text-zinc-400 uppercase",children:"Reserved directories at its root"}),Object.entries(l.data?.data??{}).map(([f,d])=>(0,pt.jsxs)("div",{className:"flex items-baseline gap-[9px] border-t border-zinc-100 py-[7px]",children:[(0,pt.jsxs)("span",{className:"min-w-[150px] font-mono text-[11.5px]",children:[f,"/"]}),(0,pt.jsx)("span",{className:"text-[11.5px] text-zinc-500",children:d})]},f))]}),o!==null&&(0,pt.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,pt.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was installed"}),(0,pt.jsx)(Fr,{children:(0,pt.jsxs)("p",{className:"whitespace-pre-line",children:[o.data.message," ",(0,pt.jsx)("span",{className:"text-muted-foreground",children:o.data.fix})]})})]}),(0,pt.jsxs)("div",{className:li,children:[(0,pt.jsx)(Ae,{disabled:u.isPending||a.trim()==="",onClick:()=>{c()},children:"Add source"}),(0,pt.jsx)(Ae,{variant:"outline",onClick:e,children:"Cancel"})]})]})}var IC=L(F(),1);var It=L(G(),1);function mz({name:t,onDone:e,onClose:a}){let n=Fm().data?.data.testSuites.find(({data:i})=>i.name===t);return n===void 0?null:(0,It.jsx)(rW,{name:t,initialText:n.data.text??"",onDone:e,onClose:a},t)}function rW({name:t,initialText:e,onDone:a,onClose:r}){let[n,i]=(0,IC.useState)(e),[o,s]=(0,IC.useState)(null),l=DA(),u=$A(),c=async()=>{let d=await l.mutateAsync({name:t,text:n});if(typeof d!="string")return s(d);a("Saved",`.cw/test/${t} rewritten \xB7 run the cases again`)},f=async()=>{let d=await u.mutateAsync(t);if(d!==null)return s(d);a("Test file deleted",`.cw/test/${t} removed`)};return(0,It.jsxs)("div",{className:"space-y-3",children:[(0,It.jsxs)("p",{className:"text-xs leading-[1.65] text-zinc-600 [&_code]:font-mono",children:["A case is one situation \u2014 a touched file (",(0,It.jsx)("code",{children:"do.touchFile"}),") or a raised event (",(0,It.jsx)("code",{children:"when"}),") \u2014 and expects one thing:"," ",(0,It.jsx)("code",{children:"activate"}),", ",(0,It.jsx)("code",{children:"run"})," or ",(0,It.jsx)("code",{children:"allow"}),"."]}),(0,It.jsx)("textarea",{"aria-label":"Test file text",className:"h-[340px] w-full resize-y rounded-[11px] border bg-zinc-50 px-3.5 py-3 font-mono text-[11.5px] leading-[1.65] outline-none",spellCheck:!1,value:n,onChange:d=>i(d.target.value)}),o!==null&&(0,It.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,It.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was written"}),(0,It.jsx)(Fr,{children:(0,It.jsxs)("p",{className:"break-words whitespace-pre-line",children:[o.data.message," ",(0,It.jsx)("span",{className:"text-muted-foreground",children:o.data.fix})]})})]}),(0,It.jsx)("p",{className:"text-[11.5px] leading-[1.6] text-zinc-400",children:"Read only when tests run \u2014 never compiled, never read by an agent."}),(0,It.jsxs)("div",{className:li,children:[(0,It.jsx)(Ae,{disabled:l.isPending,onClick:()=>{c()},children:"Save"}),(0,It.jsx)(Ae,{variant:"outline",onClick:r,children:"Cancel"}),(0,It.jsx)(Ae,{variant:"destructive",className:"ml-auto",disabled:u.isPending,onClick:()=>{f()},children:"Delete file"})]})]})}var $le=L(F(),1);var sr=L(G(),1);function gz({...t}){return(0,sr.jsx)(xn.Root,{"data-slot":"dialog",...t})}function nW({...t}){return(0,sr.jsx)(xn.Portal,{"data-slot":"dialog-portal",...t})}function iW({className:t,...e}){return(0,sr.jsx)(xn.Overlay,{"data-slot":"dialog-overlay",className:pe("fixed inset-0 z-50 bg-[rgba(9,9,11,0.35)] data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...e})}function Oz({className:t,children:e,showCloseButton:a=!0,...r}){return(0,sr.jsxs)(nW,{"data-slot":"dialog-portal",children:[(0,sr.jsx)(iW,{}),(0,sr.jsxs)(xn.Content,{"data-slot":"dialog-content",className:pe("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",t),...r,children:[e,a&&(0,sr.jsxs)(xn.Close,{"data-slot":"dialog-close",className:"absolute top-4 right-[18px] cursor-pointer rounded-xs p-0.5 text-zinc-400 ring-offset-background transition-colors hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,sr.jsx)(sl,{}),(0,sr.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function xz({className:t,...e}){return(0,sr.jsx)("div",{"data-slot":"dialog-header",className:pe("flex flex-col gap-2 text-center sm:text-left",t),...e})}function yz({className:t,...e}){return(0,sr.jsx)(xn.Title,{"data-slot":"dialog-title",className:pe("text-lg leading-none font-semibold",t),...e})}function bz({className:t,...e}){return(0,sr.jsx)(xn.Description,{"data-slot":"dialog-description",className:pe("text-sm text-muted-foreground",t),...e})}var pa=L(G(),1),oW={explanation:{title:()=>"Explain",context:({identity:t})=>t,holdsDraft:!1,render:({identity:t},{open:e})=>(0,pa.jsx)(TE,{identity:t,onExplain:a=>e("explanation",{identity:a})},t)},primitive:{title:({identity:t})=>t,context:()=>"",holdsDraft:!0,render:({identity:t},{close:e})=>(0,pa.jsx)(RC,{identity:t,onDone:f0(e),onClose:e},t)},newPrimitive:{title:()=>"New primitive",context:()=>"",holdsDraft:!0,render:({kind:t},{close:e})=>(0,pa.jsx)(RC,{newKind:t,onDone:f0(e),onClose:e},`new ${t}`)},buildPreview:{title:()=>"cw build",context:()=>"nothing written yet",holdsDraft:!1,render:(t,{open:e})=>(0,pa.jsx)(SE,{onBuilt:a=>e("buildOutcome",{buildAnswer:a})})},buildOutcome:{title:()=>"cw build",context:()=>"",holdsDraft:!1,render:({buildAnswer:t})=>(0,pa.jsx)(wE,{buildAnswer:t})},addVendor:{title:()=>"Add vendor source",context:()=>"",holdsDraft:!0,render:(t,{close:e})=>(0,pa.jsx)(pz,{onDone:f0(e),onClose:e})},testSuite:{title:({name:t})=>`.cw/test/${t}`,context:()=>"",holdsDraft:!0,render:({name:t},{close:e})=>(0,pa.jsx)(mz,{name:t,onDone:f0(e),onClose:e},t)},doctor:{title:()=>"Doctor",context:()=>"cw 0.2.0",holdsDraft:!1,render:(t,{open:e})=>(0,pa.jsx)(LE,{onBuilt:a=>e("buildOutcome",{buildAnswer:a})})}};function f0(t){return(e,a)=>{t(),ll(e,{description:a})}}var vz=(0,tu.createContext)(null);function fo(){return(0,tu.useContext)(vz)}function Sz({children:t}){let[e,a]=(0,tu.useState)(null),[r,n]=(0,tu.useState)(!1),i={open:(s,l)=>{a({name:s,params:l}),n(!0)},close:()=>n(!1)},o=e===null?null:oW[e.name];return(0,pa.jsxs)(vz.Provider,{value:i,children:[t,(0,pa.jsx)(gz,{open:r,onOpenChange:n,children:e!==null&&o!==null&&(0,pa.jsxs)(Oz,{className:"flex max-h-[88vh] w-[920px] max-w-[calc(100%-48px)] flex-col gap-0 overflow-hidden rounded-[15px] border-0 p-0 shadow-[0_34px_80px_-22px_rgba(0,0,0,0.4)] sm:max-w-[calc(100%-48px)]",onInteractOutside:s=>o.holdsDraft&&s.preventDefault(),onEscapeKeyDown:s=>o.holdsDraft&&s.preventDefault(),children:[(0,pa.jsxs)(xz,{className:"flex-row items-baseline gap-2.5 border-b border-[#f0f0f0] py-[15px] pr-12 pl-[18px]",children:[(0,pa.jsx)(yz,{className:"text-[14.5px] font-bold tracking-[-0.01em]",children:o.title(e.params)}),(0,pa.jsx)(bz,{className:"font-mono text-[11px] text-zinc-400",children:o.context(e.params)})]}),(0,pa.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-[18px]",children:o.render(e.params,i)})]})})]})}var h0=L(F(),1);var Wle=L(F(),1);var sW=L(G(),1),wz=oi("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-8 min-w-8 px-1.5",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}});var d0=L(G(),1),Cz=h0.createContext({size:"default",variant:"default",spacing:0});function kz({className:t,variant:e,size:a,spacing:r=0,children:n,...i}){return(0,d0.jsx)(Xd.Root,{"data-slot":"toggle-group","data-variant":e,"data-size":a,"data-spacing":r,style:{"--gap":r},className:pe("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",t),...i,children:(0,d0.jsx)(Cz.Provider,{value:{variant:e,size:a,spacing:r},children:n})})}function Lz({className:t,children:e,variant:a,size:r,...n}){let i=h0.useContext(Cz);return(0,d0.jsx)(Xd.Item,{"data-slot":"toggle-group-item","data-variant":i.variant||a,"data-size":i.size||r,"data-spacing":i.spacing,className:pe(wz({variant:i.variant||a,size:i.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",t),...n,children:e})}var se=L(G(),1);function MC({scopes:t,kind:e,onKindChange:a}){let{open:r}=fo(),n=xc(),i=ni();if(n.data===void 0||i.data===void 0)return null;let o=n.data.data,s=i.data;if(s.type==="FaultsByFile")return(0,se.jsx)(lW,{faultsByFile:s});if(s.type==="Fault")return(0,se.jsx)(uW,{fault:s});let l=s.data.primitives.filter(({data:d})=>t.includes(d.scope)),u=new Map(Object.keys(o).map(d=>[d,l.filter(({data:h})=>h.kind===d).length])),c=e??[...u].find(([,d])=>d>0)?.[0]??Object.keys(o)[0],f=l.filter(({data:d})=>d.kind===c);return(0,se.jsxs)("div",{className:"min-w-0",children:[(0,se.jsxs)("div",{className:"mb-3 flex items-baseline gap-[9px]",children:[(0,se.jsx)("h2",{className:"text-[12.5px] font-bold",children:"Charter primitives"}),(0,se.jsxs)("span",{className:"text-[11.5px] text-zinc-400",children:[l.length," in this charter"]}),t.includes("repo")&&(0,se.jsxs)(Ae,{size:"sm",variant:"outline",className:"ml-auto",onClick:()=>r("newPrimitive",{kind:c}),children:["New ",c]})]}),(0,se.jsx)(kz,{type:"single",spacing:1.5,"aria-label":"Kinds",className:"mb-3 flex-wrap",value:c,onValueChange:d=>d!==""&&a(d),children:[...u].map(([d,h])=>(0,se.jsxs)(Lz,{value:d,"aria-label":d,className:`group/chip h-auto cursor-pointer gap-1.5 rounded-[9px] border bg-background px-2.5 py-1.5 text-[11.5px] font-medium text-zinc-700 capitalize hover:bg-background hover:text-zinc-700 data-[state=on]:border-foreground data-[state=on]:bg-foreground data-[state=on]:font-semibold data-[state=on]:text-white ${h===0&&d!==c?"opacity-50":""}`,children:[d,(0,se.jsx)(hi,{className:"rounded-none bg-transparent p-0 font-mono text-[10px] font-normal text-zinc-400 group-data-[state=on]/chip:text-white/70",children:h})]},d))}),(0,se.jsxs)("p",{className:"mb-2.5 flex items-baseline gap-2 px-0.5",children:[(0,se.jsx)("span",{className:"shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Activates when"}),(0,se.jsx)("span",{className:"text-xs leading-normal text-zinc-700","aria-label":"Activates when",children:o[c]})]}),f.length===0?(0,se.jsxs)("p",{className:"rounded-[14px] border p-[22px] text-center text-[12.5px] text-zinc-400",children:["No ",c," in this charter yet."]}):(0,se.jsx)(cW,{kind:c,listed:f})]})}function lW({faultsByFile:t}){let e=Object.entries(t.data.files);return(0,se.jsxs)("div",{className:"space-y-3.5",children:[(0,se.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,se.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"The engine will not read this charter"}),(0,se.jsxs)(Fr,{children:[e.length," file",e.length===1?" is":"s are"," refused, so there is no listing to show. Fix",e.length===1?" it":" them"," and the charter comes back."]})]}),(0,se.jsx)(cs,{faultsByFile:t,label:"Refused files"})]})}function uW({fault:t}){return(0,se.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,se.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:t.data.message}),(0,se.jsx)(Fr,{children:t.data.fix})]})}function AC(t){return t===void 0?void 0:typeof t=="string"?[t]:t}function cW({kind:t,listed:e}){let{open:a}=fo(),r=t==="guide",n=t!=="mixin";return(0,se.jsx)("div",{className:"overflow-hidden rounded-[14px] border bg-background",children:(0,se.jsxs)(kl,{"aria-label":`${t} primitives`,className:"table-fixed",children:[(0,se.jsx)(bE,{children:(0,se.jsxs)(Tl,{className:"border-[#ececef] bg-zinc-50 hover:bg-zinc-50 [&>th]:h-auto [&>th]:px-[15px] [&>th]:py-[9px] [&>th]:text-[9.5px] [&>th]:font-bold [&>th]:tracking-[0.07em] [&>th]:text-zinc-400 [&>th]:uppercase",children:[(0,se.jsx)(Pl,{className:"w-[170px]",children:"Id"}),(0,se.jsx)(Pl,{children:"Description"}),r&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(Pl,{className:"w-[170px] text-right",children:"Matching globs"}),(0,se.jsx)(Pl,{className:"w-[120px] text-right",children:"Rationale"})]}),n&&(0,se.jsx)(Pl,{className:"w-[120px] text-right",children:"Mixins"}),(0,se.jsx)(Pl,{className:"w-[50px]"})]})}),(0,se.jsx)(Ll,{children:e.map(({data:{identity:i,description:o,file:s,headers:l}})=>{let u=AC(l.globs);return(0,se.jsxs)(Tl,{className:"group/row border-[#f7f7f8] align-top hover:bg-zinc-50 [&>td]:px-[15px] [&>td]:py-3",children:[(0,se.jsx)(Cn,{className:"truncate",children:(0,se.jsx)(Ae,{variant:"link",className:"block h-auto max-w-full truncate rounded-none p-0 text-left font-mono text-[11.5px] font-bold text-foreground",title:`Open ${s}`,onClick:()=>a("primitive",{identity:i}),children:String(l.id)})}),(0,se.jsxs)(Cn,{className:"whitespace-normal",children:[(0,se.jsx)("div",{className:"text-[12.5px] font-semibold",children:o}),(0,se.jsx)("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-zinc-400",children:s})]}),r&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(QC,{named:u,none:"all patterns",said:u===void 0,label:"Matching globs"}),(0,se.jsx)(QC,{named:AC(l.rationale),none:"none",said:!1,label:"Rationale"})]}),n&&(0,se.jsx)(QC,{named:AC(l.mixins),none:"none",said:!1,label:"Mixins"}),(0,se.jsx)(Cn,{children:(0,se.jsx)(Ae,{variant:"ghost",size:"icon",className:"ml-auto size-6 rounded-[7px] border border-transparent text-zinc-300 group-hover/row:border-zinc-200 group-hover/row:bg-background group-hover/row:text-zinc-400 hover:!border-foreground hover:bg-background hover:!text-foreground [&_svg:not([class*='size-'])]:size-[13px]","aria-label":`Explain ${i}`,onClick:()=>a("explanation",{identity:i}),children:(0,se.jsx)(hn,{})})})]},i)})})]})})}function QC({named:t,none:e,said:a,label:r}){return(0,se.jsx)(Cn,{"aria-label":r,children:(0,se.jsx)("div",{className:"flex min-w-0 flex-wrap content-start justify-end gap-1",children:t===void 0||t.length===0?(0,se.jsx)("span",{className:`text-[10.5px] ${a?"text-destructive":"text-zinc-300"}`,children:e}):t.map(n=>(0,se.jsx)(hi,{title:n,className:"block max-w-full truncate rounded-[5px] bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] font-normal text-zinc-700",children:n},n))})})}var NC=L(F(),1);var Sue=L(F(),1);var Tz=1,fW=.9,dW=.8,hW=.17,EC=.1,DC=.999,pW=.9999,mW=.99,gW=/[\\\/_+.#"@\[\(\{&]/,OW=/[\\\/_+.#"@\[\(\{&]/g,xW=/[\s-]/,Rz=/[\s-]/g;function $C(t,e,a,r,n,i,o){if(i===e.length)return n===t.length?Tz:mW;var s=`${n},${i}`;if(o[s]!==void 0)return o[s];for(var l=r.charAt(i),u=a.indexOf(l,n),c=0,f,d,h,p;u>=0;)f=$C(t,e,a,r,u+1,i+1,o),f>c&&(u===n?f*=Tz:gW.test(t.charAt(u-1))?(f*=dW,h=t.slice(n,u-1).match(OW),h&&n>0&&(f*=Math.pow(DC,h.length))):xW.test(t.charAt(u-1))?(f*=fW,p=t.slice(n,u-1).match(Rz),p&&n>0&&(f*=Math.pow(DC,p.length))):(f*=hW,n>0&&(f*=Math.pow(DC,u-n))),t.charAt(u)!==e.charAt(i)&&(f*=pW)),(f<EC&&a.charAt(u-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&a.charAt(u-1)!==r.charAt(i))&&(d=$C(t,e,a,r,u+1,i+2,o),d*EC>f&&(f=d*EC)),f>c&&(c=f),u=a.indexOf(l,u+1);return o[s]=c,c}function Pz(t){return t.toLowerCase().replace(Rz," ")}function Iz(t,e,a){return t=a&&a.length>0?`${t+" "+a.join(" ")}`:t,$C(t,e,Pz(t),Pz(e),0,0,{})}var J=L(F(),1);var Xh='[cmdk-group=""]',BC='[cmdk-group-items=""]',yW='[cmdk-group-heading=""]',Qz='[cmdk-item=""]',Az=`${Qz}:not([aria-disabled="true"])`,_C="cmdk-item-select",df="data-value",bW=(t,e,a)=>Iz(t,e,a),Mz=J.createContext(void 0),qh=()=>J.useContext(Mz),Ez=J.createContext(void 0),zC=()=>J.useContext(Ez),Dz=J.createContext(void 0),$z=J.forwardRef((t,e)=>{let a=hf(()=>{var P,H;return{search:"",value:(H=(P=t.value)!=null?P:t.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=hf(()=>new Set),n=hf(()=>new Map),i=hf(()=>new Map),o=hf(()=>new Set),s=Bz(t),{label:l,children:u,value:c,onValueChange:f,filter:d,shouldFilter:h,loop:p,disablePointerSelection:m=!1,vimBindings:x=!0,...g}=t,O=Dt(),y=Dt(),b=Dt(),v=J.useRef(null),S=AW();au(()=>{if(c!==void 0){let P=c.trim();a.current.value=P,w.emit()}},[c]),au(()=>{S(6,R)},[]);let w=J.useMemo(()=>({subscribe:P=>(o.current.add(P),()=>o.current.delete(P)),snapshot:()=>a.current,setState:(P,H,N)=>{var M,j,de,ee;if(!Object.is(a.current[P],H)){if(a.current[P]=H,P==="search")A(),Q(),S(1,D);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(b);Z?Z.focus():(M=document.getElementById(O))==null||M.focus()}if(S(7,()=>{var Z;a.current.selectedItemId=(Z=B())==null?void 0:Z.id,w.emit()}),N||S(5,R),((j=s.current)==null?void 0:j.value)!==void 0){let Z=H??"";(ee=(de=s.current).onValueChange)==null||ee.call(de,Z);return}}w.emit()}},emit:()=>{o.current.forEach(P=>P())}}),[]),k=J.useMemo(()=>({value:(P,H,N)=>{var M;H!==((M=i.current.get(P))==null?void 0:M.value)&&(i.current.set(P,{value:H,keywords:N}),a.current.filtered.items.set(P,T(H,N)),S(2,()=>{Q(),w.emit()}))},item:(P,H)=>(r.current.add(P),H&&(n.current.has(H)?n.current.get(H).add(P):n.current.set(H,new Set([P]))),S(3,()=>{A(),Q(),a.current.value||D(),w.emit()}),()=>{i.current.delete(P),r.current.delete(P),a.current.filtered.items.delete(P);let N=B();S(4,()=>{A(),N?.getAttribute("id")===P&&D(),w.emit()})}),group:P=>(n.current.has(P)||n.current.set(P,new Set),()=>{i.current.delete(P),n.current.delete(P)}),filter:()=>s.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:O,inputId:b,labelId:y,listInnerRef:v}),[]);function T(P,H){var N,M;let j=(M=(N=s.current)==null?void 0:N.filter)!=null?M:bW;return P?j(P,a.current.search,H):0}function Q(){if(!a.current.search||s.current.shouldFilter===!1)return;let P=a.current.filtered.items,H=[];a.current.filtered.groups.forEach(M=>{let j=n.current.get(M),de=0;j.forEach(ee=>{let Z=P.get(ee);de=Math.max(Z,de)}),H.push([M,de])});let N=v.current;W().sort((M,j)=>{var de,ee;let Z=M.getAttribute("id"),qe=j.getAttribute("id");return((de=P.get(qe))!=null?de:0)-((ee=P.get(Z))!=null?ee:0)}).forEach(M=>{let j=M.closest(BC);j?j.appendChild(M.parentElement===j?M:M.closest(`${BC} > *`)):N.appendChild(M.parentElement===N?M:M.closest(`${BC} > *`))}),H.sort((M,j)=>j[1]-M[1]).forEach(M=>{var j;let de=(j=v.current)==null?void 0:j.querySelector(`${Xh}[${df}="${encodeURIComponent(M[0])}"]`);de?.parentElement.appendChild(de)})}function D(){let P=W().find(N=>N.getAttribute("aria-disabled")!=="true"),H=P?.getAttribute(df);w.setState("value",H||void 0)}function A(){var P,H,N,M;if(!a.current.search||s.current.shouldFilter===!1){a.current.filtered.count=r.current.size;return}a.current.filtered.groups=new Set;let j=0;for(let de of r.current){let ee=(H=(P=i.current.get(de))==null?void 0:P.value)!=null?H:"",Z=(M=(N=i.current.get(de))==null?void 0:N.keywords)!=null?M:[],qe=T(ee,Z);a.current.filtered.items.set(de,qe),qe>0&&j++}for(let[de,ee]of n.current)for(let Z of ee)if(a.current.filtered.items.get(Z)>0){a.current.filtered.groups.add(de);break}a.current.filtered.count=j}function R(){var P,H,N;let M=B();M&&(((P=M.parentElement)==null?void 0:P.firstChild)===M&&((N=(H=M.closest(Xh))==null?void 0:H.querySelector(yW))==null||N.scrollIntoView({block:"nearest"})),M.scrollIntoView({block:"nearest"}))}function B(){var P;return(P=v.current)==null?void 0:P.querySelector(`${Qz}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=v.current)==null?void 0:P.querySelectorAll(Az))||[])}function $(P){let H=W()[P];H&&w.setState("value",H.getAttribute(df))}function q(P){var H;let N=B(),M=W(),j=M.findIndex(ee=>ee===N),de=M[j+P];(H=s.current)!=null&&H.loop&&(de=j+P<0?M[M.length-1]:j+P===M.length?M[0]:M[j+P]),de&&w.setState("value",de.getAttribute(df))}function re(P){let H=B(),N=H?.closest(Xh),M;for(;N&&!M;)N=P>0?RW(N,Xh):IW(N,Xh),M=N?.querySelector(Az);M?w.setState("value",M.getAttribute(df)):q(P)}let ie=()=>$(W().length-1),z=P=>{P.preventDefault(),P.metaKey?ie():P.altKey?re(1):q(1)},Pe=P=>{P.preventDefault(),P.metaKey?$(0):P.altKey?re(-1):q(-1)};return J.createElement(ue.div,{ref:e,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:P=>{var H;(H=g.onKeyDown)==null||H.call(g,P);let N=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||N))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&z(P);break}case"ArrowDown":{z(P);break}case"p":case"k":{x&&P.ctrlKey&&Pe(P);break}case"ArrowUp":{Pe(P);break}case"Home":{P.preventDefault(),$(0);break}case"End":{P.preventDefault(),ie();break}case"Enter":{P.preventDefault();let M=B();if(M){let j=new Event(_C);M.dispatchEvent(j)}}}}},J.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:MW},l),p0(t,P=>J.createElement(Ez.Provider,{value:w},J.createElement(Mz.Provider,{value:k},P))))}),vW=J.forwardRef((t,e)=>{var a,r;let n=Dt(),i=J.useRef(null),o=J.useContext(Dz),s=qh(),l=Bz(t),u=(r=(a=l.current)==null?void 0:a.forceMount)!=null?r:o?.forceMount;au(()=>{if(!u)return s.item(n,o?.id)},[u]);let c=_z(n,i,[t.value,t.children,i],t.keywords),f=zC(),d=Ms(S=>S.value&&S.value===c.current),h=Ms(S=>u||s.filter()===!1?!0:S.search?S.filtered.items.get(n)>0:!0);J.useEffect(()=>{let S=i.current;if(!(!S||t.disabled))return S.addEventListener(_C,p),()=>S.removeEventListener(_C,p)},[h,t.onSelect,t.disabled]);function p(){var S,w;m(),(w=(S=l.current).onSelect)==null||w.call(S,c.current)}function m(){f.setState("value",c.current,!0)}if(!h)return null;let{disabled:x,value:g,onSelect:O,forceMount:y,keywords:b,...v}=t;return J.createElement(ue.div,{ref:es(i,e),...v,id:n,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!d,"data-disabled":!!x,"data-selected":!!d,onPointerMove:x||s.getDisablePointerSelection()?void 0:m,onClick:x?void 0:p},t.children)}),SW=J.forwardRef((t,e)=>{let{heading:a,children:r,forceMount:n,...i}=t,o=Dt(),s=J.useRef(null),l=J.useRef(null),u=Dt(),c=qh(),f=Ms(h=>n||c.filter()===!1?!0:h.search?h.filtered.groups.has(o):!0);au(()=>c.group(o),[]),_z(o,s,[t.value,t.heading,l]);let d=J.useMemo(()=>({id:o,forceMount:n}),[n]);return J.createElement(ue.div,{ref:es(s,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},a&&J.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},a),p0(t,h=>J.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?u:void 0},J.createElement(Dz.Provider,{value:d},h))))}),wW=J.forwardRef((t,e)=>{let{alwaysRender:a,...r}=t,n=J.useRef(null),i=Ms(o=>!o.search);return!a&&!i?null:J.createElement(ue.div,{ref:es(n,e),...r,"cmdk-separator":"",role:"separator"})}),CW=J.forwardRef((t,e)=>{let{onValueChange:a,...r}=t,n=t.value!=null,i=zC(),o=Ms(u=>u.search),s=Ms(u=>u.selectedItemId),l=qh();return J.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),J.createElement(ue.input,{ref:e,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":s,id:l.inputId,type:"text",value:n?t.value:o,onChange:u=>{n||i.setState("search",u.target.value),a?.(u.target.value)}})}),kW=J.forwardRef((t,e)=>{let{children:a,label:r="Suggestions",...n}=t,i=J.useRef(null),o=J.useRef(null),s=Ms(u=>u.selectedItemId),l=qh();return J.useEffect(()=>{if(o.current&&i.current){let u=o.current,c=i.current,f,d=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let h=u.offsetHeight;c.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return d.observe(u),()=>{cancelAnimationFrame(f),d.unobserve(u)}}},[]),J.createElement(ue.div,{ref:es(i,e),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:l.listId},p0(t,u=>J.createElement("div",{ref:es(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),LW=J.forwardRef((t,e)=>{let{open:a,onOpenChange:r,overlayClassName:n,contentClassName:i,container:o,...s}=t;return J.createElement(Rv,{open:a,onOpenChange:r},J.createElement(Iv,{container:o},J.createElement(Av,{"cmdk-overlay":"",className:n}),J.createElement(Qv,{"aria-label":t.label,"cmdk-dialog":"",className:i},J.createElement($z,{ref:e,...s}))))}),TW=J.forwardRef((t,e)=>Ms(a=>a.filtered.count===0)?J.createElement(ue.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),PW=J.forwardRef((t,e)=>{let{progress:a,children:r,label:n="Loading...",...i}=t;return J.createElement(ue.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},p0(t,o=>J.createElement("div",{"aria-hidden":!0},o)))}),ru=Object.assign($z,{List:kW,Item:vW,Input:CW,Group:SW,Separator:wW,Dialog:LW,Empty:TW,Loading:PW});function RW(t,e){let a=t.nextElementSibling;for(;a;){if(a.matches(e))return a;a=a.nextElementSibling}}function IW(t,e){let a=t.previousElementSibling;for(;a;){if(a.matches(e))return a;a=a.previousElementSibling}}function Bz(t){let e=J.useRef(t);return au(()=>{e.current=t}),e}var au=typeof window>"u"?J.useEffect:J.useLayoutEffect;function hf(t){let e=J.useRef();return e.current===void 0&&(e.current=t()),e}function Ms(t){let e=zC(),a=()=>t(e.snapshot());return J.useSyncExternalStore(e.subscribe,a,a)}function _z(t,e,a,r=[]){let n=J.useRef(),i=qh();return au(()=>{var o;let s=(()=>{var u;for(let c of a){if(typeof c=="string")return c.trim();if(typeof c=="object"&&"current"in c)return c.current?(u=c.current.textContent)==null?void 0:u.trim():n.current}})(),l=r.map(u=>u.trim());i.value(t,s,l),(o=e.current)==null||o.setAttribute(df,s),n.current=s}),n}var AW=()=>{let[t,e]=J.useState(),a=hf(()=>new Map);return au(()=>{a.current.forEach(r=>r()),a.current=new Map},[t]),(r,n)=>{a.current.set(r,n),e({})}};function QW(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function p0({asChild:t,children:e},a){return t&&J.isValidElement(e)?J.cloneElement(QW(e),{ref:e.ref},a(e.props.children)):a(e)}var MW={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};var vi=L(G(),1);function zz({className:t,...e}){return(0,vi.jsx)(ru,{"data-slot":"command",className:pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e})}function Nz({className:t,...e}){return(0,vi.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,vi.jsx)(kd,{className:"size-4 shrink-0 opacity-50"}),(0,vi.jsx)(ru.Input,{"data-slot":"command-input",className:pe("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function Xz({className:t,...e}){return(0,vi.jsx)(ru.List,{"data-slot":"command-list",className:pe("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function qz({...t}){return(0,vi.jsx)(ru.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function Zz({className:t,...e}){return(0,vi.jsx)(ru.Group,{"data-slot":"command-group",className:pe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e})}function Vz({className:t,...e}){return(0,vi.jsx)(ru.Item,{"data-slot":"command-item",className:pe("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...e})}var mt=L(G(),1);function jz({onPick:t}){let[e,a]=(0,NC.useState)(""),[r,n]=(0,NC.useState)(!1),{data:i}=ni(e);return(0,mt.jsxs)(zz,{shouldFilter:!1,className:"relative w-full overflow-visible rounded-[9px] border bg-zinc-50 text-zinc-400 focus-within:border-foreground focus-within:bg-background focus-within:text-zinc-500 [&_[data-slot=command-input-wrapper]]:h-[32px] [&_[data-slot=command-input-wrapper]]:border-0 [&_[data-slot=command-input]]:h-8 [&_[data-slot=command-input]]:text-[12.5px] [&_[data-slot=command-input]]:text-foreground [&_[data-slot=command-input]]:placeholder:text-zinc-400",onFocus:()=>n(!0),onBlur:()=>n(!1),children:[(0,mt.jsx)(Nz,{placeholder:"Search everything",spellCheck:!1,value:e,onValueChange:a,onKeyDown:o=>o.key==="Escape"&&a("")}),r&&e!==""&&(0,mt.jsxs)(Xz,{className:"absolute top-full right-0 left-0 z-50 mt-[7px] max-h-[min(460px,62vh)] rounded-xl border bg-popover p-[5px] shadow-[0_20px_44px_-16px_rgba(0,0,0,0.3)] [&_[cmdk-group-heading]]:px-[11px] [&_[cmdk-group-heading]]:pt-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-bold [&_[cmdk-group-heading]]:tracking-[0.07em] [&_[cmdk-group-heading]]:text-zinc-400 [&_[cmdk-group-heading]]:uppercase [&_[data-slot=command-group]]:p-0",onMouseDown:o=>o.preventDefault(),children:[i?.type==="FaultsByFile"&&(0,mt.jsx)("p",{className:"px-3 py-3.5 text-xs text-zinc-400",children:"The engine will not read this charter, so there is nothing to search."}),i?.type==="Fault"&&(0,mt.jsxs)("p",{className:"px-3 py-3.5 text-xs text-zinc-400",children:[i.data.message," ",i.data.fix]}),i?.type==="ScopedPrimitives"&&(0,mt.jsxs)(mt.Fragment,{children:[(0,mt.jsx)(qz,{className:"px-3 py-3.5 text-xs text-zinc-400",children:"Nothing in the charter says that."}),i.data.primitives.length>0&&(0,mt.jsx)(Zz,{heading:`${i.data.primitives.length} primitive${i.data.primitives.length===1?"":"s"}`,children:i.data.primitives.map(o=>{let{identity:s,kind:l,description:u,scope:c,headers:f}=o.data;return(0,mt.jsxs)(Vz,{value:s,className:"grid cursor-pointer grid-cols-[74px_minmax(0,1fr)_max-content] items-baseline gap-2.5 rounded-lg px-[11px] py-2 data-[selected=true]:bg-zinc-50 data-[selected=true]:outline data-[selected=true]:outline-zinc-200",onSelect:()=>{a(""),n(!1),t(o)},children:[(0,mt.jsx)("span",{className:"font-mono text-[9.5px] font-bold tracking-[0.03em] text-zinc-500 uppercase",children:l}),(0,mt.jsxs)("span",{className:"min-w-0",children:[(0,mt.jsx)("span",{className:"block truncate font-mono text-xs text-foreground",children:(0,mt.jsx)(Uz,{text:String(f.id),word:e})}),(0,mt.jsx)("span",{className:"mt-0.5 block truncate text-[11px] leading-[1.45] text-zinc-400",children:(0,mt.jsx)(Uz,{text:u,word:e})})]}),(0,mt.jsx)(hi,{className:`rounded-[5px] px-1.5 py-0.5 font-mono text-[9.5px] font-bold tracking-[0.03em] ${EW[c]}`,children:c})]},s)})})]})]})]})}var EW={repo:"bg-[#eff6ff] text-[#1d4ed8]",vendor:"bg-[#f6f2ff] text-[#7c3aed]",builtin:"bg-zinc-100 text-zinc-700"};function Uz({text:t,word:e}){let a=t.toLowerCase().indexOf(e.toLowerCase());return a===-1||e===""?(0,mt.jsx)(mt.Fragment,{children:t}):(0,mt.jsxs)(mt.Fragment,{children:[t.slice(0,a),(0,mt.jsx)("mark",{className:"rounded-[2px] bg-[#fff2b8] text-inherit",children:t.slice(a,a+e.length)}),t.slice(a+e.length)]})}var Fz=L(F(),1);var De=L(G(),1);function Hz(){let{open:t}=fo(),e=Fm(),a=MA(),r=ni(),n=EA(),[i,o]=(0,Fz.useState)(null);if(e.data===void 0)return null;let{testSuites:s}=e.data.data,l=new Set(r.data?.type==="ScopedPrimitives"?r.data.data.primitives.map(({data:m})=>m.identity):[]),u=a.data?.type==="TestRunReport"?a.data:void 0,c=m=>u?.data.testCaseReports.filter(({data:x})=>x.suiteName===m)??[],f=s.reduce((m,{data:x})=>m+x.cases.length,0),d=u?.data.testCaseReports.filter(({data:m})=>!m.passed).length??0,h=async()=>{let{data:m}=await a.refetch();if(m?.type!=="TestRunReport")return;let x=m.data.testCaseReports.find(({data:g})=>!g.passed);x!==void 0&&o(x.data.suiteName)},p=async()=>{let m=await n.mutateAsync();o(m),t("testSuite",{name:m}),ll("Test file created",{description:`.cw/test/${m} \xB7 edit the cases, then run them`})};return(0,De.jsxs)("div",{className:"space-y-2.5",children:[(0,De.jsxs)("div",{className:`mb-[18px] flex flex-wrap items-center gap-[11px] rounded-xl border px-[15px] py-[13px] ${u===void 0?"":d>0?"border-[#f6d9d9] bg-[#fef6f6]":"border-[#dcf0e2] bg-[#f5fbf7]"}`,"aria-label":"Test summary",children:[(0,De.jsx)("span",{className:"text-[12.5px] font-bold",children:u===void 0?`${f} case${f===1?"":"s"} in ${s.length} file${s.length===1?"":"s"}`:`${u.data.testCaseReports.length-d} of ${u.data.testCaseReports.length} cases pass`}),(0,De.jsx)("span",{className:"min-w-0 flex-1 text-[11.5px] leading-[1.6] text-zinc-500",children:"A case names the file a change touches or the event it raises, then says what must come up. It runs nothing and asks no agent."}),(0,De.jsx)(Ae,{variant:"outline",disabled:n.isPending,onClick:()=>{p()},children:"New test file"}),(0,De.jsx)(Ae,{disabled:a.isFetching,onClick:()=>{h()},children:"Run all tests"})]}),a.data?.type==="FaultsByFile"&&(0,De.jsx)(cs,{faultsByFile:a.data,label:"Nothing was resolved"}),s.length===0&&(0,De.jsx)("div",{className:"rounded-xl border border-dashed px-[15px] py-3.5 text-[11.5px] leading-[1.6] text-zinc-500",children:"No test file yet. Test files live in .cw/test/."}),s.map(({data:m})=>{let x=c(m.name),g=x.filter(({data:O})=>!O.passed).length;return(0,De.jsxs)("section",{className:"overflow-hidden rounded-[14px] border bg-background","aria-label":m.name,children:[(0,De.jsxs)("div",{className:"flex items-baseline gap-2.5 px-[15px] py-3",children:[(0,De.jsxs)("button",{className:"flex min-w-0 flex-1 cursor-pointer items-baseline gap-2.5 text-left","aria-expanded":i===m.name,onClick:()=>o(i===m.name?null:m.name),children:[(0,De.jsx)("span",{className:"font-mono text-[11.5px] font-bold",children:m.name}),(0,De.jsx)("span",{className:"min-w-0 flex-1 text-[11.5px] text-zinc-500",children:m.description}),(0,De.jsxs)("span",{className:`font-mono text-[10.5px] ${g>0?"text-destructive":"text-zinc-400"}`,children:[m.cases.length," case",m.cases.length===1?"":"s",g>0&&` \xB7 ${g} failing`]})]}),(0,De.jsx)(Ae,{variant:"ghost",className:"h-auto p-0 text-[11.5px] text-zinc-400 hover:bg-transparent hover:text-foreground",onClick:()=>t("testSuite",{name:m.name}),children:"Edit"})]}),m.fault!==void 0&&(0,De.jsxs)("p",{className:"border-t border-[#f7f7f8] px-[15px] py-2.5 text-[11.5px] text-destructive",children:[m.fault.data.message," ",(0,De.jsx)("span",{className:"text-zinc-400",children:m.fault.data.fix})]}),i===m.name&&m.cases.map(({data:O},y)=>(0,De.jsx)(DW,{testCase:O,testCaseReport:x[y],isHeld:O.identity===void 0||l.has(O.identity),onOpen:b=>t("primitive",{identity:b})},y))]},m.name)})]})}function DW({testCase:t,testCaseReport:e,isHeld:a,onOpen:r}){let n=e?.data.unmet,{identity:i,expectation:o}=t;return(0,De.jsxs)("div",{className:`grid grid-cols-[minmax(150px,1fr)_minmax(0,1.4fr)_auto] items-baseline gap-3 border-t border-[#f7f7f8] px-[15px] py-2.5 ${n?"bg-[#fef6f6]":""}`,children:[(0,De.jsx)("span",{className:"font-mono text-[10.5px]",children:t.situation}),n!==void 0?(0,De.jsxs)("span",{className:"font-mono text-[10.5px] text-destructive",children:[n.data.message," ",(0,De.jsx)("span",{className:"text-zinc-400",children:n.data.fix})]}):(0,De.jsx)("span",{className:"font-mono text-[10.5px] text-zinc-400",children:i===void 0||!o.endsWith(i)?o:(0,De.jsxs)(De.Fragment,{children:[o.slice(0,-i.length),a?(0,De.jsx)("button",{className:"cursor-pointer text-[#1d4ed8] underline underline-offset-2",onClick:()=>r(i),children:i}):(0,De.jsxs)(De.Fragment,{children:[(0,De.jsx)("span",{className:"underline decoration-dotted underline-offset-2",children:i})," ",(0,De.jsx)(hi,{className:"rounded-[5px] bg-zinc-100 px-1.5 py-0 font-sans text-[10px] font-normal text-zinc-500",children:"not in the charter"})]})]})}),(0,De.jsx)(hi,{className:`rounded-[5px] px-[7px] py-0 text-[11.5px] font-bold tracking-[0.04em] [font-variant-caps:all-small-caps] ${e===void 0?"bg-zinc-50 text-[#c4c4c8]":e.data.passed?"bg-[#f0fdf4] text-[#15803d]":"bg-[#fdeef0] text-[#b91c1c]"}`,children:e===void 0?"not run":e.data.passed?"pass":"fail"})]})}var Zt=L(G(),1);function Gz(){let{open:t}=fo(),e=IA(),a=ni(),r=QA();if(e.data===void 0)return null;let n=e.data,i=a.data?.type==="ScopedPrimitives"?a.data.data.primitives.filter(({data:s})=>s.scope==="vendor"):[],o=async s=>{let l=await r.mutateAsync(s.split("/").at(-1)??"");if(l!==null)return void ll.error(l.data.message,{description:l.data.fix});ll("Vendor source removed",{description:`${s} \xB7 run Build to compile the charter without it`})};return n.length===0?(0,Zt.jsxs)("div",{className:"flex items-center gap-[9px] rounded-xl border border-dashed px-[15px] py-3.5","aria-label":"Vendor sources",children:[(0,Zt.jsx)("span",{className:"text-xs font-semibold",children:"No vendor source installed"}),(0,Zt.jsx)(Ae,{size:"sm",className:"ml-auto",onClick:()=>t("addVendor",{}),children:"Add vendor source"})]}):(0,Zt.jsxs)("section",{className:"divide-y divide-[#f0f0f0] overflow-hidden rounded-[13px] border bg-background","aria-label":"Vendor sources",children:[(0,Zt.jsx)("h2",{className:"px-3.5 py-[11px] text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Vendor sources"}),n.map(s=>{let l=i.filter(({data:c})=>c.file.startsWith(`${s}/`)),u=[...new Set(l.map(({data:c})=>c.kind))].map(c=>[c,l.filter(({data:f})=>f.kind===c).length]);return(0,Zt.jsxs)("div",{className:"flex flex-col gap-2.5 bg-[#f6f2ff] px-3.5 py-3","aria-label":s,children:[(0,Zt.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,Zt.jsx)("div",{className:"text-[12.5px] font-semibold",children:s.split("/").at(-1)}),(0,Zt.jsxs)("div",{className:"text-[11px] text-zinc-500",children:[(0,Zt.jsxs)("span",{className:"font-mono",children:[s,"/"]})," \xB7 read-only"]})]}),(0,Zt.jsx)("dl",{className:"grid grid-cols-[1fr_auto] gap-x-2 gap-y-1.5 text-[11.5px] text-zinc-500","aria-label":"Primitives by kind",children:u.map(([c,f])=>(0,Zt.jsxs)("div",{className:"contents",children:[(0,Zt.jsx)("dt",{children:c}),(0,Zt.jsx)("dd",{className:"font-mono text-[10.5px] text-zinc-400",children:f})]},c))}),(0,Zt.jsx)(Ae,{size:"sm",variant:"outline",className:"self-start",disabled:r.isPending,onClick:()=>{o(s)},children:"Remove"})]},s)}),(0,Zt.jsx)("div",{className:"px-3.5 py-[11px]",children:(0,Zt.jsx)(Ae,{size:"sm",variant:"outline",onClick:()=>t("addVendor",{}),children:"Add source"})})]})}var nu=L(G(),1),Yz=({...t})=>(0,nu.jsx)(XA,{theme:"light",className:"toaster group",icons:{success:(0,nu.jsx)(Ho,{className:"size-4"}),info:(0,nu.jsx)(Cd,{className:"size-4"}),warning:(0,nu.jsx)(Wo,{className:"size-4"}),error:(0,nu.jsx)(Yo,{className:"size-4"}),loading:(0,nu.jsx)(Go,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t});var Ge=L(G(),1),$W=[["repo","Repo Charter"],["vendor","Vendor"],["test","Test"]],XC="rounded-2xl border bg-background px-[22px] py-5";function BW(){let[t,e]=(0,Zh.useState)("repo"),[a,r]=(0,Zh.useState)(null),{open:n}=fo();return(0,Ge.jsxs)(Ge.Fragment,{children:[(0,Ge.jsxs)("header",{className:"sticky top-0 z-20 flex h-14 items-center gap-3 border-b bg-background px-[26px]",children:[(0,Ge.jsxs)("span",{className:"flex items-center gap-[9px] text-[13.5px] font-bold tracking-[-0.01em]",children:[(0,Ge.jsx)("img",{src:"./logo.png",alt:"",className:"size-[22px] object-contain"}),"Cherry Works"]}),(0,Ge.jsx)("span",{className:"font-mono text-[11.5px] text-zinc-400"}),(0,Ge.jsx)("div",{className:"ml-auto flex w-full max-w-[460px]",children:(0,Ge.jsx)(jz,{onPick:({data:{identity:i,kind:o,scope:s}})=>{e(s==="vendor"?"vendor":"repo"),r(o),n("primitive",{identity:i})}})}),(0,Ge.jsx)(Ae,{variant:"outline",onClick:()=>n("buildPreview",{}),children:"Build"}),(0,Ge.jsx)(Ae,{variant:"outline",onClick:()=>n("doctor",{}),children:"Doctor"})]}),(0,Ge.jsx)("main",{className:"mx-auto max-w-[1120px] px-[26px] pt-[22px] pb-[60px]",children:(0,Ge.jsxs)(l0,{value:t,onValueChange:i=>{e(i),r(null)},children:[(0,Ge.jsx)(u0,{className:"mb-4 h-auto w-full gap-1 rounded-[11px] bg-[#e9e9ec] p-1",children:$W.map(([i,o])=>(0,Ge.jsx)(_h,{value:i,className:"h-auto rounded-lg py-[9px] text-[12.5px] font-semibold text-zinc-500 data-[state=active]:shadow-[0_1px_3px_rgba(0,0,0,0.09)]",children:o},i))}),(0,Ge.jsx)(Jl,{value:"repo",className:XC,children:(0,Ge.jsx)(MC,{scopes:["repo","builtin"],kind:a,onKindChange:r})}),(0,Ge.jsxs)(Jl,{value:"vendor",className:`${XC} grid items-start gap-4 md:has-[>section]:grid-cols-[210px_minmax(0,1fr)]`,children:[(0,Ge.jsx)(Gz,{}),(0,Ge.jsx)(MC,{scopes:["vendor"],kind:a,onKindChange:r})]}),(0,Ge.jsx)(Jl,{value:"test",className:XC,children:(0,Ge.jsx)(Hz,{})})]})}),(0,Ge.jsx)(Yz,{})]})}var _W=new Db;(0,Wz.createRoot)(document.getElementById("root")).render((0,Ge.jsx)(Zh.StrictMode,{children:(0,Ge.jsx)(Cb,{client:_W,children:(0,Ge.jsx)(Sz,{children:(0,Ge.jsx)(BW,{})})})}));
139
+ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+Tr(a.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(a);throw a}}},Wl=new SC;function it(t,e){return Wl.parse(t,e)}it.options=it.setOptions=function(t){return Wl.setOptions(t),it.defaults=Wl.defaults,K5(it.defaults),it};it.getDefaults=pC;it.defaults=Kl;function G8(...t){return Wl.use(...t),it.defaults=Wl.defaults,K5(it.defaults),it}it.use=G8;it.walkTokens=function(t,e){return Wl.walkTokens(t,e)};it.parseInline=Wl.parseInline;it.Parser=$n;it.parser=$n.parse;it.Renderer=s0;it.TextRenderer=vC;it.Lexer=Dn;it.lexer=Dn.lex;it.Tokenizer=o0;it.Hooks=Eh;it.parse=it;var Qse=it.options,Mse=it.setOptions,Ese=it.walkTokens,Dse=it.parseInline;var $se=$n.parse,Bse=Dn.lex;var Vse=L(F(),1);var zh=L(G(),1);function l0({className:t,orientation:e="horizontal",...a}){return(0,zh.jsx)(Cl.Root,{"data-slot":"tabs","data-orientation":e,orientation:e,className:pe("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",t),...a})}var Y8=oi("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function u0({className:t,variant:e="default",...a}){return(0,zh.jsx)(Cl.List,{"data-slot":"tabs-list","data-variant":e,className:pe(Y8({variant:e}),t),...a})}function _h({className:t,...e}){return(0,zh.jsx)(Cl.Trigger,{"data-slot":"tabs-trigger",className:pe("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",t),...e})}function Jl({className:t,...e}){return(0,zh.jsx)(Cl.Content,{"data-slot":"tabs-content",className:pe("flex-1 outline-none",t),...e})}var or=L(G(),1),W8=new SC({renderer:{html:({text:t})=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},walkTokens:t=>{(t.type==="link"||t.type==="image")&&/^\s*(javascript|vbscript|data):/i.test(t.href)&&(t.href="#")}}),sz="h-auto flex-none cursor-pointer rounded-md px-[11px] py-[5px] text-[11.5px] font-semibold text-zinc-500 data-[state=active]:shadow-[0_1px_2px_rgba(0,0,0,0.08)]";function wC({body:t,onChange:e}){return(0,or.jsxs)(l0,{defaultValue:e===void 0?"preview":"source",className:"gap-0 overflow-hidden rounded-xl border bg-background",children:[(0,or.jsxs)("div",{className:"flex items-center gap-2.5 border-b border-[#f0f0f0] px-[13px] py-[9px]",children:[(0,or.jsx)("span",{className:"text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Body"}),(0,or.jsx)("span",{className:"font-mono text-[10.5px] text-zinc-400",children:"markdown"}),(0,or.jsxs)(u0,{className:"ml-auto h-auto gap-0.5 rounded-lg bg-[#f0f0f2] p-[3px]",children:[(0,or.jsx)(_h,{value:"source",className:sz,children:"Source"}),(0,or.jsx)(_h,{value:"preview",className:sz,children:"Preview"})]})]}),(0,or.jsx)(Jl,{value:"source",className:"h-[300px] flex-none",children:(0,or.jsx)(K8,{body:t,onChange:e})}),(0,or.jsx)(Jl,{value:"preview",children:(0,or.jsx)("div",{className:"min-h-32 px-[18px] py-4 text-[12.5px] leading-[1.65] text-zinc-700 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:font-mono [&_code]:text-xs [&_h1]:mb-[7px] [&_h1]:text-[15px] [&_h1]:font-bold [&_h1]:text-foreground [&_h2]:mt-4 [&_h2]:mb-[7px] [&_h2]:text-[13px] [&_h2]:font-bold [&_h2]:text-foreground [&_strong]:font-semibold [&_strong]:text-foreground [&_li]:ml-5 [&_ol]:list-decimal [&_p]:mb-2 [&_ul]:list-disc",dangerouslySetInnerHTML:{__html:W8.parse(t,{async:!1})}})})]})}function K8({body:t,onChange:e}){let a=(0,lz.useCallback)(r=>{let n=new oe({parent:r,doc:t,extensions:[q5(),j$(F$),iB(),zl.of([...DB,...uB]),oe.lineWrapping,oe.editable.of(e!==void 0),oe.updateListener.of(i=>{i.docChanged&&e?.(i.state.doc.toString())})]});return()=>n.destroy()},[]);return(0,or.jsx)("div",{className:"h-full",ref:a})}var ale=L(F(),1);var uz=L(G(),1);function eu({className:t,type:e,...a}){return(0,uz.jsx)("input",{type:e,"data-slot":"input",className:pe("h-[30px] w-full min-w-0 rounded-lg border border-input bg-background px-[11px] py-1 font-mono text-[11.5px] text-foreground transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30","focus-visible:border-[#d92f45]","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",t),...a})}var ile=L(F(),1);var cz=L(G(),1);function Nh({className:t,...e}){return(0,cz.jsx)(Eg.Root,{"data-slot":"label",className:pe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}var ule=L(F(),1);var Rt=L(G(),1);function CC({...t}){return(0,Rt.jsx)(Ea.Root,{"data-slot":"select",...t})}function kC({...t}){return(0,Rt.jsx)(Ea.Value,{"data-slot":"select-value",...t})}function LC({className:t,size:e="default",children:a,...r}){return(0,Rt.jsxs)(Ea.Trigger,{"data-slot":"select-trigger","data-size":e,className:pe("flex w-fit cursor-pointer items-center justify-between gap-2 rounded-lg border border-input bg-background px-[11px] py-1 font-mono text-[11.5px] whitespace-nowrap text-foreground transition-[color,box-shadow] outline-none focus-visible:border-[#d92f45] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-[30px] data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...r,children:[a,(0,Rt.jsx)(Ea.Icon,{asChild:!0,children:(0,Rt.jsx)(Oc,{className:"size-4 opacity-50"})})]})}function TC({className:t,children:e,position:a="item-aligned",align:r="center",...n}){return(0,Rt.jsx)(Ea.Portal,{children:(0,Rt.jsxs)(Ea.Content,{"data-slot":"select-content",className:pe("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:a,align:r,...n,children:[(0,Rt.jsx)(J8,{}),(0,Rt.jsx)(Ea.Viewport,{className:pe("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),(0,Rt.jsx)(eW,{})]})})}function PC({className:t,children:e,...a}){return(0,Rt.jsxs)(Ea.Item,{"data-slot":"select-item",className:pe("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...a,children:[(0,Rt.jsx)("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,Rt.jsx)(Ea.ItemIndicator,{children:(0,Rt.jsx)(Sd,{className:"size-4"})})}),(0,Rt.jsx)(Ea.ItemText,{children:e})]})}function J8({className:t,...e}){return(0,Rt.jsx)(Ea.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:pe("flex cursor-default items-center justify-center py-1",t),...e,children:(0,Rt.jsx)(wd,{className:"size-4"})})}function eW({className:t,...e}){return(0,Rt.jsx)(Ea.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:pe("flex cursor-default items-center justify-center py-1",t),...e,children:(0,Rt.jsx)(Oc,{className:"size-4"})})}var K=L(G(),1);function RC({identity:t,newKind:e,onDone:a,onClose:r}){let{data:n}=wA(t);if(t===void 0)return(0,K.jsx)(fz,{primitiveSnapshot:null,entityTag:"",newKind:e??"",onDone:a,onClose:r});if(n===void 0)return null;let{answer:i,entityTag:o}=n;return i.type==="Fault"?(0,K.jsx)(hz,{faults:[i]}):i.data.scopedPrimitive.data.scope!=="repo"?(0,K.jsx)(tW,{primitiveSnapshot:i}):(0,K.jsx)(fz,{primitiveSnapshot:i,entityTag:o,newKind:"",onDone:a,onClose:r})}function fz({primitiveSnapshot:t,entityTag:e,newKind:a,onDone:r,onClose:n}){let i=t?.data.scopedPrimitive.data,[o,s]=(0,ff.useState)(i?.kind??a),[l,u]=(0,ff.useState)(i===void 0?"":String(i.headers.id)),[c,f]=(0,ff.useState)(()=>Object.fromEntries(Object.entries(i?.headers??{}).filter(([R])=>R!=="id").map(([R,B])=>[R,typeof B=="string"?B:[...B]]))),[d,h]=(0,ff.useState)(t?.data.body??""),[p,m]=(0,ff.useState)([]),{data:x}=xc(),{data:g}=CA(o),{data:O}=ni(),y=kA(),b=LA(),v=TA(),S=x===void 0?[]:Object.keys(x.data),w=g?.type==="PrimitiveRequirements"?g.data.headers:[],k=O?.type==="ScopedPrimitives"?O.data.primitives.filter(({data:R})=>R.kind==="corpus").map(({data:R})=>R.identity):[],T=Object.fromEntries(w.flatMap(({data:{field:R}})=>{let B=c[R],W=typeof B=="string"?B.trim():(B??[]).map($=>$.trim()).filter($=>$!=="");return W.length===0?[]:[[R,W]]})),Q=R=>m(R.type==="Faults"?R.data.faults:[R]),D=async()=>{let R=t===null?await y.mutateAsync({kind:o,id:l,headers:T,body:d}):await b.mutateAsync({param:{identity:t.data.scopedPrimitive.data.identity},header:{"if-match":e},json:{headers:T,body:d}});if(R.type!=="ScopedPrimitive")return Q(R);r(t===null?"Primitive created":"Primitive saved",`${R.data.file} \xB7 nothing compiled until the next build`)},A=async()=>{if(t===null)return;let R=await v.mutateAsync(t.data.scopedPrimitive.data.identity);if(R!==null)return Q(R);r("Primitive deleted",`${t.data.scopedPrimitive.data.file} \xB7 what still names it is reported by Doctor`)};return(0,K.jsxs)("div",{className:"space-y-3.5",children:[(0,K.jsxs)("div",{className:dz,children:[t===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(co,{label:"kind",htmlFor:"primitive-kind",children:(0,K.jsxs)(CC,{value:o,onValueChange:s,children:[(0,K.jsx)(LC,{id:"primitive-kind",className:"w-full",children:(0,K.jsx)(kC,{})}),(0,K.jsx)(TC,{children:S.map(R=>(0,K.jsx)(PC,{value:R,children:R},R))})]})}),(0,K.jsx)(co,{label:"id",htmlFor:"primitive-id",hint:`.cw/charter/${o}/${l||"<id>"}.md`,children:(0,K.jsx)(eu,{id:"primitive-id",value:l,placeholder:"no-any",spellCheck:!1,onChange:R=>u(R.currentTarget.value)})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(co,{label:"kind",hint:"the identity is the file \u2014 rename by creating a new primitive and deleting this one",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:o})}),(0,K.jsx)(co,{label:"id",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:l})})]}),w.map(({data:{field:R,shape:B,required:W,allowedValues:$}})=>(0,K.jsx)(co,{label:R,htmlFor:`header-${R}`,hint:W?"required":void 0,children:B==="list"?(0,K.jsx)(aW,{field:R,entries:Array.isArray(c[R])?c[R]:[],onChange:q=>f({...c,[R]:q})}):$!==void 0?(0,K.jsxs)(CC,{value:typeof c[R]=="string"?c[R]:"",onValueChange:q=>f({...c,[R]:q}),children:[(0,K.jsx)(LC,{id:`header-${R}`,className:"w-full",children:(0,K.jsx)(kC,{placeholder:"\u2014"})}),(0,K.jsx)(TC,{children:$.map(q=>(0,K.jsx)(PC,{value:q,children:q},q))})]}):(0,K.jsx)(eu,{id:`header-${R}`,spellCheck:!1,autoComplete:"off",value:typeof c[R]=="string"?c[R]:"",list:R==="rationale"?"corpus-identities":void 0,onChange:q=>f({...c,[R]:q.currentTarget.value})})},R))]}),(0,K.jsx)("datalist",{id:"corpus-identities",children:k.map(R=>(0,K.jsx)("option",{value:R},R))}),(0,K.jsx)(wC,{body:d,onChange:h}),p.length>0&&(0,K.jsx)(hz,{faults:p}),(0,K.jsxs)("div",{className:li,children:[(0,K.jsx)(Ae,{onClick:()=>{D()},children:t===null?"Create primitive":"Save"}),(0,K.jsx)(Ae,{variant:"outline",onClick:n,children:"Cancel"}),t!==null&&(0,K.jsx)(Ae,{variant:"destructive",className:"ml-auto",onClick:()=>{A()},children:"Delete"})]})]})}function tW({primitiveSnapshot:t}){let{kind:e,description:a,file:r,scope:n,headers:i}=t.data.scopedPrimitive.data;return(0,K.jsxs)("div",{className:"space-y-3.5",children:[(0,K.jsxs)(Ur,{className:"rounded-xl border-[#7c3aed33] bg-[#f6f2ff]",children:[(0,K.jsx)(jr,{className:"text-[12.5px] font-bold",children:n==="vendor"?"Installed from a vendor, and read-only here.":"Built into cw, and read-only here."}),(0,K.jsx)(Fr,{className:"text-[11.5px] text-zinc-600",children:"To differ from it, author a primitive of your own under an identity of its own."})]}),(0,K.jsxs)("div",{className:dz,children:[(0,K.jsx)(co,{label:"kind",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:e})}),(0,K.jsx)(co,{label:"file",children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:r})}),(0,K.jsx)(co,{label:"description",children:(0,K.jsx)("span",{className:"text-xs",children:a})}),Object.entries(i).filter(([o])=>o!=="id"&&o!=="description").map(([o,s])=>(0,K.jsx)(co,{label:o,children:(0,K.jsx)("span",{className:"font-mono text-[11.5px]",children:typeof s=="string"?s:s.join(", ")})},o))]}),(0,K.jsx)(wC,{body:t.data.body})]})}var dz="overflow-hidden rounded-[11px] border border-[#f0f0f0] bg-background divide-y divide-zinc-100";function co({label:t,htmlFor:e,hint:a,children:r}){return(0,K.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,K.jsx)(Nh,{htmlFor:e,className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:t}),(0,K.jsx)("div",{className:"min-w-0 flex-1",children:r}),a!==void 0&&(0,K.jsx)("span",{className:"max-w-[45%] shrink text-right text-[11.5px] text-zinc-400",children:a})]})}function aW({field:t,entries:e,onChange:a}){let r=e.length===0?[""]:e;return(0,K.jsxs)("div",{className:"flex flex-col gap-1.5",children:[r.map((n,i)=>(0,K.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,K.jsx)(eu,{id:i===0?`header-${t}`:void 0,"aria-label":`${t} ${i+1}`,spellCheck:!1,value:n,onChange:o=>a(r.map((s,l)=>l===i?o.currentTarget.value:s))}),r.length>1&&(0,K.jsx)(Ae,{variant:"outline",size:"icon",className:"size-[26px] shrink-0 rounded-[7px] text-zinc-400 [&_svg:not([class*='size-'])]:size-[11px]","aria-label":`Remove this ${t} entry`,onClick:()=>a(r.filter((o,s)=>s!==i)),children:(0,K.jsx)(sl,{})})]},i)),(0,K.jsxs)(Ae,{variant:"outline",size:"sm",className:"h-auto self-start rounded-[7px] border-dashed border-zinc-300 px-2.5 py-[5px] text-[11px] font-normal text-zinc-500",onClick:()=>a([...r,""]),children:["Add ",t]})]})}function hz({faults:t}){return(0,K.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,K.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was written"}),(0,K.jsx)(Fr,{children:t.map(({data:{message:e,fix:a}})=>(0,K.jsxs)("p",{className:"whitespace-pre-line",children:[e," ",(0,K.jsx)("span",{className:"text-muted-foreground",children:a})]},e))})]})}var c0=L(F(),1);var pt=L(G(),1);function pz({onDone:t,onClose:e}){let[a,r]=(0,c0.useState)(""),[n,i]=(0,c0.useState)(""),[o,s]=(0,c0.useState)(null),l=xc(),u=AA(),c=async()=>{let f=n.trim(),d=await u.mutateAsync({source:a.trim(),...f===""?{}:{version:f}});if(d!==null)return s(d);t("Vendor source added",`${a.trim()}${f===""?"":` @ ${f}`} \xB7 run Build to compile what it adds`)};return(0,pt.jsxs)("div",{className:"space-y-3.5",children:[(0,pt.jsx)("p",{className:"text-[13px] leading-[1.65] text-zinc-700",children:"A vendor source is a repository of primitives laid out by kind."}),(0,pt.jsxs)("div",{className:"divide-y divide-zinc-100 overflow-hidden rounded-[11px] border border-[#f0f0f0]",children:[(0,pt.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,pt.jsx)(Nh,{htmlFor:"vendor-source",className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"source"}),(0,pt.jsx)(eu,{id:"vendor-source",value:a,spellCheck:!1,onChange:f=>r(f.target.value)})]}),(0,pt.jsxs)("div",{className:"flex items-center gap-3 px-[13px] py-2.5",children:[(0,pt.jsx)(Nh,{htmlFor:"vendor-version",className:"w-[118px] shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"version"}),(0,pt.jsx)(eu,{id:"vendor-version",value:n,spellCheck:!1,onChange:f=>i(f.target.value)}),(0,pt.jsx)("span",{className:"max-w-[45%] shrink text-right text-[11.5px] text-zinc-400",children:"a tag, branch or commit; left empty, the source's default"})]})]}),(0,pt.jsxs)("div",{className:"rounded-[11px] border bg-zinc-50 px-3.5 py-3","aria-label":"Reserved directories",children:[(0,pt.jsx)("div",{className:"mb-1 text-[11px] font-bold tracking-[0.07em] text-zinc-400 uppercase",children:"Reserved directories at its root"}),Object.entries(l.data?.data??{}).map(([f,d])=>(0,pt.jsxs)("div",{className:"flex items-baseline gap-[9px] border-t border-zinc-100 py-[7px]",children:[(0,pt.jsxs)("span",{className:"min-w-[150px] font-mono text-[11.5px]",children:[f,"/"]}),(0,pt.jsx)("span",{className:"text-[11.5px] text-zinc-500",children:d})]},f))]}),o!==null&&(0,pt.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,pt.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was installed"}),(0,pt.jsx)(Fr,{children:(0,pt.jsxs)("p",{className:"whitespace-pre-line",children:[o.data.message," ",(0,pt.jsx)("span",{className:"text-muted-foreground",children:o.data.fix})]})})]}),(0,pt.jsxs)("div",{className:li,children:[(0,pt.jsx)(Ae,{disabled:u.isPending||a.trim()==="",onClick:()=>{c()},children:"Add source"}),(0,pt.jsx)(Ae,{variant:"outline",onClick:e,children:"Cancel"})]})]})}var IC=L(F(),1);var It=L(G(),1);function mz({name:t,onDone:e,onClose:a}){let n=Fm().data?.data.testSuites.find(({data:i})=>i.name===t);return n===void 0?null:(0,It.jsx)(rW,{name:t,initialText:n.data.text??"",onDone:e,onClose:a},t)}function rW({name:t,initialText:e,onDone:a,onClose:r}){let[n,i]=(0,IC.useState)(e),[o,s]=(0,IC.useState)(null),l=DA(),u=$A(),c=async()=>{let d=await l.mutateAsync({name:t,text:n});if(typeof d!="string")return s(d);a("Saved",`.cw/test/${t} rewritten \xB7 run the cases again`)},f=async()=>{let d=await u.mutateAsync(t);if(d!==null)return s(d);a("Test file deleted",`.cw/test/${t} removed`)};return(0,It.jsxs)("div",{className:"space-y-3",children:[(0,It.jsxs)("p",{className:"text-xs leading-[1.65] text-zinc-600 [&_code]:font-mono",children:["A case is one situation \u2014 a touched file (",(0,It.jsx)("code",{children:"do.touchFile"}),") or a raised event (",(0,It.jsx)("code",{children:"when"}),") \u2014 and expects one thing:"," ",(0,It.jsx)("code",{children:"activate"}),", ",(0,It.jsx)("code",{children:"run"})," or ",(0,It.jsx)("code",{children:"allow"}),"."]}),(0,It.jsx)("textarea",{"aria-label":"Test file text",className:"h-[340px] w-full resize-y rounded-[11px] border bg-zinc-50 px-3.5 py-3 font-mono text-[11.5px] leading-[1.65] outline-none",spellCheck:!1,value:n,onChange:d=>i(d.target.value)}),o!==null&&(0,It.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,It.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"Refused, and nothing was written"}),(0,It.jsx)(Fr,{children:(0,It.jsxs)("p",{className:"break-words whitespace-pre-line",children:[o.data.message," ",(0,It.jsx)("span",{className:"text-muted-foreground",children:o.data.fix})]})})]}),(0,It.jsx)("p",{className:"text-[11.5px] leading-[1.6] text-zinc-400",children:"Read only when tests run \u2014 never compiled, never read by an agent."}),(0,It.jsxs)("div",{className:li,children:[(0,It.jsx)(Ae,{disabled:l.isPending,onClick:()=>{c()},children:"Save"}),(0,It.jsx)(Ae,{variant:"outline",onClick:r,children:"Cancel"}),(0,It.jsx)(Ae,{variant:"destructive",className:"ml-auto",disabled:u.isPending,onClick:()=>{f()},children:"Delete file"})]})]})}var $le=L(F(),1);var sr=L(G(),1);function gz({...t}){return(0,sr.jsx)(xn.Root,{"data-slot":"dialog",...t})}function nW({...t}){return(0,sr.jsx)(xn.Portal,{"data-slot":"dialog-portal",...t})}function iW({className:t,...e}){return(0,sr.jsx)(xn.Overlay,{"data-slot":"dialog-overlay",className:pe("fixed inset-0 z-50 bg-[rgba(9,9,11,0.35)] data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...e})}function Oz({className:t,children:e,showCloseButton:a=!0,...r}){return(0,sr.jsxs)(nW,{"data-slot":"dialog-portal",children:[(0,sr.jsx)(iW,{}),(0,sr.jsxs)(xn.Content,{"data-slot":"dialog-content",className:pe("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",t),...r,children:[e,a&&(0,sr.jsxs)(xn.Close,{"data-slot":"dialog-close",className:"absolute top-4 right-[18px] cursor-pointer rounded-xs p-0.5 text-zinc-400 ring-offset-background transition-colors hover:text-foreground focus:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,sr.jsx)(sl,{}),(0,sr.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function xz({className:t,...e}){return(0,sr.jsx)("div",{"data-slot":"dialog-header",className:pe("flex flex-col gap-2 text-center sm:text-left",t),...e})}function yz({className:t,...e}){return(0,sr.jsx)(xn.Title,{"data-slot":"dialog-title",className:pe("text-lg leading-none font-semibold",t),...e})}function bz({className:t,...e}){return(0,sr.jsx)(xn.Description,{"data-slot":"dialog-description",className:pe("text-sm text-muted-foreground",t),...e})}var pa=L(G(),1),oW={explanation:{title:()=>"Explain",context:({identity:t})=>t,holdsDraft:!1,render:({identity:t},{open:e})=>(0,pa.jsx)(TE,{identity:t,onExplain:a=>e("explanation",{identity:a})},t)},primitive:{title:({identity:t})=>t,context:()=>"",holdsDraft:!0,render:({identity:t},{close:e})=>(0,pa.jsx)(RC,{identity:t,onDone:f0(e),onClose:e},t)},newPrimitive:{title:()=>"New primitive",context:()=>"",holdsDraft:!0,render:({kind:t},{close:e})=>(0,pa.jsx)(RC,{newKind:t,onDone:f0(e),onClose:e},`new ${t}`)},buildPreview:{title:()=>"cw build",context:()=>"nothing written yet",holdsDraft:!1,render:(t,{open:e})=>(0,pa.jsx)(SE,{onBuilt:a=>e("buildOutcome",{buildAnswer:a})})},buildOutcome:{title:()=>"cw build",context:()=>"",holdsDraft:!1,render:({buildAnswer:t})=>(0,pa.jsx)(wE,{buildAnswer:t})},addVendor:{title:()=>"Add vendor source",context:()=>"",holdsDraft:!0,render:(t,{close:e})=>(0,pa.jsx)(pz,{onDone:f0(e),onClose:e})},testSuite:{title:({name:t})=>`.cw/test/${t}`,context:()=>"",holdsDraft:!0,render:({name:t},{close:e})=>(0,pa.jsx)(mz,{name:t,onDone:f0(e),onClose:e},t)},doctor:{title:()=>"Doctor",context:()=>"cw 0.2.1",holdsDraft:!1,render:(t,{open:e})=>(0,pa.jsx)(LE,{onBuilt:a=>e("buildOutcome",{buildAnswer:a})})}};function f0(t){return(e,a)=>{t(),ll(e,{description:a})}}var vz=(0,tu.createContext)(null);function fo(){return(0,tu.useContext)(vz)}function Sz({children:t}){let[e,a]=(0,tu.useState)(null),[r,n]=(0,tu.useState)(!1),i={open:(s,l)=>{a({name:s,params:l}),n(!0)},close:()=>n(!1)},o=e===null?null:oW[e.name];return(0,pa.jsxs)(vz.Provider,{value:i,children:[t,(0,pa.jsx)(gz,{open:r,onOpenChange:n,children:e!==null&&o!==null&&(0,pa.jsxs)(Oz,{className:"flex max-h-[88vh] w-[920px] max-w-[calc(100%-48px)] flex-col gap-0 overflow-hidden rounded-[15px] border-0 p-0 shadow-[0_34px_80px_-22px_rgba(0,0,0,0.4)] sm:max-w-[calc(100%-48px)]",onInteractOutside:s=>o.holdsDraft&&s.preventDefault(),onEscapeKeyDown:s=>o.holdsDraft&&s.preventDefault(),children:[(0,pa.jsxs)(xz,{className:"flex-row items-baseline gap-2.5 border-b border-[#f0f0f0] py-[15px] pr-12 pl-[18px]",children:[(0,pa.jsx)(yz,{className:"text-[14.5px] font-bold tracking-[-0.01em]",children:o.title(e.params)}),(0,pa.jsx)(bz,{className:"font-mono text-[11px] text-zinc-400",children:o.context(e.params)})]}),(0,pa.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-[18px]",children:o.render(e.params,i)})]})})]})}var h0=L(F(),1);var Wle=L(F(),1);var sW=L(G(),1),wz=oi("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-8 min-w-8 px-1.5",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}});var d0=L(G(),1),Cz=h0.createContext({size:"default",variant:"default",spacing:0});function kz({className:t,variant:e,size:a,spacing:r=0,children:n,...i}){return(0,d0.jsx)(Xd.Root,{"data-slot":"toggle-group","data-variant":e,"data-size":a,"data-spacing":r,style:{"--gap":r},className:pe("group/toggle-group flex w-fit items-center gap-[--spacing(var(--gap))] rounded-md data-[spacing=default]:data-[variant=outline]:shadow-xs",t),...i,children:(0,d0.jsx)(Cz.Provider,{value:{variant:e,size:a,spacing:r},children:n})})}function Lz({className:t,children:e,variant:a,size:r,...n}){let i=h0.useContext(Cz);return(0,d0.jsx)(Xd.Item,{"data-slot":"toggle-group-item","data-variant":i.variant||a,"data-size":i.size||r,"data-spacing":i.spacing,className:pe(wz({variant:i.variant||a,size:i.size||r}),"w-auto min-w-0 shrink-0 px-3 focus:z-10 focus-visible:z-10","data-[spacing=0]:rounded-none data-[spacing=0]:shadow-none data-[spacing=0]:first:rounded-l-md data-[spacing=0]:last:rounded-r-md data-[spacing=0]:data-[variant=outline]:border-l-0 data-[spacing=0]:data-[variant=outline]:first:border-l",t),...n,children:e})}var se=L(G(),1);function MC({scopes:t,kind:e,onKindChange:a}){let{open:r}=fo(),n=xc(),i=ni();if(n.data===void 0||i.data===void 0)return null;let o=n.data.data,s=i.data;if(s.type==="FaultsByFile")return(0,se.jsx)(lW,{faultsByFile:s});if(s.type==="Fault")return(0,se.jsx)(uW,{fault:s});let l=s.data.primitives.filter(({data:d})=>t.includes(d.scope)),u=new Map(Object.keys(o).map(d=>[d,l.filter(({data:h})=>h.kind===d).length])),c=e??[...u].find(([,d])=>d>0)?.[0]??Object.keys(o)[0],f=l.filter(({data:d})=>d.kind===c);return(0,se.jsxs)("div",{className:"min-w-0",children:[(0,se.jsxs)("div",{className:"mb-3 flex items-baseline gap-[9px]",children:[(0,se.jsx)("h2",{className:"text-[12.5px] font-bold",children:"Charter primitives"}),(0,se.jsxs)("span",{className:"text-[11.5px] text-zinc-400",children:[l.length," in this charter"]}),t.includes("repo")&&(0,se.jsxs)(Ae,{size:"sm",variant:"outline",className:"ml-auto",onClick:()=>r("newPrimitive",{kind:c}),children:["New ",c]})]}),(0,se.jsx)(kz,{type:"single",spacing:1.5,"aria-label":"Kinds",className:"mb-3 flex-wrap",value:c,onValueChange:d=>d!==""&&a(d),children:[...u].map(([d,h])=>(0,se.jsxs)(Lz,{value:d,"aria-label":d,className:`group/chip h-auto cursor-pointer gap-1.5 rounded-[9px] border bg-background px-2.5 py-1.5 text-[11.5px] font-medium text-zinc-700 capitalize hover:bg-background hover:text-zinc-700 data-[state=on]:border-foreground data-[state=on]:bg-foreground data-[state=on]:font-semibold data-[state=on]:text-white ${h===0&&d!==c?"opacity-50":""}`,children:[d,(0,se.jsx)(hi,{className:"rounded-none bg-transparent p-0 font-mono text-[10px] font-normal text-zinc-400 group-data-[state=on]/chip:text-white/70",children:h})]},d))}),(0,se.jsxs)("p",{className:"mb-2.5 flex items-baseline gap-2 px-0.5",children:[(0,se.jsx)("span",{className:"shrink-0 text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Activates when"}),(0,se.jsx)("span",{className:"text-xs leading-normal text-zinc-700","aria-label":"Activates when",children:o[c]})]}),f.length===0?(0,se.jsxs)("p",{className:"rounded-[14px] border p-[22px] text-center text-[12.5px] text-zinc-400",children:["No ",c," in this charter yet."]}):(0,se.jsx)(cW,{kind:c,listed:f})]})}function lW({faultsByFile:t}){let e=Object.entries(t.data.files);return(0,se.jsxs)("div",{className:"space-y-3.5",children:[(0,se.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,se.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:"The engine will not read this charter"}),(0,se.jsxs)(Fr,{children:[e.length," file",e.length===1?" is":"s are"," refused, so there is no listing to show. Fix",e.length===1?" it":" them"," and the charter comes back."]})]}),(0,se.jsx)(cs,{faultsByFile:t,label:"Refused files"})]})}function uW({fault:t}){return(0,se.jsxs)(Ur,{variant:"destructive",className:"rounded-xl border-[#f6d9d9] bg-[#fef6f6]",children:[(0,se.jsx)(jr,{className:"text-[12.5px] font-bold text-foreground",children:t.data.message}),(0,se.jsx)(Fr,{children:t.data.fix})]})}function AC(t){return t===void 0?void 0:typeof t=="string"?[t]:t}function cW({kind:t,listed:e}){let{open:a}=fo(),r=t==="guide",n=t!=="mixin";return(0,se.jsx)("div",{className:"overflow-hidden rounded-[14px] border bg-background",children:(0,se.jsxs)(kl,{"aria-label":`${t} primitives`,className:"table-fixed",children:[(0,se.jsx)(bE,{children:(0,se.jsxs)(Tl,{className:"border-[#ececef] bg-zinc-50 hover:bg-zinc-50 [&>th]:h-auto [&>th]:px-[15px] [&>th]:py-[9px] [&>th]:text-[9.5px] [&>th]:font-bold [&>th]:tracking-[0.07em] [&>th]:text-zinc-400 [&>th]:uppercase",children:[(0,se.jsx)(Pl,{className:"w-[170px]",children:"Id"}),(0,se.jsx)(Pl,{children:"Description"}),r&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(Pl,{className:"w-[170px] text-right",children:"Matching globs"}),(0,se.jsx)(Pl,{className:"w-[120px] text-right",children:"Rationale"})]}),n&&(0,se.jsx)(Pl,{className:"w-[120px] text-right",children:"Mixins"}),(0,se.jsx)(Pl,{className:"w-[50px]"})]})}),(0,se.jsx)(Ll,{children:e.map(({data:{identity:i,description:o,file:s,headers:l}})=>{let u=AC(l.globs);return(0,se.jsxs)(Tl,{className:"group/row border-[#f7f7f8] align-top hover:bg-zinc-50 [&>td]:px-[15px] [&>td]:py-3",children:[(0,se.jsx)(Cn,{className:"truncate",children:(0,se.jsx)(Ae,{variant:"link",className:"block h-auto max-w-full truncate rounded-none p-0 text-left font-mono text-[11.5px] font-bold text-foreground",title:`Open ${s}`,onClick:()=>a("primitive",{identity:i}),children:String(l.id)})}),(0,se.jsxs)(Cn,{className:"whitespace-normal",children:[(0,se.jsx)("div",{className:"text-[12.5px] font-semibold",children:o}),(0,se.jsx)("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-zinc-400",children:s})]}),r&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)(QC,{named:u,none:"all patterns",said:u===void 0,label:"Matching globs"}),(0,se.jsx)(QC,{named:AC(l.rationale),none:"none",said:!1,label:"Rationale"})]}),n&&(0,se.jsx)(QC,{named:AC(l.mixins),none:"none",said:!1,label:"Mixins"}),(0,se.jsx)(Cn,{children:(0,se.jsx)(Ae,{variant:"ghost",size:"icon",className:"ml-auto size-6 rounded-[7px] border border-transparent text-zinc-300 group-hover/row:border-zinc-200 group-hover/row:bg-background group-hover/row:text-zinc-400 hover:!border-foreground hover:bg-background hover:!text-foreground [&_svg:not([class*='size-'])]:size-[13px]","aria-label":`Explain ${i}`,onClick:()=>a("explanation",{identity:i}),children:(0,se.jsx)(hn,{})})})]},i)})})]})})}function QC({named:t,none:e,said:a,label:r}){return(0,se.jsx)(Cn,{"aria-label":r,children:(0,se.jsx)("div",{className:"flex min-w-0 flex-wrap content-start justify-end gap-1",children:t===void 0||t.length===0?(0,se.jsx)("span",{className:`text-[10.5px] ${a?"text-destructive":"text-zinc-300"}`,children:e}):t.map(n=>(0,se.jsx)(hi,{title:n,className:"block max-w-full truncate rounded-[5px] bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] font-normal text-zinc-700",children:n},n))})})}var NC=L(F(),1);var Sue=L(F(),1);var Tz=1,fW=.9,dW=.8,hW=.17,EC=.1,DC=.999,pW=.9999,mW=.99,gW=/[\\\/_+.#"@\[\(\{&]/,OW=/[\\\/_+.#"@\[\(\{&]/g,xW=/[\s-]/,Rz=/[\s-]/g;function $C(t,e,a,r,n,i,o){if(i===e.length)return n===t.length?Tz:mW;var s=`${n},${i}`;if(o[s]!==void 0)return o[s];for(var l=r.charAt(i),u=a.indexOf(l,n),c=0,f,d,h,p;u>=0;)f=$C(t,e,a,r,u+1,i+1,o),f>c&&(u===n?f*=Tz:gW.test(t.charAt(u-1))?(f*=dW,h=t.slice(n,u-1).match(OW),h&&n>0&&(f*=Math.pow(DC,h.length))):xW.test(t.charAt(u-1))?(f*=fW,p=t.slice(n,u-1).match(Rz),p&&n>0&&(f*=Math.pow(DC,p.length))):(f*=hW,n>0&&(f*=Math.pow(DC,u-n))),t.charAt(u)!==e.charAt(i)&&(f*=pW)),(f<EC&&a.charAt(u-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&a.charAt(u-1)!==r.charAt(i))&&(d=$C(t,e,a,r,u+1,i+2,o),d*EC>f&&(f=d*EC)),f>c&&(c=f),u=a.indexOf(l,u+1);return o[s]=c,c}function Pz(t){return t.toLowerCase().replace(Rz," ")}function Iz(t,e,a){return t=a&&a.length>0?`${t+" "+a.join(" ")}`:t,$C(t,e,Pz(t),Pz(e),0,0,{})}var J=L(F(),1);var Xh='[cmdk-group=""]',BC='[cmdk-group-items=""]',yW='[cmdk-group-heading=""]',Qz='[cmdk-item=""]',Az=`${Qz}:not([aria-disabled="true"])`,_C="cmdk-item-select",df="data-value",bW=(t,e,a)=>Iz(t,e,a),Mz=J.createContext(void 0),qh=()=>J.useContext(Mz),Ez=J.createContext(void 0),zC=()=>J.useContext(Ez),Dz=J.createContext(void 0),$z=J.forwardRef((t,e)=>{let a=hf(()=>{var P,H;return{search:"",value:(H=(P=t.value)!=null?P:t.defaultValue)!=null?H:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=hf(()=>new Set),n=hf(()=>new Map),i=hf(()=>new Map),o=hf(()=>new Set),s=Bz(t),{label:l,children:u,value:c,onValueChange:f,filter:d,shouldFilter:h,loop:p,disablePointerSelection:m=!1,vimBindings:x=!0,...g}=t,O=Dt(),y=Dt(),b=Dt(),v=J.useRef(null),S=AW();au(()=>{if(c!==void 0){let P=c.trim();a.current.value=P,w.emit()}},[c]),au(()=>{S(6,R)},[]);let w=J.useMemo(()=>({subscribe:P=>(o.current.add(P),()=>o.current.delete(P)),snapshot:()=>a.current,setState:(P,H,N)=>{var M,j,de,ee;if(!Object.is(a.current[P],H)){if(a.current[P]=H,P==="search")A(),Q(),S(1,D);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Z=document.getElementById(b);Z?Z.focus():(M=document.getElementById(O))==null||M.focus()}if(S(7,()=>{var Z;a.current.selectedItemId=(Z=B())==null?void 0:Z.id,w.emit()}),N||S(5,R),((j=s.current)==null?void 0:j.value)!==void 0){let Z=H??"";(ee=(de=s.current).onValueChange)==null||ee.call(de,Z);return}}w.emit()}},emit:()=>{o.current.forEach(P=>P())}}),[]),k=J.useMemo(()=>({value:(P,H,N)=>{var M;H!==((M=i.current.get(P))==null?void 0:M.value)&&(i.current.set(P,{value:H,keywords:N}),a.current.filtered.items.set(P,T(H,N)),S(2,()=>{Q(),w.emit()}))},item:(P,H)=>(r.current.add(P),H&&(n.current.has(H)?n.current.get(H).add(P):n.current.set(H,new Set([P]))),S(3,()=>{A(),Q(),a.current.value||D(),w.emit()}),()=>{i.current.delete(P),r.current.delete(P),a.current.filtered.items.delete(P);let N=B();S(4,()=>{A(),N?.getAttribute("id")===P&&D(),w.emit()})}),group:P=>(n.current.has(P)||n.current.set(P,new Set),()=>{i.current.delete(P),n.current.delete(P)}),filter:()=>s.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:O,inputId:b,labelId:y,listInnerRef:v}),[]);function T(P,H){var N,M;let j=(M=(N=s.current)==null?void 0:N.filter)!=null?M:bW;return P?j(P,a.current.search,H):0}function Q(){if(!a.current.search||s.current.shouldFilter===!1)return;let P=a.current.filtered.items,H=[];a.current.filtered.groups.forEach(M=>{let j=n.current.get(M),de=0;j.forEach(ee=>{let Z=P.get(ee);de=Math.max(Z,de)}),H.push([M,de])});let N=v.current;W().sort((M,j)=>{var de,ee;let Z=M.getAttribute("id"),qe=j.getAttribute("id");return((de=P.get(qe))!=null?de:0)-((ee=P.get(Z))!=null?ee:0)}).forEach(M=>{let j=M.closest(BC);j?j.appendChild(M.parentElement===j?M:M.closest(`${BC} > *`)):N.appendChild(M.parentElement===N?M:M.closest(`${BC} > *`))}),H.sort((M,j)=>j[1]-M[1]).forEach(M=>{var j;let de=(j=v.current)==null?void 0:j.querySelector(`${Xh}[${df}="${encodeURIComponent(M[0])}"]`);de?.parentElement.appendChild(de)})}function D(){let P=W().find(N=>N.getAttribute("aria-disabled")!=="true"),H=P?.getAttribute(df);w.setState("value",H||void 0)}function A(){var P,H,N,M;if(!a.current.search||s.current.shouldFilter===!1){a.current.filtered.count=r.current.size;return}a.current.filtered.groups=new Set;let j=0;for(let de of r.current){let ee=(H=(P=i.current.get(de))==null?void 0:P.value)!=null?H:"",Z=(M=(N=i.current.get(de))==null?void 0:N.keywords)!=null?M:[],qe=T(ee,Z);a.current.filtered.items.set(de,qe),qe>0&&j++}for(let[de,ee]of n.current)for(let Z of ee)if(a.current.filtered.items.get(Z)>0){a.current.filtered.groups.add(de);break}a.current.filtered.count=j}function R(){var P,H,N;let M=B();M&&(((P=M.parentElement)==null?void 0:P.firstChild)===M&&((N=(H=M.closest(Xh))==null?void 0:H.querySelector(yW))==null||N.scrollIntoView({block:"nearest"})),M.scrollIntoView({block:"nearest"}))}function B(){var P;return(P=v.current)==null?void 0:P.querySelector(`${Qz}[aria-selected="true"]`)}function W(){var P;return Array.from(((P=v.current)==null?void 0:P.querySelectorAll(Az))||[])}function $(P){let H=W()[P];H&&w.setState("value",H.getAttribute(df))}function q(P){var H;let N=B(),M=W(),j=M.findIndex(ee=>ee===N),de=M[j+P];(H=s.current)!=null&&H.loop&&(de=j+P<0?M[M.length-1]:j+P===M.length?M[0]:M[j+P]),de&&w.setState("value",de.getAttribute(df))}function re(P){let H=B(),N=H?.closest(Xh),M;for(;N&&!M;)N=P>0?RW(N,Xh):IW(N,Xh),M=N?.querySelector(Az);M?w.setState("value",M.getAttribute(df)):q(P)}let ie=()=>$(W().length-1),z=P=>{P.preventDefault(),P.metaKey?ie():P.altKey?re(1):q(1)},Pe=P=>{P.preventDefault(),P.metaKey?$(0):P.altKey?re(-1):q(-1)};return J.createElement(ue.div,{ref:e,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:P=>{var H;(H=g.onKeyDown)==null||H.call(g,P);let N=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||N))switch(P.key){case"n":case"j":{x&&P.ctrlKey&&z(P);break}case"ArrowDown":{z(P);break}case"p":case"k":{x&&P.ctrlKey&&Pe(P);break}case"ArrowUp":{Pe(P);break}case"Home":{P.preventDefault(),$(0);break}case"End":{P.preventDefault(),ie();break}case"Enter":{P.preventDefault();let M=B();if(M){let j=new Event(_C);M.dispatchEvent(j)}}}}},J.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:MW},l),p0(t,P=>J.createElement(Ez.Provider,{value:w},J.createElement(Mz.Provider,{value:k},P))))}),vW=J.forwardRef((t,e)=>{var a,r;let n=Dt(),i=J.useRef(null),o=J.useContext(Dz),s=qh(),l=Bz(t),u=(r=(a=l.current)==null?void 0:a.forceMount)!=null?r:o?.forceMount;au(()=>{if(!u)return s.item(n,o?.id)},[u]);let c=_z(n,i,[t.value,t.children,i],t.keywords),f=zC(),d=Ms(S=>S.value&&S.value===c.current),h=Ms(S=>u||s.filter()===!1?!0:S.search?S.filtered.items.get(n)>0:!0);J.useEffect(()=>{let S=i.current;if(!(!S||t.disabled))return S.addEventListener(_C,p),()=>S.removeEventListener(_C,p)},[h,t.onSelect,t.disabled]);function p(){var S,w;m(),(w=(S=l.current).onSelect)==null||w.call(S,c.current)}function m(){f.setState("value",c.current,!0)}if(!h)return null;let{disabled:x,value:g,onSelect:O,forceMount:y,keywords:b,...v}=t;return J.createElement(ue.div,{ref:es(i,e),...v,id:n,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!d,"data-disabled":!!x,"data-selected":!!d,onPointerMove:x||s.getDisablePointerSelection()?void 0:m,onClick:x?void 0:p},t.children)}),SW=J.forwardRef((t,e)=>{let{heading:a,children:r,forceMount:n,...i}=t,o=Dt(),s=J.useRef(null),l=J.useRef(null),u=Dt(),c=qh(),f=Ms(h=>n||c.filter()===!1?!0:h.search?h.filtered.groups.has(o):!0);au(()=>c.group(o),[]),_z(o,s,[t.value,t.heading,l]);let d=J.useMemo(()=>({id:o,forceMount:n}),[n]);return J.createElement(ue.div,{ref:es(s,e),...i,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},a&&J.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},a),p0(t,h=>J.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?u:void 0},J.createElement(Dz.Provider,{value:d},h))))}),wW=J.forwardRef((t,e)=>{let{alwaysRender:a,...r}=t,n=J.useRef(null),i=Ms(o=>!o.search);return!a&&!i?null:J.createElement(ue.div,{ref:es(n,e),...r,"cmdk-separator":"",role:"separator"})}),CW=J.forwardRef((t,e)=>{let{onValueChange:a,...r}=t,n=t.value!=null,i=zC(),o=Ms(u=>u.search),s=Ms(u=>u.selectedItemId),l=qh();return J.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),J.createElement(ue.input,{ref:e,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":s,id:l.inputId,type:"text",value:n?t.value:o,onChange:u=>{n||i.setState("search",u.target.value),a?.(u.target.value)}})}),kW=J.forwardRef((t,e)=>{let{children:a,label:r="Suggestions",...n}=t,i=J.useRef(null),o=J.useRef(null),s=Ms(u=>u.selectedItemId),l=qh();return J.useEffect(()=>{if(o.current&&i.current){let u=o.current,c=i.current,f,d=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let h=u.offsetHeight;c.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return d.observe(u),()=>{cancelAnimationFrame(f),d.unobserve(u)}}},[]),J.createElement(ue.div,{ref:es(i,e),...n,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:l.listId},p0(t,u=>J.createElement("div",{ref:es(o,l.listInnerRef),"cmdk-list-sizer":""},u)))}),LW=J.forwardRef((t,e)=>{let{open:a,onOpenChange:r,overlayClassName:n,contentClassName:i,container:o,...s}=t;return J.createElement(Rv,{open:a,onOpenChange:r},J.createElement(Iv,{container:o},J.createElement(Av,{"cmdk-overlay":"",className:n}),J.createElement(Qv,{"aria-label":t.label,"cmdk-dialog":"",className:i},J.createElement($z,{ref:e,...s}))))}),TW=J.forwardRef((t,e)=>Ms(a=>a.filtered.count===0)?J.createElement(ue.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),PW=J.forwardRef((t,e)=>{let{progress:a,children:r,label:n="Loading...",...i}=t;return J.createElement(ue.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n},p0(t,o=>J.createElement("div",{"aria-hidden":!0},o)))}),ru=Object.assign($z,{List:kW,Item:vW,Input:CW,Group:SW,Separator:wW,Dialog:LW,Empty:TW,Loading:PW});function RW(t,e){let a=t.nextElementSibling;for(;a;){if(a.matches(e))return a;a=a.nextElementSibling}}function IW(t,e){let a=t.previousElementSibling;for(;a;){if(a.matches(e))return a;a=a.previousElementSibling}}function Bz(t){let e=J.useRef(t);return au(()=>{e.current=t}),e}var au=typeof window>"u"?J.useEffect:J.useLayoutEffect;function hf(t){let e=J.useRef();return e.current===void 0&&(e.current=t()),e}function Ms(t){let e=zC(),a=()=>t(e.snapshot());return J.useSyncExternalStore(e.subscribe,a,a)}function _z(t,e,a,r=[]){let n=J.useRef(),i=qh();return au(()=>{var o;let s=(()=>{var u;for(let c of a){if(typeof c=="string")return c.trim();if(typeof c=="object"&&"current"in c)return c.current?(u=c.current.textContent)==null?void 0:u.trim():n.current}})(),l=r.map(u=>u.trim());i.value(t,s,l),(o=e.current)==null||o.setAttribute(df,s),n.current=s}),n}var AW=()=>{let[t,e]=J.useState(),a=hf(()=>new Map);return au(()=>{a.current.forEach(r=>r()),a.current=new Map},[t]),(r,n)=>{a.current.set(r,n),e({})}};function QW(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function p0({asChild:t,children:e},a){return t&&J.isValidElement(e)?J.cloneElement(QW(e),{ref:e.ref},a(e.props.children)):a(e)}var MW={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};var vi=L(G(),1);function zz({className:t,...e}){return(0,vi.jsx)(ru,{"data-slot":"command",className:pe("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e})}function Nz({className:t,...e}){return(0,vi.jsxs)("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[(0,vi.jsx)(kd,{className:"size-4 shrink-0 opacity-50"}),(0,vi.jsx)(ru.Input,{"data-slot":"command-input",className:pe("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function Xz({className:t,...e}){return(0,vi.jsx)(ru.List,{"data-slot":"command-list",className:pe("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function qz({...t}){return(0,vi.jsx)(ru.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...t})}function Zz({className:t,...e}){return(0,vi.jsx)(ru.Group,{"data-slot":"command-group",className:pe("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e})}function Vz({className:t,...e}){return(0,vi.jsx)(ru.Item,{"data-slot":"command-item",className:pe("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...e})}var mt=L(G(),1);function jz({onPick:t}){let[e,a]=(0,NC.useState)(""),[r,n]=(0,NC.useState)(!1),{data:i}=ni(e);return(0,mt.jsxs)(zz,{shouldFilter:!1,className:"relative w-full overflow-visible rounded-[9px] border bg-zinc-50 text-zinc-400 focus-within:border-foreground focus-within:bg-background focus-within:text-zinc-500 [&_[data-slot=command-input-wrapper]]:h-[32px] [&_[data-slot=command-input-wrapper]]:border-0 [&_[data-slot=command-input]]:h-8 [&_[data-slot=command-input]]:text-[12.5px] [&_[data-slot=command-input]]:text-foreground [&_[data-slot=command-input]]:placeholder:text-zinc-400",onFocus:()=>n(!0),onBlur:()=>n(!1),children:[(0,mt.jsx)(Nz,{placeholder:"Search everything",spellCheck:!1,value:e,onValueChange:a,onKeyDown:o=>o.key==="Escape"&&a("")}),r&&e!==""&&(0,mt.jsxs)(Xz,{className:"absolute top-full right-0 left-0 z-50 mt-[7px] max-h-[min(460px,62vh)] rounded-xl border bg-popover p-[5px] shadow-[0_20px_44px_-16px_rgba(0,0,0,0.3)] [&_[cmdk-group-heading]]:px-[11px] [&_[cmdk-group-heading]]:pt-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-bold [&_[cmdk-group-heading]]:tracking-[0.07em] [&_[cmdk-group-heading]]:text-zinc-400 [&_[cmdk-group-heading]]:uppercase [&_[data-slot=command-group]]:p-0",onMouseDown:o=>o.preventDefault(),children:[i?.type==="FaultsByFile"&&(0,mt.jsx)("p",{className:"px-3 py-3.5 text-xs text-zinc-400",children:"The engine will not read this charter, so there is nothing to search."}),i?.type==="Fault"&&(0,mt.jsxs)("p",{className:"px-3 py-3.5 text-xs text-zinc-400",children:[i.data.message," ",i.data.fix]}),i?.type==="ScopedPrimitives"&&(0,mt.jsxs)(mt.Fragment,{children:[(0,mt.jsx)(qz,{className:"px-3 py-3.5 text-xs text-zinc-400",children:"Nothing in the charter says that."}),i.data.primitives.length>0&&(0,mt.jsx)(Zz,{heading:`${i.data.primitives.length} primitive${i.data.primitives.length===1?"":"s"}`,children:i.data.primitives.map(o=>{let{identity:s,kind:l,description:u,scope:c,headers:f}=o.data;return(0,mt.jsxs)(Vz,{value:s,className:"grid cursor-pointer grid-cols-[74px_minmax(0,1fr)_max-content] items-baseline gap-2.5 rounded-lg px-[11px] py-2 data-[selected=true]:bg-zinc-50 data-[selected=true]:outline data-[selected=true]:outline-zinc-200",onSelect:()=>{a(""),n(!1),t(o)},children:[(0,mt.jsx)("span",{className:"font-mono text-[9.5px] font-bold tracking-[0.03em] text-zinc-500 uppercase",children:l}),(0,mt.jsxs)("span",{className:"min-w-0",children:[(0,mt.jsx)("span",{className:"block truncate font-mono text-xs text-foreground",children:(0,mt.jsx)(Uz,{text:String(f.id),word:e})}),(0,mt.jsx)("span",{className:"mt-0.5 block truncate text-[11px] leading-[1.45] text-zinc-400",children:(0,mt.jsx)(Uz,{text:u,word:e})})]}),(0,mt.jsx)(hi,{className:`rounded-[5px] px-1.5 py-0.5 font-mono text-[9.5px] font-bold tracking-[0.03em] ${EW[c]}`,children:c})]},s)})})]})]})]})}var EW={repo:"bg-[#eff6ff] text-[#1d4ed8]",vendor:"bg-[#f6f2ff] text-[#7c3aed]",builtin:"bg-zinc-100 text-zinc-700"};function Uz({text:t,word:e}){let a=t.toLowerCase().indexOf(e.toLowerCase());return a===-1||e===""?(0,mt.jsx)(mt.Fragment,{children:t}):(0,mt.jsxs)(mt.Fragment,{children:[t.slice(0,a),(0,mt.jsx)("mark",{className:"rounded-[2px] bg-[#fff2b8] text-inherit",children:t.slice(a,a+e.length)}),t.slice(a+e.length)]})}var Fz=L(F(),1);var De=L(G(),1);function Hz(){let{open:t}=fo(),e=Fm(),a=MA(),r=ni(),n=EA(),[i,o]=(0,Fz.useState)(null);if(e.data===void 0)return null;let{testSuites:s}=e.data.data,l=new Set(r.data?.type==="ScopedPrimitives"?r.data.data.primitives.map(({data:m})=>m.identity):[]),u=a.data?.type==="TestRunReport"?a.data:void 0,c=m=>u?.data.testCaseReports.filter(({data:x})=>x.suiteName===m)??[],f=s.reduce((m,{data:x})=>m+x.cases.length,0),d=u?.data.testCaseReports.filter(({data:m})=>!m.passed).length??0,h=async()=>{let{data:m}=await a.refetch();if(m?.type!=="TestRunReport")return;let x=m.data.testCaseReports.find(({data:g})=>!g.passed);x!==void 0&&o(x.data.suiteName)},p=async()=>{let m=await n.mutateAsync();o(m),t("testSuite",{name:m}),ll("Test file created",{description:`.cw/test/${m} \xB7 edit the cases, then run them`})};return(0,De.jsxs)("div",{className:"space-y-2.5",children:[(0,De.jsxs)("div",{className:`mb-[18px] flex flex-wrap items-center gap-[11px] rounded-xl border px-[15px] py-[13px] ${u===void 0?"":d>0?"border-[#f6d9d9] bg-[#fef6f6]":"border-[#dcf0e2] bg-[#f5fbf7]"}`,"aria-label":"Test summary",children:[(0,De.jsx)("span",{className:"text-[12.5px] font-bold",children:u===void 0?`${f} case${f===1?"":"s"} in ${s.length} file${s.length===1?"":"s"}`:`${u.data.testCaseReports.length-d} of ${u.data.testCaseReports.length} cases pass`}),(0,De.jsx)("span",{className:"min-w-0 flex-1 text-[11.5px] leading-[1.6] text-zinc-500",children:"A case names the file a change touches or the event it raises, then says what must come up. It runs nothing and asks no agent."}),(0,De.jsx)(Ae,{variant:"outline",disabled:n.isPending,onClick:()=>{p()},children:"New test file"}),(0,De.jsx)(Ae,{disabled:a.isFetching,onClick:()=>{h()},children:"Run all tests"})]}),a.data?.type==="FaultsByFile"&&(0,De.jsx)(cs,{faultsByFile:a.data,label:"Nothing was resolved"}),s.length===0&&(0,De.jsx)("div",{className:"rounded-xl border border-dashed px-[15px] py-3.5 text-[11.5px] leading-[1.6] text-zinc-500",children:"No test file yet. Test files live in .cw/test/."}),s.map(({data:m})=>{let x=c(m.name),g=x.filter(({data:O})=>!O.passed).length;return(0,De.jsxs)("section",{className:"overflow-hidden rounded-[14px] border bg-background","aria-label":m.name,children:[(0,De.jsxs)("div",{className:"flex items-baseline gap-2.5 px-[15px] py-3",children:[(0,De.jsxs)("button",{className:"flex min-w-0 flex-1 cursor-pointer items-baseline gap-2.5 text-left","aria-expanded":i===m.name,onClick:()=>o(i===m.name?null:m.name),children:[(0,De.jsx)("span",{className:"font-mono text-[11.5px] font-bold",children:m.name}),(0,De.jsx)("span",{className:"min-w-0 flex-1 text-[11.5px] text-zinc-500",children:m.description}),(0,De.jsxs)("span",{className:`font-mono text-[10.5px] ${g>0?"text-destructive":"text-zinc-400"}`,children:[m.cases.length," case",m.cases.length===1?"":"s",g>0&&` \xB7 ${g} failing`]})]}),(0,De.jsx)(Ae,{variant:"ghost",className:"h-auto p-0 text-[11.5px] text-zinc-400 hover:bg-transparent hover:text-foreground",onClick:()=>t("testSuite",{name:m.name}),children:"Edit"})]}),m.fault!==void 0&&(0,De.jsxs)("p",{className:"border-t border-[#f7f7f8] px-[15px] py-2.5 text-[11.5px] text-destructive",children:[m.fault.data.message," ",(0,De.jsx)("span",{className:"text-zinc-400",children:m.fault.data.fix})]}),i===m.name&&m.cases.map(({data:O},y)=>(0,De.jsx)(DW,{testCase:O,testCaseReport:x[y],isHeld:O.identity===void 0||l.has(O.identity),onOpen:b=>t("primitive",{identity:b})},y))]},m.name)})]})}function DW({testCase:t,testCaseReport:e,isHeld:a,onOpen:r}){let n=e?.data.unmet,{identity:i,expectation:o}=t;return(0,De.jsxs)("div",{className:`grid grid-cols-[minmax(150px,1fr)_minmax(0,1.4fr)_auto] items-baseline gap-3 border-t border-[#f7f7f8] px-[15px] py-2.5 ${n?"bg-[#fef6f6]":""}`,children:[(0,De.jsx)("span",{className:"font-mono text-[10.5px]",children:t.situation}),n!==void 0?(0,De.jsxs)("span",{className:"font-mono text-[10.5px] text-destructive",children:[n.data.message," ",(0,De.jsx)("span",{className:"text-zinc-400",children:n.data.fix})]}):(0,De.jsx)("span",{className:"font-mono text-[10.5px] text-zinc-400",children:i===void 0||!o.endsWith(i)?o:(0,De.jsxs)(De.Fragment,{children:[o.slice(0,-i.length),a?(0,De.jsx)("button",{className:"cursor-pointer text-[#1d4ed8] underline underline-offset-2",onClick:()=>r(i),children:i}):(0,De.jsxs)(De.Fragment,{children:[(0,De.jsx)("span",{className:"underline decoration-dotted underline-offset-2",children:i})," ",(0,De.jsx)(hi,{className:"rounded-[5px] bg-zinc-100 px-1.5 py-0 font-sans text-[10px] font-normal text-zinc-500",children:"not in the charter"})]})]})}),(0,De.jsx)(hi,{className:`rounded-[5px] px-[7px] py-0 text-[11.5px] font-bold tracking-[0.04em] [font-variant-caps:all-small-caps] ${e===void 0?"bg-zinc-50 text-[#c4c4c8]":e.data.passed?"bg-[#f0fdf4] text-[#15803d]":"bg-[#fdeef0] text-[#b91c1c]"}`,children:e===void 0?"not run":e.data.passed?"pass":"fail"})]})}var Zt=L(G(),1);function Gz(){let{open:t}=fo(),e=IA(),a=ni(),r=QA();if(e.data===void 0)return null;let n=e.data,i=a.data?.type==="ScopedPrimitives"?a.data.data.primitives.filter(({data:s})=>s.scope==="vendor"):[],o=async s=>{let l=await r.mutateAsync(s.split("/").at(-1)??"");if(l!==null)return void ll.error(l.data.message,{description:l.data.fix});ll("Vendor source removed",{description:`${s} \xB7 run Build to compile the charter without it`})};return n.length===0?(0,Zt.jsxs)("div",{className:"flex items-center gap-[9px] rounded-xl border border-dashed px-[15px] py-3.5","aria-label":"Vendor sources",children:[(0,Zt.jsx)("span",{className:"text-xs font-semibold",children:"No vendor source installed"}),(0,Zt.jsx)(Ae,{size:"sm",className:"ml-auto",onClick:()=>t("addVendor",{}),children:"Add vendor source"})]}):(0,Zt.jsxs)("section",{className:"divide-y divide-[#f0f0f0] overflow-hidden rounded-[13px] border bg-background","aria-label":"Vendor sources",children:[(0,Zt.jsx)("h2",{className:"px-3.5 py-[11px] text-[10.5px] font-bold tracking-[0.06em] text-zinc-400 uppercase",children:"Vendor sources"}),n.map(s=>{let l=i.filter(({data:c})=>c.file.startsWith(`${s}/`)),u=[...new Set(l.map(({data:c})=>c.kind))].map(c=>[c,l.filter(({data:f})=>f.kind===c).length]);return(0,Zt.jsxs)("div",{className:"flex flex-col gap-2.5 bg-[#f6f2ff] px-3.5 py-3","aria-label":s,children:[(0,Zt.jsxs)("div",{className:"min-w-0 space-y-0.5",children:[(0,Zt.jsx)("div",{className:"text-[12.5px] font-semibold",children:s.split("/").at(-1)}),(0,Zt.jsxs)("div",{className:"text-[11px] text-zinc-500",children:[(0,Zt.jsxs)("span",{className:"font-mono",children:[s,"/"]})," \xB7 read-only"]})]}),(0,Zt.jsx)("dl",{className:"grid grid-cols-[1fr_auto] gap-x-2 gap-y-1.5 text-[11.5px] text-zinc-500","aria-label":"Primitives by kind",children:u.map(([c,f])=>(0,Zt.jsxs)("div",{className:"contents",children:[(0,Zt.jsx)("dt",{children:c}),(0,Zt.jsx)("dd",{className:"font-mono text-[10.5px] text-zinc-400",children:f})]},c))}),(0,Zt.jsx)(Ae,{size:"sm",variant:"outline",className:"self-start",disabled:r.isPending,onClick:()=>{o(s)},children:"Remove"})]},s)}),(0,Zt.jsx)("div",{className:"px-3.5 py-[11px]",children:(0,Zt.jsx)(Ae,{size:"sm",variant:"outline",onClick:()=>t("addVendor",{}),children:"Add source"})})]})}var nu=L(G(),1),Yz=({...t})=>(0,nu.jsx)(XA,{theme:"light",className:"toaster group",icons:{success:(0,nu.jsx)(Ho,{className:"size-4"}),info:(0,nu.jsx)(Cd,{className:"size-4"}),warning:(0,nu.jsx)(Wo,{className:"size-4"}),error:(0,nu.jsx)(Yo,{className:"size-4"}),loading:(0,nu.jsx)(Go,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...t});var Ge=L(G(),1),$W=[["repo","Repo Charter"],["vendor","Vendor"],["test","Test"]],XC="rounded-2xl border bg-background px-[22px] py-5";function BW(){let[t,e]=(0,Zh.useState)("repo"),[a,r]=(0,Zh.useState)(null),{open:n}=fo();return(0,Ge.jsxs)(Ge.Fragment,{children:[(0,Ge.jsxs)("header",{className:"sticky top-0 z-20 flex h-14 items-center gap-3 border-b bg-background px-[26px]",children:[(0,Ge.jsxs)("span",{className:"flex items-center gap-[9px] text-[13.5px] font-bold tracking-[-0.01em]",children:[(0,Ge.jsx)("img",{src:"./logo.png",alt:"",className:"size-[22px] object-contain"}),"Cherry Works"]}),(0,Ge.jsx)("span",{className:"font-mono text-[11.5px] text-zinc-400"}),(0,Ge.jsx)("div",{className:"ml-auto flex w-full max-w-[460px]",children:(0,Ge.jsx)(jz,{onPick:({data:{identity:i,kind:o,scope:s}})=>{e(s==="vendor"?"vendor":"repo"),r(o),n("primitive",{identity:i})}})}),(0,Ge.jsx)(Ae,{variant:"outline",onClick:()=>n("buildPreview",{}),children:"Build"}),(0,Ge.jsx)(Ae,{variant:"outline",onClick:()=>n("doctor",{}),children:"Doctor"})]}),(0,Ge.jsx)("main",{className:"mx-auto max-w-[1120px] px-[26px] pt-[22px] pb-[60px]",children:(0,Ge.jsxs)(l0,{value:t,onValueChange:i=>{e(i),r(null)},children:[(0,Ge.jsx)(u0,{className:"mb-4 h-auto w-full gap-1 rounded-[11px] bg-[#e9e9ec] p-1",children:$W.map(([i,o])=>(0,Ge.jsx)(_h,{value:i,className:"h-auto rounded-lg py-[9px] text-[12.5px] font-semibold text-zinc-500 data-[state=active]:shadow-[0_1px_3px_rgba(0,0,0,0.09)]",children:o},i))}),(0,Ge.jsx)(Jl,{value:"repo",className:XC,children:(0,Ge.jsx)(MC,{scopes:["repo","builtin"],kind:a,onKindChange:r})}),(0,Ge.jsxs)(Jl,{value:"vendor",className:`${XC} grid items-start gap-4 md:has-[>section]:grid-cols-[210px_minmax(0,1fr)]`,children:[(0,Ge.jsx)(Gz,{}),(0,Ge.jsx)(MC,{scopes:["vendor"],kind:a,onKindChange:r})]}),(0,Ge.jsx)(Jl,{value:"test",className:XC,children:(0,Ge.jsx)(Hz,{})})]})}),(0,Ge.jsx)(Yz,{})]})}var _W=new Db;(0,Wz.createRoot)(document.getElementById("root")).render((0,Ge.jsx)(Zh.StrictMode,{children:(0,Ge.jsx)(Cb,{client:_W,children:(0,Ge.jsx)(Sz,{children:(0,Ge.jsx)(BW,{})})})}));
140
140
  /*! Bundled license information:
141
141
 
142
142
  react/cjs/react.production.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherry-works",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "The charter engine: resolves a charter and compiles it into what a coding agent reads.",
5
5
  "keywords": [
6
6
  "claude-code",