/**
 * Copyright 2023-present DreamNum Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import type { ISectionBreak, ISectionColumnProperties, SectionHeaderFooterKind, SectionHeaderFooterVariant } from '@univerjs/core';
import type { IEffectiveSectionPageSetup, IHeaderFooterProps } from '@univerjs/docs';
import type { FDocument } from './f-document';
import type { IFDocumentTextRange } from './utils';
import { ColumnSeparatorType, ICommandService, IPermissionService, SectionType } from '@univerjs/core';
import { FDocumentObjectPermission } from './f-document-permission';
export interface IFDocumentSectionColumnOptions {
    /** Gap after each column except the last, in 96-DPI layout pixels. */
    gap?: number;
    /** Optional explicit column widths in 96-DPI layout pixels. Length must equal `columnCount`. */
    widths?: number[];
    /** Whether to draw separators, or the exact separator enum value. */
    separator?: boolean | ColumnSeparatorType;
}
export type FDocumentSectionPageSetup = Pick<ISectionBreak, 'pageNumberStart' | 'pageSize' | 'pageOrient' | 'marginTop' | 'marginBottom' | 'marginLeft' | 'marginRight'>;
export interface IFDocumentSectionDescription {
    sectionId: string;
    index: number;
    range: IFDocumentTextRange;
    columnCount: number;
    columns: ISectionColumnProperties[];
    columnSeparatorType: ColumnSeparatorType;
    sectionType: SectionType;
    headerFooter: Record<`${SectionHeaderFooterVariant}${Capitalize<SectionHeaderFooterKind>}`, {
        segmentId: string | null;
        linkedToPrevious: boolean;
    }>;
    config: ISectionBreak;
}
/** Error thrown when a Traditional-only section API is used with another document flavor. */
export declare class DocsSectionUnsupportedDocumentFlavorError extends Error {
    constructor();
}
/**
 * Facade wrapper for an OOXML-compatible traditional document section.
 * Modern documents use ColumnGroup APIs. Unspecified documents must resolve
 * their flavor before using this facade.
 * @example
 * ```ts
 * const fDocument = univerAPI.getActiveDocument();
 * if (fDocument?.isTraditional()) {
 *   console.log(fDocument.getSection(0)?.describe());
 * }
 * ```
 */
