import { nothing, type PropertyValues, type TemplateResult } from 'lit';
import { DomainProperty } from '@api-client/core/modeling/DomainProperty.js';
import { type DomainPropertyFormat } from '@api-client/core/modeling/DataFormat.js';
import { PropertySemantic } from '@api-client/core/modeling/Semantics.js';
import { ModelingElement } from './ModelingElement.js';
import type { DomainPropertyInputConfig } from '../types.js';
/**
 * Dispatched when the user deletes a property.
 *
 * @event DomainPropertyEditor#delete
 * @type {CustomEvent}
 * @property {object} detail - The event details.
 * @property {string} detail.key - The key of the parent entity to navigate to.
 * @property {string} detail.kind - The kind of the parent entity. It will always be `DomainEntityKind`.
 */
/**
 * `DomainPropertyEditor` is a LitElement-based web component that provides a user interface for editing
 * properties of a `DomainProperty` object. It allows users to modify various aspects of a data property,
 * including its metadata, attributes, schema, and enum values.
 *
 * ## Features
 *
 * -   **Metadata Editing**: Allows editing of the property's name, display name, and description.
 * -   **Attribute Management**: Provides controls for setting data type, format, and other attributes
 *     like `required`, `multiple`, `primary`, `index`, and `readOnly`.
 * -   **Schema Definition**: Enables defining the schema for the property, including default values
 *     and enum values.
 * -   **Enum Editor**: Supports enabling and disabling an enum editor for predefined values, with
 *     options to add, update, and delete enum values.
 * -   **Default Value Setting**: Allows setting a default value for the property, either as a literal
 *     value or a function.
 * -   **Data Type and Format Selection**: Provides dropdowns for selecting the data type and format
 *     of the property.
 * -   **Validation**: Includes input validation to ensure data integrity.
 * -   **Change Notification**: Dispatches a `change` event whenever a property is modified.
 *
 * ## Usage
 *
 * The `DomainPropertyEditor` is typically used within a larger application that manages data models.
 *
 * ```html
 * <domain-property-editor .root="${this.domainNamespace}" selected="property-key"></domain-property-editor>
 * ```
 *
 * @fires DomainPropertyEditor#delete - A custom event with the `key` and `type` when a property was selected.
 */
