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_USER_WORKSPACE_CONTEXT } from '../user-workspace.context-token.js';
import { html, customElement, state } from '../../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../../../core/lit-element/index.js';
// TODO: This seems like legacy code [NL]
let UmbUserWorkspaceActionSaveElement = class UmbUserWorkspaceActionSaveElement extends UmbLitElement {
    constructor() {
        super();
        this.consumeContext(UMB_USER_WORKSPACE_CONTEXT, (instance) => {
            this._workspaceContext = instance;
        });
    }
    async _handleSave() {
        if (!this._workspaceContext)
            return;
        this._saveButtonState = 'waiting';
        await this._workspaceContext
            .requestSubmit()
            .then(() => {
            this._saveButtonState = 'success';
        })
            .catch(() => {
            this._saveButtonState = 'failed';
        });
    }
    render() {
        return html `<uui-button
			@click=${this._handleSave}
			look="primary"
			color="positive"
			label="save"
			.state="${this._saveButtonState}"></uui-button>`;
    }
};
__decorate([
    state()
], UmbUserWorkspaceActionSaveElement.prototype, "_saveButtonState", void 0);
UmbUserWorkspaceActionSaveElement = __decorate([
    customElement('umb-user-workspace-action-save')
], UmbUserWorkspaceActionSaveElement);
export { UmbUserWorkspaceActionSaveElement };
export default UmbUserWorkspaceActionSaveElement;
