import { Instrumentation } from '@synnaxlabs/alamos';
import { channel, control, framer, Synnax } from '@synnaxlabs/client';
import { CrudeSeries, status as xstatus } from '@synnaxlabs/x';
import { z } from 'zod';
import { aether } from '../../../aether/aether';
import { theming } from '../../../ether';
import { status } from '../../../status/aether';
import { telem } from '../../aether';
import { AbstractSink } from '../../aether/telem';
import { StateProvider } from './state';
export declare const statusZ: z.ZodEnum<{
    failed: "failed";
    acquired: "acquired";
    released: "released";
    overridden: "overridden";
}>;
export type Status = z.infer<typeof statusZ>;
export declare const controllerStateZ: z.ZodObject<{
    name: z.ZodString;
    authority: z.ZodDefault<z.ZodNumber>;
    acquireTrigger: z.ZodNumber;
    status: z.ZodOptional<z.ZodEnum<{
        failed: "failed";
        acquired: "acquired";
        released: "released";
        overridden: "overridden";
    }>>;
    needsControlOf: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUInt32, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>>>>;
}, z.core.$strip>;
interface InternalState {
    client: Synnax | null;
    instrumentation: Instrumentation;
    stateProv: StateProvider;
    addStatus: status.Adder;
    runAsync: status.ErrorHandler;
    theme: theming.Theme;
    prevTrigger: number;
    telemCtx: telem.Context;
}
interface AetherControllerTelem extends telem.Telem {
    needsControlOf: (client: Synnax) => Promise<channel.Keys>;
}
/**
 * @summary Acquires control over a set of channels by opening a writer to a Synnax
 * cluster, and then acts as a factory for telemetry that can be used to send commands
 * to that writer.
 */
export declare class Controller extends aether.Composite<typeof controllerStateZ, InternalState> implements telem.Factory {
    static readonly TYPE = "Controller";
    schema: z.ZodObject<{
        name: z.ZodString;
        authority: z.ZodDefault<z.ZodNumber>;
        acquireTrigger: z.ZodNumber;
        status: z.ZodOptional<z.ZodEnum<{
            failed: "failed";
            acquired: "acquired";
            released: "released";
            overridden: "overridden";
        }>>;
        needsControlOf: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodUInt32, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>>>>;
    }, z.core.$strip>;
    private readonly registry;
    private writer?;
    afterUpdate(ctx: aether.Context): void;
    afterDelete(): void;
    private updateNeedsControlOf;
    private acquire;
    private release;
    set(frame: framer.CrudeFrame | Record<channel.KeyOrName, CrudeSeries>): Promise<void>;
    setAuthority(channels: channel.Keys, value: control.Authority): Promise<void>;
    releaseAuthority(keys: channel.Keys): Promise<void>;
    deleteTelem(t: AetherControllerTelem): void;
    /** @implements telem.Factory to create telemetry that is bound to this controller. */
    create<T>(spec: telem.Spec): T | null;
}
export declare const setChannelValuePropsZ: z.ZodObject<{
    channel: z.ZodNumber;
}, z.core.$strip>;
export type SetChannelValueProps = z.infer<typeof setChannelValuePropsZ>;
export declare class SetChannelValue extends AbstractSink<typeof setChannelValuePropsZ> implements telem.NumberSink, AetherControllerTelem {
    static readonly TYPE = "controlled-numeric-telem-sink";
    private readonly controller;
    private readonly runAsync;
    schema: z.ZodObject<{
        channel: z.ZodNumber;
    }, z.core.$strip>;
    constructor(controller: Controller, runAsync: status.ErrorHandler, props: unknown);
    invalidate(): void;
    cleanup(): void;
    needsControlOf(client: Synnax): Promise<channel.Keys>;
    set(...values: number[]): void;
}
export declare const setChannelValue: (props: SetChannelValueProps) => telem.NumberSinkSpec;
export declare const acquireChannelControlPropsZ: z.ZodObject<{
    authority: z.ZodDefault<z.ZodNumber>;
    channel: z.ZodNumber;
}, z.core.$strip>;
export type AcquireChannelControlProps = z.infer<typeof acquireChannelControlPropsZ>;
export declare class AcquireChannelControl extends AbstractSink<typeof acquireChannelControlPropsZ> implements telem.BooleanSink, AetherControllerTelem {
    static readonly TYPE = "acquire-channel-control";
    private readonly controller;
    private readonly runAsync;
    schema: z.ZodObject<{
        authority: z.ZodDefault<z.ZodNumber>;
        channel: z.ZodNumber;
    }, z.core.$strip>;
    constructor(controller: Controller, runAsync: status.ErrorHandler, props: unknown);
    cleanup(): void;
    needsControlOf(client: Synnax): Promise<channel.Keys>;
    set(acquire: boolean): void;
}
export declare const acquireChannelControl: (props: AcquireChannelControlProps) => telem.BooleanSinkSpec;
export declare const authoritySourceProps: z.ZodObject<{
    channel: z.ZodNumber;
}, z.core.$strip>;
export type AuthoritySourceProps = z.infer<typeof authoritySourceProps>;
export declare const authoritySourceDetailsZ: z.ZodObject<{
    valid: z.ZodBoolean;
    color: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{
        rgba255: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
    }, z.core.$strip>]>, z.ZodTransform<[number, number, number, number], string | [number, number, number] | [number, number, number, number] | {
        rgba255: [number, number, number, number];
    }>>>;
    authority: z.ZodNumber;
}, z.core.$strip>;
export type AuthoritySourceDetails = z.infer<typeof authoritySourceDetailsZ>;
export declare class AuthoritySource extends telem.AbstractSource<typeof authoritySourceProps> implements telem.StatusSource<AuthoritySourceDetails>, AetherControllerTelem {
    static readonly TYPE = "controlled-status-source";
    private readonly prov;
    private valid;
    private stopListening?;
    private readonly controller;
    schema: z.ZodObject<{
        channel: z.ZodNumber;
    }, z.core.$strip>;
    constructor(controller: Controller, prov: StateProvider, props: unknown);
    needsControlOf(): Promise<channel.Keys>;
    private maybeRevalidate;
    value(): xstatus.Status<AuthoritySourceDetails>;
    cleanup(): void;
}
export declare const authoritySource: (props: AuthoritySourceProps) => telem.StatusSourceSpec;
export {};
//# sourceMappingURL=controller.d.ts.map