{"version":3,"file":"collection-action-button.element-TmHU9Eph.js","sources":["../../../src/packages/core/collection/conditions/constants.ts","../../../src/packages/core/collection/action/collection-action-button.element.ts"],"sourcesContent":["export const UMB_COLLECTION_ALIAS_CONDITION = 'Umb.Condition.CollectionAlias';\r\n\r\n/** @deprecated No longer used internally. This will be removed in Umbraco 17. [LK] */\r\nexport const UMB_COLLECTION_BULK_ACTION_PERMISSION_CONDITION = 'Umb.Condition.CollectionBulkActionPermission';\r\n","import type { UmbCollectionAction } from './collection-action-base.js';\r\nimport { UmbActionExecutedEvent } from '@umbraco-cms/backoffice/event';\r\nimport { html, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';\r\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\r\nimport type { ManifestCollectionAction } from '@umbraco-cms/backoffice/collection';\r\nimport { createExtensionApi } from '@umbraco-cms/backoffice/extension-api';\r\nimport type { UUIButtonState } from '@umbraco-cms/backoffice/external/uui';\r\n\r\n@customElement('umb-collection-action-button')\r\nexport class UmbCollectionActionButtonElement extends UmbLitElement {\r\n\t#api?: UmbCollectionAction;\r\n\r\n\t@property({ type: Object, attribute: false })\r\n\tpublic get manifest() {\r\n\t\treturn this._manifest;\r\n\t}\r\n\tpublic set manifest(value: ManifestCollectionAction | undefined) {\r\n\t\tconst oldValue = this._manifest;\r\n\t\tif (oldValue !== value) {\r\n\t\t\tthis._manifest = value;\r\n\t\t\tthis._href = this.manifest?.meta.href;\r\n\t\t\tthis._additionalOptions = this.manifest?.meta.additionalOptions;\r\n\t\t\tthis.#createApi();\r\n\t\t\tthis.requestUpdate('manifest', oldValue);\r\n\t\t}\r\n\t}\r\n\tprivate _manifest?: ManifestCollectionAction;\r\n\r\n\tasync #createApi() {\r\n\t\tif (!this._manifest) throw new Error('No manifest defined');\r\n\t\tif (!this._manifest.api) return;\r\n\t\tthis.#api = await createExtensionApi(this, this._manifest);\r\n\r\n\t\tthis._href = (await this.#api?.getHref?.()) ?? this.manifest?.meta.href;\r\n\t\tthis._additionalOptions = (await this.#api?.hasAddionalOptions?.()) ?? this.manifest?.meta.additionalOptions;\r\n\t}\r\n\r\n\t@state()\r\n\tprivate _buttonState?: UUIButtonState;\r\n\r\n\t@state()\r\n\tprivate _additionalOptions?: boolean;\r\n\r\n\t@state()\r\n\tprivate _href?: string;\r\n\r\n\tprivate async _onClick() {\r\n\t\t// If its a link or has additional options, then we do not want to display state on the button. [NL]\r\n\t\tif (!this._href) {\r\n\t\t\tif (!this._additionalOptions) {\r\n\t\t\t\tthis._buttonState = 'waiting';\r\n\t\t\t}\r\n\r\n\t\t\ttry {\r\n\t\t\t\tif (!this.#api) throw new Error('No api defined');\r\n\t\t\t\tawait this.#api.execute();\r\n\t\t\t\tif (!this._additionalOptions) {\r\n\t\t\t\t\tthis._buttonState = 'success';\r\n\t\t\t\t}\r\n\t\t\t} catch {\r\n\t\t\t\tif (!this._additionalOptions) {\r\n\t\t\t\t\tthis._buttonState = 'failed';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.dispatchEvent(new UmbActionExecutedEvent());\r\n\t}\r\n\r\n\toverride render() {\r\n\t\tconst label = this.manifest?.meta.label\r\n\t\t\t? this.localize.string(this.manifest.meta.label)\r\n\t\t\t: (this.manifest?.name ?? '');\r\n\t\treturn html`\r\n\t\t\t\r\n\t\t`;\r\n\t}\r\n}\r\n\r\nexport default UmbCollectionActionButtonElement;\r\n\r\ndeclare global {\r\n\tinterface HTMLElementTagNameMap {\r\n\t\t'umb-collection-action-button': UmbCollectionActionButtonElement;\r\n\t}\r\n}\r\n"],"names":["UMB_COLLECTION_ALIAS_CONDITION","UMB_COLLECTION_BULK_ACTION_PERMISSION_CONDITION","_api","_UmbCollectionActionButtonElement_instances","createApi_fn","UmbCollectionActionButtonElement","UmbLitElement","__privateAdd","value","oldValue","__privateMethod","__privateGet","UmbActionExecutedEvent","label","html","__privateSet","createExtensionApi","__decorateClass","property","state","customElement","UmbCollectionActionButtonElement$1"],"mappings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