import { Observable } from 'rxjs';
import { QdMenuButtonActionConfig } from '../../button/model/button-config';
import { QdPageHeaderFacetConfig } from './page-header-facet.interface';
/**
 * @description Configuration of QdPage.
 *
 * @template T - The type of the page object data
 */
export type QdPageConfig<T extends object = object> = QdPageConfigOverview | QdPageConfigCreate<T> | QdPageConfigInspect<T> | QdPageConfigCustom<T>;
export interface QdPageSelectedContext {
    value: string;
    label: {
        i18n: string;
    };
}
interface QdPageContextConfigBase {
    /**
     * @description Description for the specific header facet
     */
    label: {
        /**
         * @description i18n string for the description, used for translation.
         */
        i18n: string;
    };
    /**
     * @description Allows to identify the context
     */
    id: string;
    /**
     * @description Register some handler that is executed when the selection changes.
     */
    changed?: (selection: QdPageSelectedContext | QdPageSelectedContext[] | null) => void;
}
/**
 * @description Configuration for a context with single selection
 */
export interface QdPageContextConfigSingle extends QdPageContextConfigBase {
    /**
     * @description Configures the type on how the context selection happens.
     */
    type: 'single';
    /**
     * @description Available options for selection.
     */
    options: QdPageSelectedContext[];
    /**
     * @description Configures whether the context options are searchable for the user.
     * @default false
     */
    hasSearch?: boolean;
    /**
     * @description Placeholder for search
     */
    searchPlaceholder?: {
        /**
         * @description i18n string
         */
        i18n: string;
    };
    /**
     * @description Title for the dialog that will be opened
     */
    title?: {
        /**
         * @description i18n string
         */
        i18n: string;
    };
}
/**
 * @description Configuration for a context with multi selection
 */
export interface QdPageContextConfigMulti extends QdPageContextConfigBase {
    /**
     * @description Configures the type on how the context selection happens.
     */
    type: 'multi';
    /**
     * @description Available options for selection.
     */
    options: QdPageSelectedContext[];
    /**
     * @description Configures whether the context options are searchable for the user.
     * @default false
     */
    hasSearch?: boolean;
    /**
     * @description Placeholder for search
  
     */
    searchPlaceholder?: {
        /**
         * @description i18n string
         */
        i18n: string;
    };
    /**
     * @description Title for the dialog that will be opened
     */
    title?: {
        /**
         * @description i18n string
         */
        i18n: string;
    };
}
/**
 * @description Configuration for a context with custom selection (e. g. your own dialog)
 */
export interface QdPageContextConfigCustom extends QdPageContextConfigBase {
    /**
     * @description Configures the type on how the context selection happens.
     */
    type: 'custom';
    /**
     * @description Handler to open a custom dialog for selection
     */
    open: () => void;
}
/**
 * @description Configures the context with one of the available types
 */
export type QdPageContextConfig = QdPageContextConfigSingle | QdPageContextConfigMulti | QdPageContextConfigCustom;
/**
 * @description Base configuration for QdPage.
 */
interface QdPageConfigBase {
    /**
     * @description Title of the page.
     */
    title: QdPageTitle;
    /**
     * @description Hides contexts from being shown. The ContextService will still work in the background.
     *
     * @default false
     */
    hideContexts?: boolean;
    /**
     * @description Label for the menu button of custom actions.
     */
    customActionsLabel?: QdPageCustomActionsLabel;
}
/**
 * @description Configuration for the overview page type.
 *
 * @template T - The type of the page object data
 */
export interface QdPageConfigOverview extends QdPageConfigBase {
    /**
     * @description Page Type
     *
     * @default 'overview'
     */
    pageType?: 'overview';
    /**
     * @description Configuration specific to the overview page type.
     */
    pageTypeConfig?: QdPageTypeOverviewConfig;
}
/**
 * @description Configuration for the create page type.
 *
 * @template T - The type of the page object data
 */