export declare class FDocumentSection {
    private readonly _document;
    private readonly _sectionId;
    private readonly _commandService;
    private readonly _permissionService;
    constructor(_document: FDocument, _sectionId: string, _commandService: ICommandService, _permissionService: IPermissionService);
    /**
     * Returns the persisted section id.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getId());
     * ```
     */
    getId(): string;
    /**
     * Returns this Section's permission facade.
     * @returns {FDocumentObjectPermission} Permission facade combining Document and Section Edit points.
     * @example
     * ```ts
     * const section = univerAPI.getActiveDocument()?.getSection(0);
     * if (!section) throw new Error('Section not found.');
     * await section.getPermission().setReadOnly();
     * ```
     */
    getPermission(): FDocumentObjectPermission;
    /**
     * Returns the current zero-based section index.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getIndex());
     * ```
     */
    getIndex(): number;
    /**
     * Returns the section break snapshot that terminates this section.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getConfig());
     * ```
     */
    getConfig(): ISectionBreak;
    /**
     * Returns the section content range, excluding its terminating section-break token.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getRange());
     * ```
     */
    getRange(): IFDocumentTextRange;
    /**
     * Returns the explicit columns. An empty array means the normal single-column layout.
     * Column widths and trailing spaces are in 96-DPI layout pixels.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getColumns());
     * ```
     */
    getColumns(): ISectionColumnProperties[];
    /**
     * Returns a compact serializable section summary.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.describe());
     * ```
     */
    describe(): IFDocumentSectionDescription;
    /**
     * Sets equal or explicitly sized columns for this traditional section.
     * Use `columnCount = 1` to restore normal single-column layout.
     * `gap` and `widths` are in 96-DPI layout pixels.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   fDocument.getSection(0)?.setColumns(2, { gap: 18, separator: true });
     * }
     * ```
     */
    setColumns(columnCount: number, options?: IFDocumentSectionColumnOptions): boolean;
    /**
     * Sets explicit OOXML-compatible column width and trailing-space values in 96-DPI layout pixels.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   fDocument.getSection(0)?.setColumnProperties([
     *     { width: 240, paddingEnd: 18 },
     *     { width: 240, paddingEnd: 0 },
     *   ], univerAPI.Enum.ColumnSeparatorType.BETWEEN_EACH_COLUMN);
     * }
     * ```
     */
    setColumnProperties(columns: ISectionColumnProperties[], separator?: ColumnSeparatorType): boolean;
    /**
     * Sets how this section begins relative to the previous section.
     *
     * The first section has no preceding boundary, so setting its type does not
     * create an initial blank page. Prefer `FDocument.insertSectionBreak` with
     * `nextSectionType` when creating a new boundary; use this method when
     * updating an existing section after resolving it again from the document.
     *
     * @param {SectionType} sectionType How this section begins.
     * @returns {boolean} `true` when the section command was applied.
     * @example
     * ```ts
     * const document = univerAPI.getActiveDocument();
     * if (!document?.isTraditional()) {
     *   throw new Error('A Traditional document is required');
     * }
     *
     * const secondSection = document.getSection(1);
     * if (!secondSection) {
     *   throw new Error('The second section does not exist');
     * }
     * if (!secondSection.setSectionType(univerAPI.Enum.SectionType.NEXT_PAGE)) {
     *   throw new Error('Failed to update the second section');
     * }
     * ```
     */
    setSectionType(sectionType: SectionType): boolean;
    /**
     * Returns this section's explicit page setup overrides.
     * Missing values inherit from the document style. Geometry values use 96-DPI layout pixels.
     *
     * Use `getEffectivePageSetup()` when an agent needs resolved page and content
     * dimensions rather than only the overrides stored on this section.
     *
     * @returns {FDocumentSectionPageSetup} A cloned object containing only explicit section overrides.
     * @example
     * ```ts
     * const document = univerAPI.getActiveDocument();
     * const section = document?.getSection(0);
     * console.log(section?.getPageSetup());
     * ```
     */
    getPageSetup(): FDocumentSectionPageSetup;
    /**
     * Returns nominal page geometry after resolving this section's overrides
     * against document defaults. All geometry values use 96-DPI layout pixels.
     *
     * This synchronous model-only API works without `engine-render`. It does not
     * report physical page count, remaining page space, or final coordinates.
     *
     * @returns {IEffectiveSectionPageSetup} A cloned, serializable page setup.
     * @example
     * ```ts
     * const document = univerAPI.getActiveDocument();
     * if (!document) {
     *   throw new Error('No active document');
     * }
     * if (!document.isTraditional()) {
     *   throw new Error('Traditional document sections are required');
     * }
     *
     * const section = document.getSection(0);
     * if (!section) {
     *   throw new Error('The document has no traditional section');
     * }
     *
     * const layout = section.getEffectivePageSetup();
     * console.log({
     *   pageWidth: layout.pageSize.width,
     *   pageHeight: layout.pageSize.height,
     *   contentWidth: layout.contentSize.width,
     *   contentHeight: layout.contentSize.height,
     *   margins: layout.margins,
     * });
     * ```
     */
    getEffectivePageSetup(): IEffectiveSectionPageSetup;
    /**
     * Updates this section's page setup through the document section command.
     * Geometry values use 96-DPI layout pixels.
     *
     * This method changes static page geometry; it does not choose where the
     * section begins. Use `setSectionType()` for an existing boundary, or
     * `insertSectionBreak(..., { nextSectionType })` while creating one.
     *
     * @param {FDocumentSectionPageSetup} pageSetup Explicit section overrides to patch.
     * @returns {boolean} `true` when the section command was applied.
     * @example
     * ```ts
     * const document = univerAPI.getActiveDocument();
     * if (!document?.isTraditional()) {
     *   throw new Error('A Traditional document is required');
     * }
     *
     * const section = document.getSection(1);
     * if (!section) {
     *   throw new Error('The second section does not exist');
     * }
     * const updated = section.setPageSetup({
     *   pageSize: { width: 816, height: 1056 },
     *   marginTop: 96,
     *   marginBottom: 96,
     *   marginLeft: 96,
     *   marginRight: 96,
     * });
     * if (!updated) {
     *   throw new Error('Failed to update section page setup');
     * }
     * console.log(section.getEffectivePageSetup());
     * ```
     */
    setPageSetup(pageSetup: FDocumentSectionPageSetup): boolean;
    /**
     * Ensures a header segment linked specifically to this section.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   const segmentId = fDocument.getSection(0)?.ensureHeader();
     *   if (segmentId) {
     *     fDocument.insertText(0, 'Quarterly report', segmentId);
     *   }
     * }
     * ```
     */
    ensureHeader(variant?: SectionHeaderFooterVariant): string;
    /**
     * Ensures a footer segment linked specifically to this section.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   const segmentId = fDocument.getSection(0)?.ensureFooter('first');
     *   if (segmentId) {
     *     fDocument.insertText(0, 'Confidential', segmentId);
     *   }
     * }
     * ```
     */
    ensureFooter(variant?: SectionHeaderFooterVariant): string;
    /**
     * Returns the effective header id after resolving links to previous sections.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getHeaderId('default'));
     * ```
     */
    getHeaderId(variant?: SectionHeaderFooterVariant): string | null;
    /**
     * Returns the effective footer id after resolving links to previous sections.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(0)?.getFooterId('first'));
     * ```
     */
    getFooterId(variant?: SectionHeaderFooterVariant): string | null;
    /**
     * Whether this header variant inherits the previous section's reference.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(1)?.isHeaderLinkedToPrevious());
     * ```
     */
    isHeaderLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
    /**
     * Whether this footer variant inherits the previous section's reference.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * console.log(fDocument?.getSection(1)?.isFooterLinkedToPrevious('even'));
     * ```
     */
    isFooterLinkedToPrevious(variant?: SectionHeaderFooterVariant): boolean;
    /**
     * Links or unlinks this header variant. Unlinking clones the inherited header.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   fDocument.getSection(1)?.setHeaderLinkedToPrevious(false, 'default');
     * }
     * ```
     */
    setHeaderLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): boolean;
    /**
     * Links or unlinks this footer variant. Unlinking clones the inherited footer.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   fDocument.getSection(1)?.setFooterLinkedToPrevious(true, 'even');
     * }
     * ```
     */
    setFooterLinkedToPrevious(linkedToPrevious: boolean, variant?: SectionHeaderFooterVariant): boolean;
    /**
     * Updates header/footer switches and margins on this section break.
     * `marginHeader` and `marginFooter` are in 96-DPI layout pixels.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   fDocument.getSection(0)?.setHeaderFooterOptions({
     *     marginHeader: 36,
     *     marginFooter: 36,
     *     useFirstPageHeaderFooter: univerAPI.Enum.BooleanNumber.TRUE,
     *   });
     * }
     * ```
     */
    setHeaderFooterOptions(options: IHeaderFooterProps): boolean;
    /**
     * Deletes this section break. The final top-level section break cannot be removed.
     * @example
     * ```ts
     * const fDocument = univerAPI.getActiveDocument();
     * if (fDocument?.isTraditional()) {
     *   const sections = fDocument.getSections();
     *   if (sections.length > 1) {
     *     sections[0].remove();
     *   }
     * }
     * ```
     */
    remove(): boolean;
    private _update;
    private _ensureHeaderFooter;
    private _getHeaderFooterReference;
    private _describeHeaderFooterReference;
    private _setHeaderFooterLinkedToPrevious;
    private _assertTraditionalDocument;
    private _getConfigSnapshot;
    private _getRange;
    private _resolve;
}
