{"version":3,"file":"modal-base.element-Ch1QfFez.js","sources":["../../../src/packages/core/modal/context/modal.context-token.ts","../../../src/packages/core/modal/component/modal.element.ts","../../../src/packages/core/modal/context/modal.context.ts","../../../src/packages/core/modal/context/modal-manager.context.ts","../../../src/packages/core/modal/component/modal-base.element.ts"],"sourcesContent":["import type { UmbModalContext } from './modal.context.js';\nimport { UmbContextToken } from '@umbraco-cms/backoffice/context-api';\n\nexport const UMB_MODAL_CONTEXT = new UmbContextToken('UmbModalContext');\n","import type { UmbModalContext } from '../context/modal.context.js';\nimport { UMB_MODAL_CONTEXT } from '../context/modal.context-token.js';\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\nimport type { ManifestModal } from '@umbraco-cms/backoffice/extension-registry';\nimport { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';\nimport { UmbTextStyles } from '@umbraco-cms/backoffice/style';\nimport type { CSSResultGroup } from '@umbraco-cms/backoffice/external/lit';\nimport { html, customElement } from '@umbraco-cms/backoffice/external/lit';\nimport { UmbBasicState, type UmbObserverController } from '@umbraco-cms/backoffice/observable-api';\nimport {\n\tUUIModalCloseEvent,\n\ttype UUIDialogElement,\n\ttype UUIModalDialogElement,\n\ttype UUIModalSidebarElement,\n} from '@umbraco-cms/backoffice/external/uui';\nimport type { UmbRouterSlotElement } from '@umbraco-cms/backoffice/router';\nimport { createExtensionElement } from '@umbraco-cms/backoffice/extension-api';\nimport type { UmbContextRequestEvent } from '@umbraco-cms/backoffice/context-api';\nimport { UMB_CONTENT_REQUEST_EVENT_TYPE, UmbContextProvider } from '@umbraco-cms/backoffice/context-api';\n\n@customElement('umb-modal')\nexport class UmbModalElement extends UmbLitElement {\n\t#modalContext?: UmbModalContext;\n\tpublic get modalContext(): UmbModalContext | undefined {\n\t\treturn this.#modalContext;\n\t}\n\tpublic set modalContext(value: UmbModalContext | undefined) {\n\t\tif (this.#modalContext === value) return;\n\t\tthis.#modalContext = value;\n\n\t\tif (!value) {\n\t\t\tthis.destroy();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#createModalElement();\n\t}\n\n\tpublic element?: UUIModalDialogElement | UUIModalSidebarElement;\n\n\t#innerElement = new UmbBasicState(undefined);\n\n\t#modalExtensionObserver?: UmbObserverController;\n\t#modalRouterElement: UmbRouterSlotElement = document.createElement('umb-router-slot');\n\n\t#onClose = () => {\n\t\tthis.element?.removeEventListener(UUIModalCloseEvent, this.#onClose);\n\t\tthis.#modalContext?.reject({ type: 'close' });\n\t};\n\n\t#createModalElement() {\n\t\tif (!this.#modalContext) return;\n\n\t\tthis.#modalContext.addEventListener('umb:destroy', this.#onContextDestroy);\n\t\tthis.element = this.#createContainerElement();\n\n\t\t// Makes sure that the modal triggers the reject of the context promise when it is closed by pressing escape.\n\t\tthis.element.addEventListener(UUIModalCloseEvent, this.#onClose);\n\n\t\t// The following code is the context api proxy.\n\t\t// It re-dispatches the context api request event to the origin target of this modal, in other words the element that initiated the modal. [NL]\n\t\tthis.element.addEventListener(UMB_CONTENT_REQUEST_EVENT_TYPE, ((event: UmbContextRequestEvent) => {\n\t\t\tif (!this.#modalContext) return;\n\t\t\t// Note for this hack (The if-sentence): [NL]\n\t\t\t// We do not currently have a good enough control to ensure that the proxy is last, meaning if another context is provided at this element, it might respond after the proxy event has been dispatched.\n\t\t\t// To avoid such this hack just prevents proxying the event if its a request for the Modal Context. [NL]\n\t\t\tif (event.contextAlias !== UMB_MODAL_CONTEXT.contextAlias) {\n\t\t\t\tevent.stopImmediatePropagation();\n\t\t\t\tthis.#modalContext.getHostElement().dispatchEvent(event.clone());\n\t\t\t}\n\t\t}) as EventListener);\n\n\t\tthis.#modalContext.onSubmit().then(\n\t\t\t() => {\n\t\t\t\tthis.element?.close();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.element?.close();\n\t\t\t},\n\t\t);\n\n\t\t/**\n\t\t *\n\t\t * Maybe we could just get a Modal Router Slot. But it needs to have the ability to actually inject via slot. so the modal inner element can be within.\n\t\t *\n\t\t */\n\t\tif (this.#modalContext.router) {\n\t\t\tthis.#modalRouterElement.routes = [\n\t\t\t\t{\n\t\t\t\t\tpath: '',\n\t\t\t\t\tcomponent: document.createElement('slot'),\n\t\t\t\t},\n\t\t\t];\n\t\t\tthis.#modalRouterElement.parent = this.#modalContext.router;\n\t\t}\n\n\t\tthis.element.appendChild(this.#modalRouterElement);\n\t\tthis.#observeModal(this.#modalContext.alias.toString());\n\n\t\tconst provider = new UmbContextProvider(this.element, UMB_MODAL_CONTEXT, this.#modalContext);\n\t\tprovider.hostConnected();\n\t}\n\n\t#createContainerElement() {\n\t\treturn this.#modalContext!.type === 'sidebar' ? this.#createSidebarElement() : this.#createDialogElement();\n\t}\n\n\t#createSidebarElement() {\n\t\tconst sidebarElement = document.createElement('uui-modal-sidebar');\n\t\tsidebarElement.size = this.#modalContext!.size;\n\t\treturn sidebarElement;\n\t}\n\n\t#createDialogElement() {\n\t\tconst modalDialogElement = document.createElement('uui-modal-dialog');\n\t\tconst dialogElement: UUIDialogElement = document.createElement('uui-dialog');\n\t\tmodalDialogElement.appendChild(dialogElement);\n\t\treturn modalDialogElement;\n\t}\n\n\t#observeModal(alias: string) {\n\t\tthis.#modalExtensionObserver?.destroy();\n\n\t\tthis.observe(umbExtensionsRegistry.byTypeAndAlias('modal', alias), async (manifest) => {\n\t\t\tthis.#removeInnerElement();\n\n\t\t\tif (manifest) {\n\t\t\t\tconst innerElement = await this.#createInnerElement(manifest);\n\t\t\t\tif (innerElement) {\n\t\t\t\t\tthis.#appendInnerElement(innerElement);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tasync #createInnerElement(manifest: ManifestModal) {\n\t\t// TODO: add inner fallback element if no extension element is found\n\t\tconst innerElement = await createExtensionElement(manifest);\n\n\t\tif (!this.#modalContext) {\n\t\t\t// If context does not exist any more, it means we have been destroyed. So we need to back out:\n\t\t\treturn undefined;\n\t\t}\n\t\tif (innerElement) {\n\t\t\tinnerElement.manifest = manifest;\n\t\t\tinnerElement.data = this.#modalContext.data;\n\t\t\tinnerElement.modalContext = this.#modalContext;\n\t\t}\n\n\t\treturn innerElement;\n\t}\n\n\t#appendInnerElement(element: HTMLElement) {\n\t\tthis.#modalRouterElement.appendChild(element);\n\t\tthis.#innerElement.setValue(element);\n\t}\n\n\t#removeInnerElement() {\n\t\tconst innerElement = this.#innerElement.getValue();\n\t\tif (innerElement) {\n\t\t\tthis.#modalRouterElement.removeChild(innerElement);\n\t\t\tthis.#innerElement.setValue(undefined);\n\t\t}\n\t}\n\n\toverride render() {\n\t\treturn html`${this.element}`;\n\t}\n\n\toverride disconnectedCallback(): void {\n\t\tsuper.disconnectedCallback();\n\t\tthis.destroy();\n\t}\n\n\t#onContextDestroy = () => {\n\t\tthis.destroy();\n\t};\n\n\toverride destroy() {\n\t\tthis.#innerElement.destroy();\n\t\tthis.#modalExtensionObserver?.destroy();\n\t\tthis.#modalExtensionObserver = undefined;\n\t\tif (this.#modalContext) {\n\t\t\tthis.#modalContext.removeEventListener('umb:destroy', this.#onContextDestroy);\n\t\t\tthis.#modalContext.destroy();\n\t\t\tthis.#modalContext = undefined;\n\t\t}\n\t\tsuper.destroy();\n\t}\n\n\tstatic override styles: CSSResultGroup = [UmbTextStyles];\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'umb-modal': UmbModalElement;\n\t}\n}\n","import { UmbModalToken } from '../token/modal-token.js';\nimport type { UmbModalConfig, UmbModalType } from './modal-manager.context.js';\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\nimport type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot';\nimport type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';\nimport { UmbId } from '@umbraco-cms/backoffice/id';\nimport { UmbObjectState } from '@umbraco-cms/backoffice/observable-api';\nimport { UmbControllerBase } from '@umbraco-cms/backoffice/class-api';\nimport { type UmbDeepPartialObject, umbDeepMerge } from '@umbraco-cms/backoffice/utils';\n\nexport interface UmbModalRejectReason {\n\ttype: string;\n}\n\nexport type UmbModalContextClassArgs<\n\tModalAliasType extends string | UmbModalToken,\n\tModalAliasTypeAsToken extends UmbModalToken = ModalAliasType extends UmbModalToken\n\t\t? ModalAliasType\n\t\t: UmbModalToken,\n> = {\n\trouter?: IRouterSlot | null;\n\tdata?: ModalAliasTypeAsToken['DATA'];\n\tvalue?: ModalAliasTypeAsToken['VALUE'];\n\tmodal?: UmbModalConfig;\n};\n\n// TODO: consider splitting this into two separate handlers\nexport class UmbModalContext<\n\tModalData extends { [key: string]: any } = { [key: string]: any },\n\tModalValue = any,\n> extends UmbControllerBase {\n\t//\n\t#submitPromise: Promise;\n\t#submitResolver?: (value: ModalValue) => void;\n\t#submitRejecter?: (reason?: UmbModalRejectReason) => void;\n\n\tpublic readonly key: string;\n\tpublic readonly data: ModalData;\n\tpublic readonly type: UmbModalType = 'dialog';\n\tpublic readonly size: UUIModalSidebarSize = 'small';\n\tpublic readonly backdropBackground?: string;\n\tpublic readonly router: IRouterSlot | null = null;\n\tpublic readonly alias: string | UmbModalToken;\n\n\t#value;\n\tpublic readonly value;\n\n\tconstructor(\n\t\thost: UmbControllerHost,\n\t\tmodalAlias: string | UmbModalToken,\n\t\targs: UmbModalContextClassArgs,\n\t) {\n\t\tsuper(host);\n\t\tthis.key = args.modal?.key || UmbId.new();\n\t\tthis.router = args.router ?? null;\n\t\tthis.alias = modalAlias;\n\n\t\tif (this.alias instanceof UmbModalToken) {\n\t\t\tthis.type = this.alias.getDefaultModal()?.type || this.type;\n\t\t\tthis.size = this.alias.getDefaultModal()?.size || this.size;\n\t\t\tthis.backdropBackground = this.alias.getDefaultModal()?.backdropBackground || this.backdropBackground;\n\t\t}\n\n\t\tthis.type = args.modal?.type || this.type;\n\t\tthis.size = args.modal?.size || this.size;\n\t\tthis.backdropBackground = args.modal?.backdropBackground || this.backdropBackground;\n\n\t\tconst defaultData = this.alias instanceof UmbModalToken ? this.alias.getDefaultData() : undefined;\n\t\tthis.data = Object.freeze(\n\t\t\t// If we have both data and defaultData perform a deep merge\n\t\t\targs.data && defaultData\n\t\t\t\t? (umbDeepMerge(args.data as UmbDeepPartialObject, defaultData) as ModalData)\n\t\t\t\t: // otherwise pick one of them:\n\t\t\t\t\t((args.data as ModalData) ?? defaultData),\n\t\t);\n\n\t\tconst initValue =\n\t\t\targs.value ?? (this.alias instanceof UmbModalToken ? (this.alias as UmbModalToken).getDefaultValue() : undefined);\n\n\t\tthis.#value = new UmbObjectState(initValue) as UmbObjectState;\n\t\tthis.value = this.#value.asObservable();\n\n\t\t// TODO: Consider if its right to use Promises, or use another event based system? Would we need to be able to cancel an event, to then prevent the closing..?\n\t\tthis.#submitPromise = new Promise((resolve, reject) => {\n\t\t\tthis.#submitResolver = resolve;\n\t\t\tthis.#submitRejecter = reject;\n\t\t});\n\t}\n\n\t// note, this methods is private argument is not defined correctly here, but requires to be fix by appending the OptionalSubmitArgumentIfUndefined type when newing up this class.\n\t/**\n\t * Submits this modal, returning with a value to the initiator of the modal.\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic submit() {\n\t\tthis.#submitResolver?.(this.getValue());\n\t\t// TODO: Could we clean up this class here? (Example destroy the value state, and other things?)\n\t}\n\n\t/**\n\t * Closes this modal\n\t * @param reason\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic reject(reason?: UmbModalRejectReason) {\n\t\tthis.#submitRejecter?.(reason);\n\t\t// TODO: Could we clean up this class here? (Example destroy the value state, and other things?)\n\t}\n\n\t/**\n\t * Gives a Promise which will be resolved when this modal is submitted.\n\t * @returns {Promise}\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic onSubmit() {\n\t\treturn this.#submitPromise;\n\t}\n\n\t/**\n\t * Gives the current value of this modal.\n\t * @returns {ModalValue}\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic getValue() {\n\t\treturn this.#value.getValue();\n\t}\n\n\t/**\n\t * Sets the current value of this modal.\n\t * @param value\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic setValue(value: ModalValue) {\n\t\tthis.#value.setValue(value);\n\t}\n\n\t/**\n\t * Updates the current value of this modal.\n\t * @param partialValue\n\t * @public\n\t * @memberof UmbModalContext\n\t */\n\tpublic updateValue(partialValue: Partial) {\n\t\tthis.#value.update(partialValue);\n\t}\n\n\tpublic override destroy(): void {\n\t\tthis.dispatchEvent(new CustomEvent('umb:destroy'));\n\t\tthis.#value.destroy();\n\t\t(this as any).router = null;\n\t\t(this as any).data = undefined;\n\t\tsuper.destroy();\n\t}\n}\n","import type { UmbModalToken } from '../token/modal-token.js';\nimport { UmbModalContext, type UmbModalContextClassArgs } from './modal.context.js';\nimport type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui';\nimport { UmbBasicState, appendToFrozenArray } from '@umbraco-cms/backoffice/observable-api';\nimport { UmbContextToken } from '@umbraco-cms/backoffice/context-api';\nimport { UmbContextBase } from '@umbraco-cms/backoffice/class-api';\nimport type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';\n\nexport type UmbModalType = 'dialog' | 'sidebar';\n\nexport interface UmbModalConfig {\n\tkey?: string;\n\ttype?: UmbModalType;\n\tsize?: UUIModalSidebarSize;\n\n\t/**\n\t * Set the background property of the modal backdrop\n\t */\n\tbackdropBackground?: string;\n}\n\nexport class UmbModalManagerContext extends UmbContextBase {\n\t// TODO: Investigate if we can get rid of HTML elements in our store, so we can use one of our states.\n\t#modals = new UmbBasicState(>[]);\n\tpublic readonly modals = this.#modals.asObservable();\n\n\tconstructor(host: UmbControllerHost) {\n\t\tsuper(host, UMB_MODAL_MANAGER_CONTEXT);\n\t}\n\n\t/**\n\t * Opens a modal or sidebar modal\n\t * @public\n\t * @param {UmbControllerHost} host - The host that the modal should be attached to, this is usually the controller/element that is opening the modal. This additionally acts as the modal origin for the context api.\n\t * @param {(string | UmbModalToken)} modalAlias - The alias or token of the modal to open\n\t * @param {UmbModalContextClassArgs} args - The arguments for this setup.\n\t * @returns {*} {UmbModalHandler}\n\t * @memberof UmbModalManagerContext\n\t */\n\tpublic open<\n\t\tModalData extends { [key: string]: any } = { [key: string]: any },\n\t\tModalValue = unknown,\n\t\tModalAliasTypeAsToken extends UmbModalToken = UmbModalToken,\n\t>(\n\t\thost: UmbControllerHost,\n\t\tmodalAlias: UmbModalToken | string,\n\t\targs: UmbModalContextClassArgs = {},\n\t) {\n\t\tconst modalContext = new UmbModalContext(host, modalAlias, args);\n\n\t\t// Append to store:\n\t\tthis.#modals.setValue(\n\t\t\tappendToFrozenArray(this.#modals.value, modalContext, (entry) => entry.key === modalContext.key),\n\t\t);\n\n\t\t// Return to implementor:\n\t\treturn modalContext;\n\t}\n\n\t/**\n\t * Closes a modal or sidebar modal\n\t * @private\n\t * @param {string} key\n\t * @memberof UmbModalManagerContext\n\t */\n\tpublic close(key: string) {\n\t\tconst modal = this.#modals.getValue().find((modal) => modal.key === key);\n\t\tif (modal) {\n\t\t\tmodal.reject();\n\t\t}\n\t}\n\n\tpublic remove(key: string) {\n\t\tthis.#modals.setValue(this.#modals.getValue().filter((modal) => modal.key !== key));\n\t}\n}\n\nexport const UMB_MODAL_MANAGER_CONTEXT = new UmbContextToken(\n\t'UmbModalManagerContext',\n);\n","import type { UmbModalRejectReason, UmbModalContext } from '../context/index.js';\nimport { property } from '@umbraco-cms/backoffice/external/lit';\nimport { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';\nimport type { ManifestModal, UmbModalExtensionElement } from '@umbraco-cms/backoffice/extension-registry';\n\nexport abstract class UmbModalBaseElement<\n\t\tModalDataType extends object = object,\n\t\tModalValueType = unknown,\n\t\tModalManifestType extends ManifestModal = ManifestModal,\n\t>\n\textends UmbLitElement\n\timplements UmbModalExtensionElement\n{\n\t#value: ModalValueType = {} as ModalValueType;\n\n\t@property({ type: Object, attribute: false })\n\tpublic manifest?: ModalManifestType;\n\n\t#modalContext?: UmbModalContext | undefined;\n\t@property({ attribute: false })\n\tpublic set modalContext(context: UmbModalContext | undefined) {\n\t\tthis.#modalContext = context;\n\t\tif (context) {\n\t\t\tthis.observe(\n\t\t\t\tcontext.value,\n\t\t\t\t(value) => {\n\t\t\t\t\tconst oldValue = this.#value;\n\t\t\t\t\tthis.#value = value;\n\t\t\t\t\tthis.requestUpdate('value', oldValue);\n\t\t\t\t\t// Idea: we could implement a callback method on class.\n\t\t\t\t},\n\t\t\t\t'observeModalContextValue',\n\t\t\t);\n\t\t}\n\t}\n\tpublic get modalContext(): UmbModalContext | undefined {\n\t\treturn this.#modalContext;\n\t}\n\n\t@property({ attribute: false })\n\tpublic set data(value: ModalDataType | undefined) {\n\t\tthis._data = value;\n\t}\n\tpublic get data(): ModalDataType | undefined {\n\t\treturn this._data;\n\t}\n\tprivate _data?: ModalDataType | undefined;\n\n\t@property({ attribute: false })\n\tpublic set value(value: ModalValueType) {\n\t\tthis.#modalContext?.setValue(value);\n\t}\n\tpublic get value(): ModalValueType {\n\t\treturn this.#value;\n\t}\n\n\tpublic updateValue(partialValue: Partial) {\n\t\tthis.#modalContext?.updateValue(partialValue);\n\t}\n\n\t/**\n\t * Submits the modal\n\t * @protected\n\t * @memberof UmbModalBaseElement\n\t */\n\tprotected _submitModal() {\n\t\tthis.#modalContext?.submit();\n\t}\n\n\t/**\n\t * Rejects the modal\n\t * @param reason\n\t * @protected\n\t * @memberof UmbModalBaseElement\n\t */\n\tprotected _rejectModal(reason?: UmbModalRejectReason) {\n\t\tthis.#modalContext?.reject(reason);\n\t}\n}\n"],"names":["UMB_MODAL_CONTEXT","UmbContextToken","_modalContext","_innerElement","_modalExtensionObserver","_modalRouterElement","_onClose","_UmbModalElement_instances","createModalElement_fn","createContainerElement_fn","createSidebarElement_fn","createDialogElement_fn","observeModal_fn","createInnerElement_fn","appendInnerElement_fn","removeInnerElement_fn","_onContextDestroy","UmbModalElement","UmbLitElement","__privateAdd","UmbBasicState","UUIModalCloseEvent","__privateGet","value","__privateSet","__privateMethod","html","UMB_CONTENT_REQUEST_EVENT_TYPE","event","UmbContextProvider","sidebarElement","modalDialogElement","dialogElement","alias","umbExtensionsRegistry","manifest","innerElement","createExtensionElement","element","UmbTextStyles","__decorateClass","customElement","UmbModalContext","UmbControllerBase","host","modalAlias","args","UmbId","UmbModalToken","defaultData","umbDeepMerge","initValue","#value","UmbObjectState","#submitPromise","resolve","reject","#submitResolver","#submitRejecter","reason","partialValue","UmbModalManagerContext","UmbContextBase","UMB_MODAL_MANAGER_CONTEXT","#modals","modalContext","appendToFrozenArray","entry","key","modal","UmbModalBaseElement","#modalContext","context","oldValue","property"],"mappings":";;;;;;;;;;;;AAGa,MAAAA,IAAoB,IAAIC,EAAiC,iBAAiB;;;;;;;wYCHvFC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAqBa,IAAAC,IAAN,cAA8BC,EAAc;AAAA,EAA5C,cAAA;AAAA,UAAA,GAAA,SAAA,GAAAC,EAAA,MAAAZ,CAAA,GACNY,EAAA,MAAAjB,CAAA,GAkBgBiB,EAAA,MAAAhB,GAAA,IAAIiB,EAAuC,MAAS,CAAA,GAEpED,EAAA,MAAAf,CAAA,GAC4Ce,EAAA,MAAAd,GAAA,SAAS,cAAc,iBAAiB,CAAA,GAEpFc,EAAA,MAAAb,GAAW,MAAM;AAChB,WAAK,SAAS,oBAAoBe,GAAoBC,EAAA,MAAKhB,CAAQ,CAAA,GACnEgB,EAAA,MAAKpB,CAAe,GAAA,OAAO,EAAE,MAAM,SAAS;AAAA,IAAA,CAC7C,GA8HAiB,EAAA,MAAAH,GAAoB,MAAM;AACzB,WAAK,QAAQ;AAAA,IAAA,CACd;AAAA,EAAA;AAAA,EAzJA,IAAW,eAA4C;AACtD,WAAOM,EAAK,MAAApB,CAAA;AAAA,EACb;AAAA,EACA,IAAW,aAAaqB,GAAoC;AACvD,QAAAD,EAAA,MAAKpB,OAAkBqB,GAG3B;AAAA,UAFAC,EAAA,MAAKtB,GAAg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