import { o as TextDirection } from "./style-D06NwxAJ.cjs"; import { _n as ContentTableRow, hn as ContentTableCell, mn as ContentTable } from "./content-BNUhgRbB.cjs"; //#region src/table-grid.d.ts /** The number of grid columns a cell occupies; an absent `colSpan` means the cell occupies its own column only. */ declare function tableCellColumnSpan(cell: ContentTableCell): number; /** The number of grid rows a cell occupies; an absent `rowSpan` means the cell occupies its own row only. */ declare function tableCellRowSpan(cell: ContentTableCell): number; /** * The table's grid width. For a table obeying the dense rule this is `columnWidthsPt.length` and every row's `cells.length` alike; taking the largest of them is what lets a reader mid-construction, or a table whose source declared a grid narrower than a row actually uses, still be walked without the walk inventing a narrower grid than the rows occupy. */ declare function tableGridColumnCount(table: ContentTable): number; /** A grid position holding a merged region's anchor, or an unmerged cell (which is its own one-position region's anchor). */ interface TableGridAnchor { readonly rowIndex: number; readonly columnIndex: number; readonly cell: ContentTableCell; readonly anchorRowIndex?: never; readonly anchorColumnIndex?: never; } /** A grid position covered by a merged region anchored elsewhere. `anchorRowIndex < rowIndex` means the region reaches this position vertically; `anchorRowIndex === rowIndex` means it reaches it horizontally along this same row. */ interface TableGridCovered { readonly rowIndex: number; readonly columnIndex: number; readonly cell: ContentTableCell; readonly anchorRowIndex: number; readonly anchorColumnIndex: number; } /** Discriminated by the presence of the anchor coordinates rather than by a tag field, since the two shapes' required fields are already mutually exclusive: `"anchorRowIndex" in position` narrows to the covered branch. */ type TableGridPosition = TableGridAnchor | TableGridCovered; /** * Classify every entry of every row as an anchor or as covered, in row-major order, one inner array per table row. * * This is the walk a consumer runs instead of accumulating spans itself. A writer targeting a format that stores only anchors (HTML's ``, a docx `w:tc` with `w:gridSpan`) keeps the anchors and drops the covered positions; a writer targeting a format that stores covered positions explicitly (ODF, pptx) writes both; a reader checks its own output against it. */ declare function walkTableGrid(table: ContentTable): TableGridPosition[][]; /** * Where a table stops obeying the grid rule (ContentTableCell in src/content.ts states the rule; walkTableGrid derives the classification every check here is made against). Every variant names a position in the table's own row and column indices. * * - `raggedRow`: the row holds `cellCount` entries where the table's widest row holds `gridColumnCount`, so the rows do not all cover the same grid. * - `coveredContent`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries blocks of its own; the region's content belongs to its anchor, so a second copy has nowhere to go. * - `coveredSpan`: the position is covered by the region anchored at `anchorRowIndex`, `anchorColumnIndex` yet carries a `colSpan` or `rowSpan` of its own. Spans are set on the anchor only and walkTableGrid never consults a covered entry's, so this is how a second anchor starting inside another's footprint shows up: the walk assigns each position to the first anchor covering it, which leaves the second entry classified as covered and its span ignored. * - `anchorOverrunsColumns`: the anchor at this position has a `colSpan` reaching past the last grid column. * - `anchorOverrunsRows`: the anchor at this position has a `rowSpan` reaching past the last row of the table. * - `overlappingAnchors`: the anchor at this position starts outside every other region but its footprint reaches a position already covered by the region anchored at `earlierAnchorRowIndex`, `earlierAnchorColumnIndex`, so two regions claim one position. * * A `kind` tag discriminates rather than property presence, because the variants' required fields are not mutually exclusive: several variants' fields include another's. */ type TableGridFault = { readonly kind: "raggedRow"; readonly rowIndex: number; readonly cellCount: number; readonly gridColumnCount: number; } | { readonly kind: "coveredContent" | "coveredSpan"; readonly rowIndex: number; readonly columnIndex: number; readonly anchorRowIndex: number; readonly anchorColumnIndex: number; } | { readonly kind: "anchorOverrunsColumns" | "anchorOverrunsRows"; readonly rowIndex: number; readonly columnIndex: number; } | { readonly kind: "overlappingAnchors"; readonly rowIndex: number; readonly columnIndex: number; readonly earlierAnchorRowIndex: number; readonly earlierAnchorColumnIndex: number; }; /** * The first place `table` contradicts the grid rule, or `undefined` when it obeys it. It never throws: a caller decides what a fault means for it, the way findConstructMarkerImbalance leaves that decision to each consumer of a block list. * * Rows are compared with each other before any position is classified, since an anchor's footprint can only be measured against a grid every row shares; the positions are then checked in row-major order, so the fault returned is the earliest one in reading order. * * The check states the whole of the rule and nothing beyond it: a table with no rows, or whose rows are all empty, has no fault, and neither `columnWidthsPt` nor a cell's own properties other than its blocks and spans are consulted. */ declare function findTableGridFault(table: ContentTable): TableGridFault | undefined; /** * One sentence stating a fault in words, for a writer that refuses or reports a table the grid rule does not admit: it names the fault by its position and, where the fault involves a second region, by that region's anchor. Indices are 0-based, matching every index in the descriptor. The sentence carries no entry point or format of its own, so each caller prefixes whatever names its own operation. */ declare function describeTableGridFault(fault: TableGridFault): string; /** A cell together with the grid column it starts at, for a reader whose source format states that column directly. */ interface PositionedTableCell { readonly columnIndex: number; readonly cell: ContentTableCell; } /** One row's worth of positioned cells, carrying the row-level properties denseTableRows copies through unchanged. */ interface PositionedTableRow { readonly cells: readonly PositionedTableCell[]; readonly heightPt?: number; readonly direction?: TextDirection; readonly isHeader?: boolean; } /** * Build dense rows from cells a reader has already positioned, filling every position no cell was placed at with an empty covered cell. * * `columnCount` is the grid width the source declared (a docx `w:tblGrid`, an ODF `table:table-column` run). The result is that wide, or wider if some row places a cell past it, so that every returned row has the same length whatever the source's own grid declaration said. */ declare function denseTableRows(rows: readonly PositionedTableRow[], columnCount: number): ContentTableRow[]; /** One row's worth of anchor cells only, for a reader whose source format omits covered positions entirely and leaves their grid columns to be worked out from the spans around them. */ interface AnchorTableRow { readonly cells: readonly ContentTableCell[]; readonly heightPt?: number; readonly direction?: TextDirection; readonly isHeader?: boolean; } /** * Build dense rows from anchor cells alone, placing each at the first grid column no earlier cell already reaches -- the placement HTML's own table model needs, where a `rowspan` in one row silently consumes a column in the rows below it and nothing marks the consumed position. * * `columnCount` is the grid width the source declared, where it declares one at all; pass 0 when it does not and the width follows from the placement. */ declare function placeAnchorTableRows(rows: readonly AnchorTableRow[], columnCount: number): ContentTableRow[]; //#endregion export { AnchorTableRow, PositionedTableCell, PositionedTableRow, TableGridAnchor, TableGridCovered, TableGridFault, TableGridPosition, denseTableRows, describeTableGridFault, findTableGridFault, placeAnchorTableRows, tableCellColumnSpan, tableCellRowSpan, tableGridColumnCount, walkTableGrid };