export type RuleEffect = "allow" | "deny"; /** What one cell in the matrix is showing. */ export type CellState = "inherit" | RuleEffect; export interface ChannelRule { roleId: string; permission: string; effect: RuleEffect; } /** The choice in the channel's dropdown, before any matrix is drawn. */ export type ScopeChoice = { kind: "everyone"; } | { kind: "template"; templateId: string; } | { kind: "custom"; }; /** The dropdown value that means "this channel has its own rules". */ export declare const CUSTOM_VALUE = "custom"; /** * The dropdown value that means "no rules at all". A word rather than an empty string: the * Select reads "" as "nothing chosen" and paints its placeholder over the label. */ export declare const EVERYONE_VALUE = "everyone"; /** Look up one cell without scanning the whole list per cell. */ export declare function indexRules(rules: ChannelRule[]): Map; export declare function cellState(index: Map, roleId: string, permission: string): CellState; /** * The next state when somebody clicks a cell: inherit, deny, allow, inherit. Deny first, * because taking something away is what people open this to do. */ export declare function nextCellState(current: CellState): CellState; /** Set one cell, dropping the row entirely when it goes back to inherit. */ export declare function withCell(rules: ChannelRule[], roleId: string, permission: string, state: CellState): ChannelRule[]; /** * Which dropdown value a channel is showing. A scope that is not a template is this * channel's own, which is Custom; no scope at all is Everyone. */ export declare function scopeChoiceValue(scopeId: string | null, isTemplate: boolean): string; /** Turn the dropdown value back into what the server event wants. */ export declare function scopeChoiceFromValue(value: string): ScopeChoice; /** * The payload for `server:channels:scope:set`. Templates deliberately do not carry rules: * editing one from a channel would change every other channel using it. */ export declare function scopeSetPayload(choice: ScopeChoice, rules: ChannelRule[]): { templateId?: string | null; custom?: boolean; rules?: ChannelRule[]; }; /** * The dropdown options: Everyone, then each template, then Custom. Custom last, because it * is the escape hatch and reaching for it is the uncommon choice. */ export declare function scopeOptions(templates: { id: string; name: string | null; }[]): { label: string; value: string; }[]; /** * A one-line summary of what a set of rules does. Reading is called out on its own: a role * denied `read_messages` is shown nothing at all rather than a locked channel. */ export declare function describeRules(rules: ChannelRule[], roleNames: Map): string;