#!/usr/bin/env node
import {c,l as l$1,m,o as o$1,B}from'./chunk-T6IDXUUA.js';import'./chunk-JIXHEBGK.js';import'./chunk-QT2LKB3P.js';import'./chunk-XHJ27CER.js';import*as u from'fs';import*as l from'path';import o from'chalk';import S from'ora';async function A(d){let h=process.cwd(),a=l.resolve(h,d);console.log(o.blue(`
\u{1F52E} Aggregating Premise...
`));let c$1=S("Loading sources...").start();try{let e,g=l.join(a,".premise");if(u.existsSync(g)){let{data:r,errors:s}=c(g);if(s.length>0){c$1.warn("Warnings parsing .premise file");for(let n of s)console.log(o.yellow(`  \u26A0 ${n}`));console.log(o.gray(`  Falling back to directory aggregation...
`));}if(r&&!s.some(n=>n.includes("Required")))try{e=await l$1(r,a);}catch(n){console.log(o.yellow(`  \u26A0 Error using .premise file: ${n.message}`)),console.log(o.gray(`  Falling back to directory aggregation...
`));}}e||(e=await m(a)),c$1.succeed("Aggregated all sources");let w=o$1(e),t=B(w);console.log(o.white(`
Sources`)),console.log(o.gray("\u2500".repeat(40))),console.log(`  Purpose files:  ${o.cyan(e.purposeFiles.length.toString())}`),console.log(`  Gate files:     ${o.cyan(e.portalFiles.length.toString())}`),console.log(o.white(`
Symbol Index`)),console.log(o.gray("\u2500".repeat(40)));let $=[{prefix:"#",name:"Components",count:t.component,color:o.green},{prefix:"$",name:"Flows",count:t.flow,color:o.yellow},{prefix:"^",name:"Gates",count:t.gate,color:o.red},{prefix:"!",name:"Signals",count:t.signal,color:o.cyan},{prefix:"~",name:"Aspects",count:t.aspect,color:o.magenta}];for(let{prefix:r,name:s,count:n,color:b}of $)n>0&&console.log(`  ${b(r)} ${s.padEnd(12)} ${o.cyan(n.toString())}`);let x=Object.values(t).reduce((r,s)=>r+s,0);if(console.log(o.gray("\u2500".repeat(40))),console.log(`  Total:          ${o.cyan(x.toString())}`),e.errors.length>0){console.log(o.yellow(`
Errors`)),console.log(o.gray("\u2500".repeat(40)));for(let r of e.errors)console.log(o.red(`  \u2717 [${r.source}] ${r.filePath}: ${r.message}`));}console.log("");}catch(e){c$1.fail("Aggregation failed"),console.log(o.red(`Error: ${e.message}
`)),process.exit(1);}}export{A as premiseAggregateCommand};