export interface QdPageConfigCreate<T extends object = object> extends QdPageConfigBase {
    /**
     * @description Page Type
     *
     * @default 'create'
     */
    pageType: 'create';
    /**
     * @description Configuration specific to the create page type.
     */
    pageTypeConfig?: QdPageTypeCreateConfig;
    /**
     * @description Information placed in the header of the page. Concerns current shown object.
     */
    headerFacets?: QdPageHeaderFacetConfig<T>[];
}
export interface QdPageConfigInspect<T extends object = object> extends QdPageConfigBase {
    /**
     * @description Page Type
     *
     * @default 'inspect'
     */
    pageType: 'inspect';
    /**
     * @description Configuration specific to the inspect page type.
     */
    pageTypeConfig?: QdPageTypeInspectConfig;
    /**
     * @description Information placed in the header of the page. Concerns current shown object.
     */
    headerFacets?: QdPageHeaderFacetConfig<T>[];
    /**
     * @description Determines whether the facets in header should be collapsed and custom actions are in a menu. This mode is designed for touch devices and mobile phones only.
     *
     * @default false
     */
    adaptiveMode?: boolean;
}
export interface QdPageConfigCustom<T extends object = object> extends QdPageConfigBase {
    /**
     * @description Page Type
     *
     * @default 'custom'
     */
    pageType: 'custom';
    /**
     * @description Configuration specific to the custom page type.
     */
    pageTypeConfig?: QdPageTypeCustomConfig;
    /**
     * @description Information placed in the header of the page. Concerns current shown object.
     */
    headerFacets?: QdPageHeaderFacetConfig<T>[];
    /**
     * @description Determines whether the facets in header should be collapsed and custom actions are in a menu. This mode is designed for touch devices and mobile phones only.
     *
     * @default false
     */
    adaptiveMode?: boolean;
}
/**
 * Configures the overview page
 */
export interface QdPageTypeOverviewConfig {
    /**
     * @description Custom actions for the header.
     * You can define a label, a handler, and you can disable or hide the action.
     *
     * * If there exists more than 1 Custom Action, a QdMenuButton will be displayed.
     *
     * * These actions are not intended to influence the core process flow or manipulate the object directly. Instead, they should be used for side effects, such as triggering notifications, updating external services, or executing supplementary tasks that do not alter the main state of the object.
     */
    customActions?: QdMenuButtonActionConfig[];
}
/**
 * @description Configures the create page.
 */
export interface QdPageTypeCreateConfig {
    /**
     * @description Configuration for the save draft action.
     */
    saveDraft?: QdPageSaveDraftAction;
    /**
     * @description Configuration for the cancel button.
     */
    cancel: QdPageCancelAction;
    /**
     * @description Configuration for the submit button.
     */
    submit: QdPageCreateSubmitAction;
    /**
     * @description Custom actions for the header.
     * You can define a label, a handler, and you can disable or hide the action.
     *
     * * If there exists more than 1 Custom Action, a QdMenuButton will be displayed.
     *
     * * These actions are not intended to influence the core process flow or manipulate the object directly. Instead, they should be used for side effects, such as triggering notifications, updating external services, or executing supplementary tasks that do not alter the main state of the object.
     */
    customActions?: QdMenuButtonActionConfig[];
}
/**
 * @description Configures the inspect page.
 */
export interface QdPageTypeInspectConfig {
    /**
     * @description Operation mode for the page.
     *
     * * This property determines the mode in which the page operates. It can be either 'view' or 'edit'.
     *
     * * **view**: The page is in read-only mode.
     * * **edit**: The page allows modifications.
     */
    operationMode?: QdInspectOperationMode;
    /**
     * @description Specifies whether the user can edit the object or not.
     */
    hideEdit?: boolean;
    /**
     * @description Configuration for the edit action.
     */
    edit?: QdPageEditAction;
    /**
     * @description Configuration for the save action.
     */
    save?: QdPageSaveAction;
    /**
     * @description Configuration for the cancel action.
     */
    cancel: QdPageCancelAction;
    /**
     * @description Configuration for the delete action.
     */
    delete?: QdPageDeleteAction;
    /**
     * @description Configuration for the archive action.
     */
    archive?: QdPageArchiveAction;
    /**
     * @description Configuration for the submit action.
     */
    submit?: QdPageInspectSubmitAction;
    /**
     * @description Custom actions for the header.
     * You can define a label, a handler, and you can disable or hide the action.
     *
     * * If there exists more than 1 Custom Action, a QdMenuButton will be displayed.
     *
     * * In the "Inspect" page type, you can assign custom actions to the operation modes "view" or "edit." By default, the action is active in both modes.
     *
     * * These actions are not intended to influence the core process flow or manipulate the object directly. Instead, they should be used for side effects, such as triggering notifications, updating external services, or executing supplementary tasks that do not alter the main state of the object.
     */
    customActions?: (QdMenuButtonActionConfig & {
        operationMode?: QdInspectOperationMode;
    })[];
}
export interface QdPageTypeCustomConfig {
    /**
     * @description Custom actions for the header.
     * You can define a label, a handler, and you can disable or hide the action.
     *
     * * If there exists more than 1 Custom Action, a QdMenuButton will be displayed.
     *
     * * These actions are not intended to influence the core process flow or manipulate the object directly. Instead, they should be used for side effects, such as triggering notifications, updating external services, or executing supplementary tasks that do not alter the main state of the object.
     */
    customActions?: QdMenuButtonActionConfig[];
}
export interface QdPageTitle {
    /**
     * @description Defines the translation key
     *
     * * @example { i18n: "i18n.overview.title"}
     */
    i18n: string;
}
/**
 * @description Configuration for the custom actions label, used when multiple custom actions exist.
 */
