namespace ZB.MOM.WW.ScadaBridge.ScriptAnalysis;

/// <summary>
/// A <b>compile-only</b> mirror of the SiteRuntime
/// <c>TriggerExpressionGlobals</c> bind surface. A trigger expression is a bare
/// boolean expression referencing <c>Attributes["x"]</c> / <c>Children["c"]</c>
/// / <c>Parent</c>; the design-time deploy gate compiles candidate
/// trigger expressions against this type to catch undefined symbols.
///
/// <para>
/// Only the read-only bind surface is reproduced — the runtime
/// <c>ExtractExpression</c> helper and the snapshot-backed constructor are
/// intentionally omitted; they are runtime concerns, not part of what an
/// expression binds against. Member bodies are compile-only and throw
/// <see cref="NotSupportedException"/>.
/// </para>
/// </summary>
public sealed class TriggerCompileSurface
{
    private const string CompileOnly = "compile-only surface";

    /// <summary>Mirrors <c>TriggerExpressionGlobals.Attributes</c>.</summary>
    public ReadOnlyAttributes Attributes => throw new NotSupportedException(CompileOnly);

    /// <summary>Mirrors <c>TriggerExpressionGlobals.Children</c>.</summary>
    public ReadOnlyChildren Children => throw new NotSupportedException(CompileOnly);

    /// <summary>Mirrors <c>TriggerExpressionGlobals.Parent</c>.</summary>
    public ReadOnlyComposition? Parent => throw new NotSupportedException(CompileOnly);

    /// <summary>Compile-only mirror of <c>TriggerExpressionGlobals.ReadOnlyAttributes</c>.</summary>
    public sealed class ReadOnlyAttributes
    {
        /// <summary>Mirrors <c>ReadOnlyAttributes.this[string]</c>.</summary>
        /// <param name="key">The attribute name to look up.</param>
        public object? this[string key] => throw new NotSupportedException(CompileOnly);
    }

    /// <summary>Compile-only mirror of <c>TriggerExpressionGlobals.ReadOnlyComposition</c>.</summary>
    public sealed class ReadOnlyComposition
    {
        /// <summary>Mirrors <c>ReadOnlyComposition.Attributes</c>.</summary>
        public ReadOnlyAttributes Attributes => throw new NotSupportedException(CompileOnly);
    }

    /// <summary>Compile-only mirror of <c>TriggerExpressionGlobals.ReadOnlyChildren</c>.</summary>
    public sealed class ReadOnlyChildren
    {
        /// <summary>Mirrors <c>ReadOnlyChildren.this[string]</c>.</summary>
        /// <param name="compositionName">The composition name to look up.</param>
        public ReadOnlyComposition this[string compositionName] => throw new NotSupportedException(CompileOnly);
    }
}
