// #region Imports
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Slottable } from '../../../Behaviors/Slottable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { flowBoardColumnComposerElementTemplate } from './FlowBoardColumnComposerElementTemplate';
import { addFlowBoardComposerController } from './FlowBoardComposerController';
import { flowBoardColumnComposerElementCosmopolitanStyle } from './Themes/FlowBoardColumnComposerElement.Cosmopolitan';
import { flowBoardColumnComposerElementJoyStyle } from './Themes/FlowBoardColumnComposerElement.Joy';
import { flowBoardColumnComposerElementMemphisStyle } from './Themes/FlowBoardColumnComposerElement.Memphis';
// #endregion
/**
 * FlowBoardColumnComposer - A composer for creating new columns in a FlowBoard.
 *
 * @description
 * Provides a trigger+form pattern for adding new columns to a board.
 * This component is completely data-agnostic - it accepts any data structure.
 * The user provides their own form fields via the `form` slot.
 * Intended for use in the `slot="append"` of the FlowBoard.
 *
 * @remarks
 * The composer emits generic `create` events with user-defined data:
 * - Element properties (title, columnKey, pinned, reorderable, etc.)
 * - Metadata (ownerId, tags, status, limits, custom fields, etc.)
 * - Any other data the application needs
 *
 * @name FlowBoardColumnComposerElement
 * @element mosaik-flow-board-column-composer
 * @category Layouts
 *
 * @slot trigger - The trigger element that opens the form (e.g., "Add another list" button)
 * @slot form - The form content for creating new columns (completely user-defined)
 *
 * @csspart container - The main container element
 * @csspart trigger - The trigger section wrapper
 * @csspart form - The form section wrapper
 *
 * @cssprop {String} --flow-board-composer-min-width - Minimum width of the composer area
 * @cssprop {String} --flow-board-composer-padding - Padding inside the container
 * @cssprop {String} --flow-board-composer-gap - Gap between form elements
 *
 * @fires flowBoardBeforeColumnCreate {FlowBoardBeforeColumnCreateEvent} - Fired before column creation (cancelable)
 * @fires flowBoardColumnCreate {FlowBoardColumnCreateEvent} - Fired when column is created with user-defined data
 *
 * @example
 * Basic usage with simple form:
 * ```html
 * <mosaik-flow-board-column-composer id="composer" slot="append">
 *   <mosaik-button slot="trigger" variant="ghost" icon="plus">Add Column</mosaik-button>
 *   <div slot="form">
 *     <mosaik-input id="title" placeholder="Enter column name…"></mosaik-input>
 *     <mosaik-button @click="${submit}">Create</mosaik-button>
 *   </div>
 * </mosaik-flow-board-column-composer>
 *
 * <script>
 * function submit() {
 *     const composer = document.getElementById('composer');
 *     const title = document.getElementById('title').value;
 *     composer.create({ title });
 * }
 * </script>
 * ```
 *
 * @example
 * Advanced usage with metadata and custom fields:
 * ```html
 * <mosaik-flow-board-column-composer id="composer" slot="append">
 *   <mosaik-button slot="trigger">Add List</mosaik-button>
 *   <div slot="form">
 *     <mosaik-input id="title" placeholder="List name"></mosaik-input>
 *     <mosaik-input id="key" placeholder="list-key"></mosaik-input>
 *     <mosaik-checkbox id="pinned">Pin this column</mosaik-checkbox>
 *     <mosaik-select id="status">
 *       <option value="active">Active</option>
 *       <option value="archived">Archived</option>
 *     </mosaik-select>
 *     <mosaik-user-picker id="owner"></mosaik-user-picker>
 *     <mosaik-number-input id="maxItems" placeholder="Max items"></mosaik-number-input>
 *     <mosaik-button @click="${submit}">Create</mosaik-button>
 *   </div>
 * </mosaik-flow-board-column-composer>
 *
 * <script>
 * function submit() {
 *     const composer = document.getElementById('composer');
 *     composer.create({
 *         // Element properties
 *         title: document.getElementById('title').value,
 *         columnKey: document.getElementById('key').value,
 *         pinned: document.getElementById('pinned').checked,
 *         reorderable: true,
 *
 *         // Metadata - saved to backend
 *         metadata: {
 *             status: document.getElementById('status').value,
 *             ownerId: document.getElementById('owner').selectedUserId,
 *             maxItems: document.getElementById('maxItems').value,
 *
 *             // Custom fields - anything your app needs
 *             customFields: {
 *                 color: '#3b82f6',
 *                 icon: 'inbox',
 *                 autoArchiveAfter: 30,
 *                 notifications: {
 *                     onAddItem: true,
 *                     onMoveItem: false
 *                 }
 *             }
 *         }
 *     });
 * }
 *
 * // Listen for create events
 * composer.addEventListener('create', (e) => {
 *     const { data } = e.detail;
 *     // Save to backend API with all metadata
 *     await api.createColumn({
 *         boardId: currentBoard.id,
 *         ...data
 *     });
 * });
 * </script>
 * ```
 *
 * @public
 */
