/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { ScheduleChange } from "../shared/schedule/editing.js"; import { type AllocationEditing } from "./editing.js"; import { type AllocationDomain, type AllocationValue, type Bin, type Day, type PlacedPeriod, type Selection, type StoredBin } from "./model.js"; /** * What a bin's parts leave unallocated (A70): its quantity less what its parts * hold — all of it with no part; none for a reservation. * * @param bin - The bin * @returns The remainder, never below zero */ export declare function remainderOf(bin: Bin): number; /** What `Split…` takes of a bin (A71): from where, how much there is, and the quantity's bounds and default. */ export interface SplitTake { /** The part it takes off, or `undefined` for what the parts leave unallocated. */ from: string | undefined; /** What there is to take: the part, or the remainder. */ held: number; /** The least and the most it takes, and what it takes unless told otherwise. */ least: number; most: number; initial: number; } /** * What `Split…` takes of a bin (A71, #1362): with some of it unallocated, that * — all of it by default and at most, at least 1 of it (all of it, under 1); * with none, a quantity off a part — its largest, or the one named — half of * it by default, at least 1 (half of it, for a part under 2) and at most the * part less that, so both keep some. A reservation, a bin with nothing on a * resource and nothing left, and a part it does not have split nothing. * * @param bin - The bin * @param from - The part to take off when nothing is left; its largest by default * @returns What it takes, or `undefined` for nothing to split */ export declare function splitOf(bin: Bin, from?: string): SplitTake | undefined; /** * What a drag onto a resource carries of a bin (A39, A73): a link's part, or * a connector's remainder — all of it with no part — or, with nothing left * over, its largest part. * * @param bin - The bin * @param from - The link's resource, for a link's drag * @returns The quantity and the part it leaves, or `undefined` for a part the bin no longer has */ export declare function linkedQuantity(bin: Bin, from: string | undefined): { quantity: number; from: string | undefined; } | undefined; /** What the commands read: the day as drafted and as stored, its rows, and the editing they record through. */ export interface AllocationState { readonly value: AllocationValue; readonly domain: AllocationDomain; /** The plan day. */ readonly day: Date; /** The day as drafted, and as the records hold it. */ readonly plan: Day; readonly held: Day; /** The own row of the period holding the day — the day's, or its week's (#1550) — as drafted, and as stored. */ readonly period: PlacedPeriod; readonly heldPeriod: PlacedPeriod; /** The bins the day's window read, by key: each stored bin's bytes. */ readonly read: ReadonlyMap; /** The editing; `undefined` for a read-only board. */ readonly editing: AllocationEditing | undefined; /** Whether the day's reads have landed and no Publish is under way: a gesture waits for them. */ readonly ready: boolean; /** * Whether what main shows is retained while a narrowing of it is read (#1398, CL8): readable, focusable and * selectable, its controls in place, and every gesture refused until it lands. */ readonly retained?: boolean | undefined; } /** The board's commands. */ export interface AllocationCommands { /** Whether the day takes a gesture now: editable, its reads landed, its records' sessions writable. */ readonly available: boolean; /** The same, as the board's parts ask it. */ canEdit: () => boolean; /** Removes a bin (A76): a committed one stays under Removed from plan until Save; a new one is gone. */ remove(id: string): void; /** Reverts a bin (A76): a committed one back as the day holds it, its row whole; a new one's arrival back to Arrivals. */ revert(id: string): void; /** Unlinks one part of a bin (A68), or every part with no resource named (the inspector's Unlink, A56): what it held there is unallocated again. */ unlink(id: string, resource?: string): void; /** * Sets a bin's quantity (A57, A75: the inspector's quantity field): a bin * wholly on one resource stays wholly there; a split or partly allocated * bin keeps its parts, its remainder changing, and never holds less than * they take. */ setQuantity(id: string, quantity: number): boolean; /** Takes a bin's row as the bin kind's own form wrote it: one transaction, as every gesture is (A75). */ row(id: string, bytes: Uint8Array): boolean; /** Edits one of the bin row's own fields, as the inspector's form over the kind's `fields` does. */ field(id: string, path: readonly string[], next: unknown): boolean; /** * Splits a bin (A71, #1362): a new part on a resource it is not on, of * what {@link splitOf} takes — of what its parts leave unallocated, more * than nothing and no more than all of it; with nothing left, off a part * (its largest, or `from`), more than nothing and less than all of it, so * both keep some. One step. */ split(id: string, resource: string, quantity: number, from?: string): boolean; /** * Sets one part's quantity (A71, the inspector's field in Assigned to): no * more than the part and the remainder together; nothing unlinks it, what * it held unallocated again. The bin's quantity never changes. */ setPart(id: string, resource: string, quantity: number): boolean; /** Moves a bin to a lane slot, after the slot's bins by a minute each (A37); its resource never changes. */ move(id: string, lane: string, at: Date): boolean; /** * Links a bin on a resource (A39): a link's part moves there (`from`), or a * connector's quantity goes there — its remainder, or, with none, its * largest part. */ link(id: string, resource: string, from: string | undefined): boolean; /** Fills a reservation with a bin (A38): the bin takes its lane, time and resource, and the reservation goes. */ fill(id: string, reservation: string): boolean; /** Books an arrival into a lane slot (A49): a new bin of it, its row's other fields the arrival's `values`, on a resource or not linked yet. */ book(arrival: string, lane: string, at: Date, resource: string | undefined): boolean; /** Replaces a bin's arrival (A49): a bin of the other arrival takes its lane, time and resource; the replaced one goes back to Arrivals. */ replace(id: string, arrival: string): boolean; /** Books an arrival into a reservation (A38, A49): its bin takes the reservation's lane, time and resource, and the reservation goes. */ fillWith(reservation: string, arrival: string): boolean; /** Reserves a lane slot on a resource (A49): a bin with no arrival, no quantity and no hold, its row's other fields the bin kind's `values` of it, or their defaults. */ reserve(lane: string, at: Date, resource: string): boolean; /** Books a committed bin the drafts removed again (A51), as the day holds it, into a lane slot: on a resource, or not linked yet. */ restore(id: string, lane: string, at: Date, resource: string | undefined): boolean; /** Books a committed bin the drafts removed again into a reservation (A38): it takes the reservation's lane, time and resource, and the reservation goes. */ restoreInto(id: string, reservation: string): boolean; /** Returns a draft booking's arrival to Arrivals (A51): every bin of it the day does not hold yet goes. */ unbook(arrival: string): void; /** Publishes the period holding the day, the day or its week (A4, B7, #1550): Save, then its status. */ publish(): void; } /** * The board's commands over the day (see the module docs). * * @param state - The day, its rows and the editing * @param select - Sets what is selected, keeping the panes as they are * @param publish - Publishes the period holding the day: Save, then its status * @returns The commands */ export declare function allocationCommands(state: AllocationState, select: (next: Selection | undefined, soft?: boolean) => void, publish: () => void): AllocationCommands; /** * The row of the period holding the day as Publish writes it — the day's, or * its week's (#1550): its status the published case, at the time given, over * its row as the Save left it (`periodPublishChange`). * * @param value - The payload: its periods * @param start - The period's first day: the plan day, or its week's first * @param at - When it is published * @returns The change; `undefined` without periods */ export declare function publishChange(value: AllocationValue, start: Date, at: Date): ScheduleChange | undefined; //# sourceMappingURL=actions.d.ts.map