{"version":3,"file":"move-to.action-CVcFQz6t.js","sources":["../../../src/packages/core/entity-bulk-action/common/move-to/move-to.action.ts"],"sourcesContent":["import type { UmbBulkMoveToRepository } from './move-to-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 { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';\nimport { UMB_TREE_PICKER_MODAL } from '@umbraco-cms/backoffice/tree';\nimport type { MetaEntityBulkActionMoveToKind } from '@umbraco-cms/backoffice/extension-registry';\n\nexport class UmbMediaMoveEntityBulkAction extends UmbEntityBulkActionBase {\n\tasync execute() {\n\t\tif (this.selection?.length === 0) return;\n\n\t\tconst modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);\n\n\t\tconst modalContext = modalManager.open(this, UMB_TREE_PICKER_MODAL, {\n\t\t\tdata: {\n\t\t\t\tfoldersOnly: this.args.meta.foldersOnly,\n\t\t\t\thideTreeRoot: this.args.meta.hideTreeRoot,\n\t\t\t\ttreeAlias: this.args.meta.treeAlias,\n\t\t\t},\n\t\t});\n\n\t\tconst value = await modalContext.onSubmit().catch(() => undefined);\n\t\tif (!value?.selection?.length) return;\n\n\t\tconst destinationUnique = value.selection[0];\n\t\tif (destinationUnique === undefined) throw new Error('Destination Unique is not available');\n\n\t\tconst bulkMoveRepository = await createExtensionApiByAlias(\n\t\t\tthis,\n\t\t\tthis.args.meta.bulkMoveRepositoryAlias,\n\t\t);\n\t\tif (!bulkMoveRepository) throw new Error('Bulk Move Repository is not available');\n\n\t\tawait bulkMoveRepository.requestBulkMoveTo({ uniques: this.selection, destination: { unique: destinationUnique } });\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 { UmbMediaMoveEntityBulkAction as api };\n"],"names":["UmbMediaMoveEntityBulkAction","UmbEntityBulkActionBase","value","UMB_MODAL_MANAGER_CONTEXT","UMB_TREE_PICKER_MODAL","destinationUnique","bulkMoveRepository","createExtensionApiByAlias","entityContext","UMB_ENTITY_CONTEXT","entityType","unique","eventContext","UMB_ACTION_EVENT_CONTEXT","args","reloadChildren","UmbRequestReloadChildrenOfEntityEvent","reloadStructure","UmbRequestReloadStructureForEntityEvent"],"mappings":";;;;;;;AAaO,MAAMA,UAAqCC,EAAwD;AAAA,EACzG,MAAM,UAAU;AACX,QAAA,KAAK,WAAW,WAAW,EAAG;AAYlC,UAAMC,IAAQ,OAVO,MAAM,KAAK,WAAWC,CAAyB,GAElC,KAAK,MAAMC,GAAuB;AAAA,MACnE,MAAM;AAAA,QACL,aAAa,KAAK,KAAK,KAAK;AAAA,QAC5B,cAAc,KAAK,KAAK,KAAK;AAAA,QAC7B,WAAW,KAAK,KAAK,KAAK;AAAA,MAC3B;AAAA,IAAA,CACA,EAEgC,SAAW,EAAA,MAAM,MAAA;AAAA,KAAe;AAC7D,QAAA,CAACF,GAAO,WAAW,OAAQ;A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