export interface QdPageCustomActionsLabel {
    /**
     * @description Label for the menu button of custom actions, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     *
     * * This label becomes visible if more than one custom action is defined, as the actions will be grouped under a QdMenuButton that displays this label.
     */
    i18n: string;
}
/**
 * @description Operation modes for the inspect page.
 *
 * @default 'view'
 */
export type QdInspectOperationMode = 'view' | 'edit';
/**
 * @description Interface for the save action, including optional validation configuration.
 */
export interface QdPageSaveAction {
    /**
     * @description Label for the save action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Triggered when the save action is executed.
     *
     * Success criteria:
     * - If the handler returns an Observable<boolean>, only the first emission after the save click counts:
     *   - **true:** success - toggle to view and apply the saved values
     *   - **false:** failure/cancel - stay in edit mode
     * - If the handler returns no Observable (void), the save is treated as instant success (toggle + apply values).
     *
     * On a successful save, the framework applies the values and resets its internal validation and change-tracking state.
     */
    handler: (formValues?: any) => void | Observable<boolean>;
    /**
     * @description Optional validation flag, defaults to true.
     * Determines whether form validation is required before saving and ensures that changes must be present in the form before saving.
     *
     * * By default, this flag is set to true, meaning that validation is enforced, and the form will only save if there are changes.
     *
     * * If set to `false`, the form will be saved without validation checks, but changes must still be present to proceed with the save operation.
     *
     * * This flag is useful in scenarios where form validation is not needed or should be bypassed, but it ensures that only modified forms can be saved.
     */
    hasValidation?: boolean;
}
/**
 * @description Interface for the safe draft action.
 */
export interface QdPageSaveDraftAction {
    /**
     * @description Label for the save draft action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Handler function that is triggered when the save draft action is executed.
     */
    handler: () => void;
}
/**
 * @description Interface for the cancel action, including an optional confirmation message.
 */
export interface QdPageCancelAction {
    /**
     * @description Label for the cancel action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Handler function that is triggered when the cancel action is executed.
     */
    handler: () => void;
    /**
     * @description An optional confirmation message displayed in a dialog when the user attempts to cancel the operation, warning that all changes will be discarded.
     * If no custom message is provided, a standard message will be shown by default.
     *
     * * The cancellation process checks whether there are unsaved changes in the form. If there are changes, the dialog will appear.
     *
     * * If no changes are detected, the cancellation proceeds without showing the confirmation dialog.
     */
    confirmationMessage?: {
        i18n: string;
    };
}
/**
 * @description Interface for the submit action on create pages.
 */
export interface QdPageCreateSubmitAction {
    /**
     * @description Label for the submit action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Handler function that is triggered when the submit action is executed.
     */
    handler: (formValues?: any) => void;
}
/**
 * @description Interface for the submit action.
 */
export interface QdPageSubmitAction {
    /**
     * @description Label for the submit action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Handler function that is triggered when the submit action is executed.
     */
    handler: (formValues?: any) => void;
    /**
     * @description By default, the visibility of the submit button depends on the page type and the operation mode.
     * To completely hide the submit button, you can set this isHidden flag.
     *
     * @default false
     */
    isHidden?: boolean;
}
/**
 * @description Interface for the edit action.
 */
export interface QdPageEditAction {
    /**
     * @description Label for the edit action, used for translation.
     *
     * * If no custom translation key is provided, a standard label will be used by default.
     */
    label?: {
        i18n: string;
    };
    /**
     * @description Handler function that is triggered when the edit action is executed.
     */
    handler: (formValues?: any) => void;
}
/**
 * @description Interface for the delete action.
 *
 * * This action is represented as an icon, so it does not require a label.
 */
export interface QdPageDeleteAction {
    /**
     * @description Handler function that is triggered when the delete action is executed.
     */
    handler: (formValues?: any) => void;
}
/**
 * @description Interface for the archive action.
 *
 * * This action is represented as an icon, so it does not require a label.
 */
export interface QdPageArchiveAction {
    /**
     * @description Handler function that is triggered when the archive action is executed.
     */
    handler: (formValues?: any) => void;
}
/**
 * @description Inspect-specific submit action configuration.
 */
export interface QdPageInspectSubmitAction extends QdPageSubmitAction {
    /**
     * @description Optional info message shown when submit is disabled on inspect pages for non-validation reasons.
     *
     * * If not provided, the standard disabled explanation is used.
     */
    disabledInfo?: {
        i18n: string;
    };
}
export {};
//# sourceMappingURL=page-config.interface.d.ts.map