let FlowBoardColumnComposerElement = class FlowBoardColumnComposerElement extends Themeable(Slottable(CustomElement)) {
    // #region Fields
    _composerController;
    _flowBoardBeforeColumnCreate;
    _flowBoardColumnCreate;
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `FlowBoardColumnComposerElement` class.
     *
     * @public
     */
    constructor() {
        super();
        this._composerController = addFlowBoardComposerController(this);
        this._flowBoardBeforeColumnCreate = new HTMLElementEventEmitter(this, 'flowBoardBeforeColumnCreate');
        this._flowBoardColumnCreate = new HTMLElementEventEmitter(this, 'flowBoardColumnCreate');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-flow-board-column-composer';
    }
    /**
     * Gets or sets whether the composer form is open.
     *
     * @public
     * @attr
     */
    get open() {
        return this._composerController.open;
    }
    set open(value) {
        this._composerController.open = value;
    }
    // #endregion
    // #region Methods
    /**
     * Creates a new column with the provided data.
     * Emits flowBoardBeforeColumnCreate (cancelable) and flowBoardColumnCreate events.
     *
     * @param data The data for the new column (completely user-defined)
     * @returns True if created, false if canceled
     *
     * @public
     */
    create(data) {
        const beforeDetail = {
            data,
            cancel: false
        };
        this._flowBoardBeforeColumnCreate.emit(beforeDetail);
        if (beforeDetail.cancel) {
            return false;
        }
        const detail = {
            data
        };
        this._flowBoardColumnCreate.emit(detail);
        // Close the composer
        this._composerController.close();
        return true;
    }
    /**
     * Toggles the composer between open and closed state.
     *
     * @public
     */
    toggle() {
        this._composerController.toggle();
    }
    /**
     * Closes the composer form.
     *
     * @public
     */
    close() {
        this._composerController.close();
    }
    /**
     * Handles keyboard events in the form.
     * Pressing Escape closes the form.
     *
     * @param evt - The keyboard event.
     *
     * @internal
     */
    handleFormKeydown(evt) {
        this._composerController.handleFormKeydown(evt);
    }
};
__decorate([
    Attribute({ type: Boolean }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], FlowBoardColumnComposerElement.prototype, "open", null);
FlowBoardColumnComposerElement = __decorate([
    Component({
        selector: 'mosaik-flow-board-column-composer',
        template: flowBoardColumnComposerElementTemplate,
        themes: {
            joy: flowBoardColumnComposerElementJoyStyle,
            cosmopolitan: flowBoardColumnComposerElementCosmopolitanStyle,
            memphis: flowBoardColumnComposerElementMemphisStyle
        },
        host: {
            slot: 'append'
        },
        options: {
            mode: 'open',
            delegatesFocus: true
        }
    }),
    __metadata("design:paramtypes", [])
], FlowBoardColumnComposerElement);
export { FlowBoardColumnComposerElement };
//# sourceMappingURL=FlowBoardColumnComposerElement.js.map