/**
 * Zenith Intermediate Representation (IR)
 *
 * Phase 1: Parse & Extract
 * This IR represents the parsed structure of a .zen file
 * without any runtime execution or transformation.
 */
/**
 * Structured ES module import metadata
 * Parsed from component scripts, used for deterministic bundling
 */
export interface ScriptImport {
    source: string;
    specifiers: string;
    typeOnly: boolean;
    sideEffect: boolean;
}
/**
 * Component Script IR - represents a component's script block
 * Used for collecting and bundling component scripts
 */
export type ComponentScriptIR = {
    name: string;
    script: string;
    props: string[];
    scriptAttributes: Record<string, string>;
    imports: ScriptImport[];
    instanceId?: string;
    propValues?: Record<string, any>;
    expressions?: ExpressionIR[];
};
export type ZenIR = {
    filePath: string;
    template: TemplateIR;
    script: ScriptIR | null;
    styles: StyleIR[];
    componentScripts?: ComponentScriptIR[];
    pageBindings?: string[];
};
export type TemplateIR = {
    raw: string;
    nodes: TemplateNode[];
    expressions: ExpressionIR[];
};
export type TemplateNode = ElementNode | TextNode | ExpressionNode | ComponentNode | ConditionalFragmentNode | OptionalFragmentNode | LoopFragmentNode | DoctypeNode;
export type DoctypeNode = {
    type: 'doctype';
    name: string;
    publicId: string;
    systemId: string;
    location: SourceLocation;
};
export type ElementNode = {
    type: 'element';
    tag: string;
    attributes: AttributeIR[];
    children: TemplateNode[];
    location: SourceLocation;
    loopContext?: LoopContext;
};
export type ComponentNode = {
    type: 'component';
    name: string;
    attributes: AttributeIR[];
    children: TemplateNode[];
    location: SourceLocation;
    loopContext?: LoopContext;
};
export type TextNode = {
    type: 'text';
    value: string;
    location: SourceLocation;
};
export type ExpressionNode = {
    type: 'expression';
    expression: string;
    location: SourceLocation;
    loopContext?: LoopContext;
};
/**
 * Conditional Fragment Node
 *
 * Represents ternary expressions with JSX branches: {cond ? <A /> : <B />}
 *
 * BOTH branches are compiled at compile time.
 * Runtime toggles visibility — never creates DOM.
 */
export type ConditionalFragmentNode = {
    type: 'conditional-fragment';
    condition: string;
    consequent: TemplateNode[];
    alternate: TemplateNode[];
    location: SourceLocation;
    loopContext?: LoopContext;
};
/**
 * Optional Fragment Node
 *
 * Represents logical AND expressions with JSX: {cond && <A />}
 *
 * Fragment is compiled at compile time.
 * Runtime toggles mount/unmount based on condition.
 */
export type OptionalFragmentNode = {
    type: 'optional-fragment';
    condition: string;
    fragment: TemplateNode[];
    location: SourceLocation;
    loopContext?: LoopContext;
};
/**
 * Loop Fragment Node
 *
 * Represents .map() expressions with JSX body: {items.map(i => <li>...</li>)}
 *
 * Desugars to @for loop semantics at compile time.
 * Body is compiled once, instantiated per item at runtime.
 * Node identity is compiler-owned via stable keys.
 */
export type LoopFragmentNode = {
    type: 'loop-fragment';
    source: string;
    itemVar: string;
    indexVar?: string;
    body: TemplateNode[];
    location: SourceLocation;
    loopContext: LoopContext;
};
export type AttributeIR = {
    name: string;
    value: string | ExpressionIR;
    location: SourceLocation;
    loopContext?: LoopContext;
};
/**
 * Loop context for expressions inside map iterations
 * Phase 7: Tracks loop variables (e.g., todo, index) for expressions inside .map() calls
 */
export type LoopContext = {
    variables: string[];
    mapSource?: string;
};
export type ExpressionIR = {
    id: string;
    code: string;
    location: SourceLocation;
    loopContext?: LoopContext;
};
export type ScriptIR = {
    raw: string;
    attributes: Record<string, string>;
};
export type StyleIR = {
    raw: string;
};
export type SourceLocation = {
    line: number;
    column: number;
};
/**
 * BundlePlan - Compiler-emitted contract for bundler execution
 *
 * If a plan exists, bundling MUST occur.
 * If no plan exists, bundling MUST NOT occur.
 * The bundler performs ZERO inference—it executes exactly what the compiler specifies.
 */
export interface BundlePlan {
    /** Entry point code (not a file path) */
    entry: string;
    /** Target platform */
    platform: 'browser' | 'node';
    /** Output format */
    format: 'esm' | 'cjs';
    /** Directories to resolve modules from */
    resolveRoots: string[];
    /** Virtual modules provided by the compiler */
    virtualModules: Array<{
        id: string;
        code: string;
    }>;
}