export default class DomainPropertyEditor extends ModelingElement {
    /**
     * The `DomainProperty` object being edited.
     * This is updated when the `selected` property changes.
     */
    private accessor domainElement;
    /**
     * Indicates whether the default value input field is visible.
     * This is set to `true` when the user selects the "Literal" option in the default value select.
     */
    private accessor hasDefaultValueInput;
    /**
     * Whether the enum options are enabled.
     * When `true` the user can add, update, and delete enum values.
     */
    private accessor enumEnabled;
    /**
     * A fields that holds in memory enum values after disabling the enum editor.
     * When that happens the values are removed from the model but kept in memory.
     * As long as the property stays the same, the user can reopen the enum editor
     * and restore the previous value.
     */
    protected cachedEnumValues: string[] | undefined;
    /**
     * A cached value of the schema-sensitive input configuration.
     * These are the default value and enum value inputs.
     */
    protected cachedSchemaInputConfig?: DomainPropertyInputConfig;
    /**
     * A configuration for a schema-sensitive HTML input.
     */
    get schemaInputConfig(): DomainPropertyInputConfig;
    protected willUpdate(cp: PropertyValues<this>): void;
    protected computeProperty(): Promise<void>;
    /**
     * Toggles the state of the enum editor.
     *
     * If the editor was disabled, it enables it and vice-versa.
     *
     * It ensures the property has the schema and then:
     * - When enabling:
     *   - If `cachedEnumValues` is set it restores them.
     *   - Otherwise it sets the default enum value `['']`
     * - When disabling:
     *   - It sets the `cachedEnumValues` to the current enum value.
     *   - Removes the enum from the model
     * - Requests the model update.
     *
     * @fires change - Dispatched when the enum editor state changes.
     */
    toggleEnum(): void;
    /**
     * Updates an enum value.
     *
     * @param index The index at which to update the value.
     * @param value The value to set. Empty string is acceptable. The type is determined by the property type.
     * @throws {RangeError} When the index is out of bounds.
     * @throws {TypeError} When the value is not a string.
     * @fires change - Dispatched when the enum value is updated.
     */
    updateEnum(index: number, value: string): void;
    /**
     * Adds a new enum value to the property.
     *
     * @param value The value to add. Defaults to an empty string.
     * @throws {TypeError} When the value is not a string.
     * @fires change - Dispatched when a new enum value is added.
     */
    addEnum(value?: string): void;
    /**
     * Deletes an enum value at a position.
     *
     * @param index The index at which to delete an enum property.
     * @throws {RangeError} When the index is out of bounds.
     * @fires change - Dispatched when an enum value is deleted.
     */
    deleteEnum(index: number): void;
    /**
     * Sets a new defaultValue on the property schema.
     *
     * @param value The default value to set. Empty to remove.
     * @param type The type of the value.
     * @param dataType Optional data type to set. Defaults to string. Only used with `type` equal `literal`.
     * @fires change - Dispatched when the default value is updated.
     */
    setDefaultValue(value?: string, type?: 'function' | 'literal'): void;
    /**
     * Updates the property's data type.
     *
     * It sets the `format` for `number`, `datetime`, and `binary` data types.
     *
     * @param value The value to set.
     * @throws {TypeError} When the passed value is not a valid data type.
     * @fires change - Dispatched when the data type is updated.
     */
    setDataType(value: string): void;
    /**
     * Sets the value of one of the "attribute" fields.
     * These are the checkboxes located in the "Attributes" section.
     *
     * @param name The name of the attribute to set.
     * @param value The boolean option to set as the value.
     * @throws {TypeError} When the passed name is not a valid attribute name.
     * @throws {TypeError} When the passed value is not a boolean value.
     * @fires change - Dispatched when an attribute value is updated.
     */
    setModelAttribute(name: string, value: boolean): void;
    /**
     * Sets the `format` value on the model.
     *
     * @param format The format value to set.
     * @throws {TypeError} When the passed format value is not supported.
     * @fires change - Dispatched when the format value is updated.
     */
    setFormat(format?: string): void;
    /**
     * Sets an example value on the schema.
     * @param value The value to set. Removes the examples array if not set.
     */
    setExampleValue(value?: string): void;
    /**
     * A method to be called when a schema property changes.
     * It caches the schema-sensitive input configuration.
     */
    protected updateSchemaInputConfig(): void;
    /**
     * A handler for the one of the metadata inputs value change.
     *
     * It supports the following fields:
     *
     * - `name`
     * - `displayName`
     * - `description`
     * - `literalDefaultValue`
     */
    protected handleMetaChange(e: Event): void;
    protected handleSchemaChange(e: Event): void;
    /**
     * A handler for the data type select input change
     */
    protected handleDataTypeChange(e: Event): void;
    /**
     * A handler for any of the checkboxes in the `attributes` section.
     * It calls the `setModelAttribute()` method.
     */
    protected handleAttributeOptionChange(e: Event): void;
    /**
     * A handler for the default value select input change.
     * Depending on the selected options it calls the `setDefaultValue()`
     * with appropriate arguments.
     */
    protected handleDefaultValueChange(e: Event): void;
    /**
     * A handler for the format select input change.
     * Calls the `setFormat()` with the appropriate value.
     */
    protected handleFormatChange(e: Event): void;
    /**
     * Handles the toggle button for the enum editor.
     * It calls the toggleEnum() whenever activated.
     */
    protected handleEnumOptionChange(): void;
    /**
     * A handler for the enum input change.
     * It calls the `updateEnum()` method
     */
    protected handleEnumChange(e: Event): void;
    /**
     * A handler for the add enum button.
     */
    protected handleAddEnum(): void;
    /**
     * A handler for the delete enum value button click.
     */
    protected handleDeleteEnum(e: Event): void;
    /**
     * Handles a change on the example input.
     */
    protected handleExampleChange(e: Event): void;
    protected handleDeleteTaxonomy(e: Event): void;
    protected handleTaxonomySelect(e: CustomEvent<{
        item: HTMLElement;
    }>): void;
    protected handleConfigureTaxonomy(e: Event): void;
    protected render(): TemplateResult | typeof nothing;
    protected renderForm(model: DomainProperty): TemplateResult;
    protected renderMetaInputs(model: DomainProperty): TemplateResult;
    protected renderAttributes(model: DomainProperty): TemplateResult;
    protected renderTaxonomy(): TemplateResult;
    protected renderSchema(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderDataTypeInput(model: DomainProperty): TemplateResult;
    protected renderAttributeOptions(model: DomainProperty): TemplateResult;
    protected renderStringSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    protected renderNumberSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    protected renderBooleanSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    protected renderDateSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    protected renderTimeSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    protected renderDateTimeSchema(model: DomainProperty): (TemplateResult | typeof nothing)[];
    /**
     * Renders the input for the default value.
     *
     * Note, when defining a new function, add support for it generation in the
     * `src/modeling/value_generator.ts` file.
     */
    protected renderDefaultValueInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderLiteralDefaultValueInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderFormat(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderFormatInput(model: DomainProperty, formats: DomainPropertyFormat[]): TemplateResult;
    /**
     * Renders the enum editing editor section.
     */
    protected renderEnumEditor(model: DomainProperty): TemplateResult;
    /**
     * Renders the enum toggle button.
     */
    protected renderEnumToggle(): TemplateResult;
    /**
     * Renders the list of enum inputs or nothing when not required.
     */
    protected renderEnumValues(model: DomainProperty): TemplateResult[] | typeof nothing;
    /**
     * Renders the text field to edit an enum value.
     * @param value The enum value to render in the input
     * @param index The enum's index in the enum array.
     */
    protected renderEnumItem(value: string, index: number): TemplateResult;
    /**
     * Renders the "add" value value button.
     */
    protected renderAddEnumButton(): TemplateResult | typeof nothing;
    protected renderExampleValueInput(model: DomainProperty): TemplateResult;
    protected renderMinimumValueInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderExclusiveMinimumInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderExclusiveMaximumInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderMaximumValueInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderMultipleOfInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderDataGovernanceSection(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderTaxonomyInput(model: DomainProperty): TemplateResult | typeof nothing;
    protected renderSelectedSemantics(selected: PropertySemantic[]): TemplateResult | typeof nothing;
    protected renderTaxonomyItem(semantic: PropertySemantic): TemplateResult;
    protected renderTaxonomyCategories(categories: Record<string, PropertySemantic[]>): TemplateResult[];
}
//# sourceMappingURL=DomainPropertyEditor.d.ts.map