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;
};
import { UMB_STYLESHEET_FOLDER_REPOSITORY_ALIAS } from '../../../tree/folder/index.js';
import { html, customElement } from '../../../../../../external/lit/index.js';
import { UmbModalBaseElement } from '../../../../../core/modal/index.js';
import { UmbCreateFolderEntityAction } from '../../../../../core/tree/index.js';
/** @deprecated No longer used internally. This will be removed in Umbraco 18. [LK] */
let UmbStylesheetCreateOptionsModalElement = class UmbStylesheetCreateOptionsModalElement extends UmbModalBaseElement {
    #createFolderAction;
    connectedCallback() {
        super.connectedCallback();
        if (!this.data?.parent)
            throw new Error('A parent is required to create a folder');
        this.#createFolderAction = new UmbCreateFolderEntityAction(this, {
            unique: this.data.parent.unique,
            entityType: this.data.parent.entityType,
            meta: {
                icon: 'icon-folder',
                label: 'New folder...',
                folderRepositoryAlias: UMB_STYLESHEET_FOLDER_REPOSITORY_ALIAS,
            },
        });
    }
    async #onCreateFolderClick(event) {
        event.stopPropagation();
        this.#createFolderAction
            ?.execute()
            .then(() => {
            this._submitModal();
        })
            .catch(() => { });
    }
    // close the modal when navigating to data type
    #onNavigate() {
        this._submitModal();
    }
    #getCreateHref() {
        return `section/settings/workspace/stylesheet/create/parent/${this.data?.parent.entityType}/${this.data?.parent.unique || 'null'}`;
    }
    render() {
        return html `
			<umb-body-layout headline="Create Stylesheet">
				<uui-box>
					<!-- TODO: construct url -->
					<uui-menu-item
						href=${`${this.#getCreateHref()}/view/code`}
						label=${this.localize.term('create_newStyleSheetFile')}
						@click=${this.#onNavigate}>
						<uui-icon slot="icon" name="icon-palette"></uui-icon>
					</uui-menu-item>

					<uui-menu-item @click=${this.#onCreateFolderClick} label="${this.localize.term('create_newFolder')}...">
						<uui-icon slot="icon" name="icon-folder"></uui-icon>
					</uui-menu-item>
				</uui-box>

				<uui-button
					slot="actions"
					id="cancel"
					label=${this.localize.term('general_cancel')}
					@click=${this._rejectModal}></uui-button>
			</umb-body-layout>
		`;
    }
};
UmbStylesheetCreateOptionsModalElement = __decorate([
    customElement('umb-stylesheet-create-options-modal')
], UmbStylesheetCreateOptionsModalElement);
export { UmbStylesheetCreateOptionsModalElement };
export default UmbStylesheetCreateOptionsModalElement;
