{"version":3,"file":"trash.action-DZIN8reT.js","sources":["../../../src/packages/core/entity-bulk-action/common/trash/trash.action.ts"],"sourcesContent":["import type { UmbBulkTrashRepository } from './trash-repository.interface.js';\nimport { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';\nimport { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action';\nimport {\n\tUmbRequestReloadChildrenOfEntityEvent,\n\tUmbRequestReloadStructureForEntityEvent,\n} from '@umbraco-cms/backoffice/entity-action';\nimport { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';\nimport { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';\nimport { umbConfirmModal } from '@umbraco-cms/backoffice/modal';\nimport type { MetaEntityBulkActionTrashKind } from '@umbraco-cms/backoffice/extension-registry';\n\nexport class UmbMediaTrashEntityBulkAction extends UmbEntityBulkActionBase {\n\tasync execute() {\n\t\tif (this.selection?.length === 0) return;\n\n\t\tawait umbConfirmModal(this._host, {\n\t\t\theadline: `Trash`,\n\t\t\tcontent: `Are you sure you want to move ${this.selection.length} ${this.selection.length === 1 ? 'item' : 'items'} to the recycle bin?`,\n\t\t\tcolor: 'danger',\n\t\t\tconfirmLabel: 'Trash',\n\t\t});\n\n\t\tconst bulkTrashRepository = await createExtensionApiByAlias(\n\t\t\tthis,\n\t\t\tthis.args.meta.bulkTrashRepositoryAlias,\n\t\t);\n\t\tif (!bulkTrashRepository) throw new Error('Bulk Trash Repository is not available');\n\n\t\tawait bulkTrashRepository.requestBulkTrash({ uniques: this.selection });\n\n\t\tconst entityContext = await this.getContext(UMB_ENTITY_CONTEXT);\n\t\tif (!entityContext) throw new Error('Entity Context is not available');\n\n\t\tconst entityType = entityContext.getEntityType();\n\t\tconst unique = entityContext.getUnique();\n\n\t\tif (entityType && unique !== undefined) {\n\t\t\tconst eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);\n\t\t\tif (!eventContext) throw new Error('Event Context is not available');\n\n\t\t\tconst args = { entityType, unique };\n\n\t\t\tconst reloadChildren = new UmbRequestReloadChildrenOfEntityEvent(args);\n\t\t\teventContext.dispatchEvent(reloadChildren);\n\n\t\t\tconst reloadStructure = new UmbRequestReloadStructureForEntityEvent(args);\n\t\t\teventContext.dispatchEvent(reloadStructure);\n\t\t}\n\t}\n}\n\nexport { UmbMediaTrashEntityBulkAction as api };\n"],"names":["UmbMediaTrashEntityBulkAction","UmbEntityBulkActionBase","umbConfirmModal","bulkTrashRepository","createExtensionApiByAlias","entityContext","UMB_ENTITY_CONTEXT","entityType","unique","eventContext","UMB_ACTION_EVENT_CONTEXT","args","reloadChildren","UmbRequestReloadChildrenOfEntityEvent","reloadStructure","UmbRequestReloadStructureForEntityEvent"],"mappings":";;;;;;AAYO,MAAMA,UAAsCC,EAAuD;AAAA,EACzG,MAAM,UAAU;AACX,QAAA,KAAK,WAAW,WAAW,EAAG;AAE5B,UAAAC,EAAgB,KAAK,OAAO;AAAA,MACjC,UAAU;AAAA,MACV,SAAS,iCAAiC,KAAK,UAAU,MAAM,IAAI,KAAK,UAAU,WAAW,IAAI,SAAS,OAAO;AAAA,MACjH,OAAO;AAAA,MACP,cAAc;AAAA,IAAA,CACd;AAED,UAAMC,IAAsB,MAAMC;AAAA,MACjC;AAAA,MACA,KAAK,KAAK,KAAK;AAAA,IAAA;AAEhB,QAAI,CAACD,EAA2B,OAAA,IAAI,MAAM,wCAAwC;AAElF,UAAMA,EAAoB,iBAAiB,EAAE,SAAS,KAAK,WAAW;AAEtE,UAAME,IAAgB,MAAM,KAAK,WAAWC,CAAkB;AAC9D,QAAI,CAACD,EAAqB,OAAA,IAAI,MAAM,iCAAiC;AAE/D,UAAAE,IAAaF,EAAc,iBAC3BG,IAASH,EAAc;AAEzB,QAAAE,KAAcC,MAAW,QAAW;AACvC,YAAMC,IAAe,MAAM,KAAK,WAAWC,CAAwB;AACnE,UAAI,CAACD,EAAoB,OAAA,IAAI,MAAM,gCAAgC;AAE7D,YAAAE,IAAO,EAAE,YAAAJ,GAAY,QAAAC,KAErBI,IAAiB,IAAIC,EAAsCF,CAAI;AACrE,MAAAF,EAAa,cAAcG,CAAc;AAEnC,YAAAE,IAAkB,IAAIC,EAAwCJ,CAAI;AACxE,MAAAF,EAAa,cAAcK,CAAe;AAAA,IAC3C;AAAA,EACD;AACD;"}