{"version":3,"file":"odx-angular-cdk-dynamic-view.mjs","sources":["../../../../libs/angular/cdk/dynamic-view/src/lib/dynamic-view.component.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/helpers/create-projectable-nodes.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/helpers/is-dynamic-text-content.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/models/dynamic-component-ref.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/models/dynamic-template-ref.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/helpers/is-dynamic-view.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/tokens/dynamic-view-context.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/tokens/dynamic-view-default-host.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/dynamic-view.service.ts","../../../../libs/angular/cdk/dynamic-view/src/lib/dynamic-view.directive.ts","../../../../libs/angular/cdk/dynamic-view/src/odx-angular-cdk-dynamic-view.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, inject, Input, OnDestroy, SecurityContext, ViewEncapsulation } from '@angular/core';\nimport { DomSanitizer } from '@angular/platform-browser';\nimport { injectElement } from '@odx/angular/utils';\nimport { distinctUntilChanged, isObservable, Subscription } from 'rxjs';\nimport { DynamicTextContent } from './facade';\n\n@Component({\n  selector: 'odx-dynamic-view',\n  template: '',\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  encapsulation: ViewEncapsulation.None,\n  standalone: true,\n})\nexport class DynamicViewComponent implements OnDestroy {\n  private readonly element = injectElement();\n  private readonly sanitizer = inject(DomSanitizer);\n  private currentSubscription: Subscription | null = null;\n\n  @Input()\n  public set content(value: DynamicTextContent) {\n    if (isObservable(value)) {\n      this.ngOnDestroy();\n      this.currentSubscription = value.pipe(distinctUntilChanged()).subscribe((innerValue) => {\n        this.setContent(innerValue);\n      });\n    } else {\n      this.setContent(value);\n    }\n  }\n\n  public ngOnDestroy(): void {\n    this.currentSubscription?.unsubscribe();\n    this.currentSubscription = null;\n  }\n\n  private setContent(value: string): void {\n    this.element.nativeElement.innerHTML = this.sanitizer.sanitize(SecurityContext.HTML, value) ?? '';\n  }\n}\n","import { reflectComponentType, Type } from '@angular/core';\n\n/**\n * Prepares an array of node arrays suitable for projection into the `<ng-content>` slots\n * of a dynamically created Angular component based on its content selectors.\n *\n * The function inspects the component's content selectors and aligns the provided nodes\n * for projection according to these selectors. A selector of '*' indicates that the nodes\n * should be projected into this slot. If a content selector does not match '*', an empty\n * array is returned for that slot, indicating no nodes are projected into it.\n *\n * @param {Type<unknown>} component - The component class for which the projectable nodes are being prepared.\n * @param {Node[]} nodes - The nodes intended for projection into the component's `<ng-content>` slots.\n * @returns {Node[][]} An array of node arrays, each corresponding to a `<ng-content>` slot in the component.\n * Each sub-array contains nodes to be projected into the respective `<ng-content>` slot, based on the component's content selectors.\n *\n * @example\n * ```ts\n * // Given a component with two `<ng-content>` slots, the first without a selector and the second with the selector `<ng-content select=\".selector-class\">`,\n * const nodes = [document.createTextNode('Hello'), document.createElement('div')];\n * const projectableNodes = createProjectableNodes(MyComponent, nodes);\n * // projectableNodes would be `[[TextNode, DivElement], []]` for a component with selectors ['*', '.selector-class']\n * ```\n */\nexport function createProjectableNodes(component: Type<unknown>, nodes: Node[]): Node[][] {\n  const componentType = reflectComponentType(component);\n  if (componentType && componentType.ngContentSelectors.length > 0) {\n    return componentType.ngContentSelectors.map((selector) => (selector === '*' ? nodes : []));\n  }\n  return [];\n}\n","import { isString } from '@odx/angular/utils';\nimport { isObservable } from 'rxjs';\nimport { DynamicTextContent } from '../facade';\n\n/**\n * Type guard function to check if a given value is considered dynamic text content.\n * Dynamic text content can either be a plain string or an Observable. This function\n * facilitates type-safe handling of dynamic text content by checking the type of the value.\n *\n * @param {unknown} value - The value to be checked.\n * @returns {value is DynamicTextContent} Returns `true` if the value is a string or an Observable,\n * indicating it can be used as dynamic text content; otherwise, returns `false`.\n *\n * @example\n * ```ts\n * // Example usage of the isDynamicTextContent function\n * const textValue: unknown = getTextValue(); // This function may return either string or Observable\n *\n * if (isDynamicTextContent(textValue)) {\n *   // The type of textValue is now narrowed to DynamicTextContent (string | Observable)\n *   console.log('The value can be used as dynamic text content.');\n * } else {\n *   console.log('The value is not suitable as dynamic text content.');\n * }\n * ```\n */\nexport function isDynamicTextContent(value: unknown): value is DynamicTextContent {\n  return isString(value) || isObservable(value);\n}\n","import { ApplicationRef, ComponentRef, createComponent, EnvironmentInjector, reflectComponentType, Type, ViewRef } from '@angular/core';\nimport { deepmerge } from '@odx/angular/internal';\nimport { isViewContainer } from '@odx/angular/utils';\nimport { GetDynamicViewContext } from '../facade';\nimport { DynamicViewRef } from '../facade/dynamic-view-ref';\nimport { DynamicViewOptions } from './dynamic-view-options';\n\nexport interface DynamicComponentOptions<T extends Type<unknown>> extends DynamicViewOptions<T> {\n  component: T;\n}\n\n/**\n * The DynamicComponentRef class is a powerful utility for dynamically creating and managing\n * Angular components at runtime. It encapsulates the logic for component creation, input handling,\n * and lifecycle management, making it easier to work with dynamic components in complex applications.\n *\n * A reference to a dynamically created component, providing methods to manage its lifecycle,\n * detect changes, and update its inputs based on a context.\n *\n * @template T - The type of the component being managed.\n * @template C - The type of the context used to update the component's inputs.\n */\nexport class DynamicComponentRef<T extends Type<unknown>, C extends GetDynamicViewContext<T>> implements DynamicViewRef<T> {\n  private readonly application = this.options.injector.get(ApplicationRef);\n  private componentRef: ComponentRef<T> | null = null;\n  private componentInputs: Record<string, true> | null = null;\n\n  constructor(private readonly options: DynamicComponentOptions<T>) {\n    const { component, context, injector, projectableNodes, host } = options;\n\n    this.componentRef = createComponent(component as Type<T>, {\n      environmentInjector: injector.get(EnvironmentInjector),\n      elementInjector: injector,\n      projectableNodes,\n    });\n    this.componentInputs =\n      reflectComponentType(this.componentRef.componentType)?.inputs.reduce(\n        (acc, { propName }) => {\n          acc[propName] = true;\n          return acc;\n        },\n        {} as Record<string, true>,\n      ) ?? null;\n\n    if (isViewContainer(host)) {\n      host.insert(this.componentRef.hostView);\n    } else {\n      this.application.attachView(this.componentRef.hostView);\n      if (host) {\n        host.appendChild(this.getElement());\n      }\n    }\n    if (context) {\n      this.update(context as C);\n    }\n  }\n\n  /**\n   * Triggers change detection for the dynamically created component, ensuring that any updates to inputs\n   * or internal state are reflected in the view.\n   */\n  public detectChanges(): void {\n    this.componentRef?.changeDetectorRef.detectChanges();\n  }\n\n  /**\n   * Destroys the dynamically created component, cleaning up resources and detaching it from the application view.\n   */\n  public destroy(): void {\n    if (this.componentRef?.hostView.destroyed) {\n      this.componentRef = null;\n      return;\n    }\n    if (this.componentRef && !isViewContainer(this.options.host)) {\n      this.application.detachView(this.componentRef.hostView);\n    }\n    this.componentRef?.destroy();\n    this.componentRef = null;\n    this.componentInputs = null;\n  }\n\n  /**\n   * Retrieves the native element associated with the dynamically created component's host view.\n   *\n   * @returns {Element} The native DOM element of the component.\n   */\n  public getElement(): Element {\n    return this.componentRef?.location.nativeElement ?? null;\n  }\n\n  /**\n   * Updates the component's inputs based on the provided context. Merges the new context with the existing\n   * context and applies the combined context as inputs to the component.\n   *\n   * @param {C} context - The context containing new values for the component's inputs.\n   */\n  public update(context: C): void {\n    this.options.context = deepmerge({}, this.options.context, context) as C;\n    if (!this.componentRef) return;\n    for (const key in this.options.context) {\n      if (this.componentInputs?.[key]) {\n        this.componentRef.setInput(key, this.options.context[key]);\n      }\n    }\n  }\n\n  /**\n   * Retrieves the current context used for the component's inputs.\n   *\n   * @returns {GetDynamicViewContext<T>} The current context object.\n   */\n  public getContext(): GetDynamicViewContext<T> {\n    return this.options.context ?? {};\n  }\n\n  /**\n   * Retrieves the view reference associated with the dynamically created component.\n   *\n   * @returns {ViewRef | null} The view reference, or null if the component has not been created or has been destroyed.\n   */\n  public getView(): ViewRef | null {\n    return this.componentRef?.hostView ?? null;\n  }\n}\n","import { ApplicationRef, EmbeddedViewRef, TemplateRef as NgTemplateRef, ViewRef } from '@angular/core';\nimport { deepmerge } from '@odx/angular/internal';\nimport { isViewContainer } from '@odx/angular/utils';\nimport { DynamicViewRef, GetDynamicViewContext } from '../facade';\nimport { DynamicViewOptions } from './dynamic-view-options';\n\nexport interface DynamicTemplateOptions<T extends NgTemplateRef<unknown>> extends DynamicViewOptions<T> {\n  template: T;\n}\n\n/**\n * A reference to a dynamically created template, offering methods to manage its lifecycle,\n * detect changes, and update its context. It encapsulates the logic for creating and manipulating\n * an `EmbeddedViewRef` from a given `TemplateRef`.\n *\n * @template T - The type of the `NgTemplateRef` being managed.\n */\nexport class DynamicTemplateRef<T extends NgTemplateRef<unknown> = NgTemplateRef<unknown>> implements DynamicViewRef<T> {\n  private readonly application = this.options.injector.get(ApplicationRef);\n  private embeddedViewRef: EmbeddedViewRef<unknown> | null = null;\n\n  constructor(private readonly options: DynamicTemplateOptions<T>) {\n    this.create(options);\n  }\n\n  /**\n   * Triggers change detection on the embedded view created from the template, ensuring that any updates\n   * to the context or internal state are reflected in the view.\n   */\n  public detectChanges(): void {\n    this.embeddedViewRef?.detectChanges();\n  }\n\n  /**\n   * Destroys the embedded view associated with the template, cleaning up resources and detaching it from the\n   * application view if necessary.\n   */\n  public destroy(): void {\n    if (this.embeddedViewRef?.destroyed) {\n      this.embeddedViewRef = null;\n      return;\n    }\n    if (!isViewContainer(this.options.host) && this.embeddedViewRef) {\n      this.application.detachView(this.embeddedViewRef);\n    }\n    this.embeddedViewRef?.destroy();\n    this.embeddedViewRef = null;\n  }\n\n  /**\n   * Retrieves the native element associated with the template's embedded view's root node.\n   *\n   * @returns {Element} The native DOM element of the embedded view's root node, if available.\n   */\n  public getElement(): Element {\n    return this.embeddedViewRef?.rootNodes?.[0] ?? null;\n  }\n\n  /**\n   * Updates the context of the embedded view based on the provided context object. Merges the new context\n   * with the existing one and applies the combined context to the embedded view.\n   *\n   * @param {GetDynamicViewContext<T>} context - The context containing new values for the template's view.\n   */\n  public update(context: GetDynamicViewContext<T>): void {\n    this.options.context = deepmerge({}, this.options.context, context) as GetDynamicViewContext<T>;\n    if (this.embeddedViewRef) {\n      this.embeddedViewRef.context = this.options.context;\n      this.detectChanges();\n    }\n  }\n\n  /**\n   * Retrieves the current context used for the template's view.\n   *\n   * @returns {GetDynamicViewContext<T>} The current context object.\n   */\n  public getContext(): GetDynamicViewContext<T> {\n    return this.options.context ?? {};\n  }\n\n  /**\n   * Retrieves the view reference (`ViewRef`) associated with the dynamically created template's embedded view.\n   *\n   * @returns {ViewRef | null} The view reference, or null if the template has not been instantiated or has been destroyed.\n   */\n  public getView(): ViewRef | null {\n    return this.embeddedViewRef;\n  }\n\n  private create({ context, template, host }: DynamicTemplateOptions<T>) {\n    if (isViewContainer(host)) {\n      this.embeddedViewRef = host.createEmbeddedView(template, context, { injector: this.options.injector });\n    } else {\n      this.embeddedViewRef = template.createEmbeddedView(context ?? {}, this.options.injector);\n      this.application.attachView(this.embeddedViewRef);\n    }\n  }\n}\n","import { DynamicContent, DynamicViewRef } from '../facade';\nimport { DynamicComponentRef, DynamicTemplateRef } from '../models';\n\n/**\n * Type guard function to check if a given value is a reference to a dynamically created view.\n * This helps in distinguishing between dynamic view references (`DynamicComponentRef` or `DynamicTemplateRef`)\n * and other types of values, facilitating type-safe operations on dynamic views.\n *\n * @param {unknown} value - The value to check.\n * @returns {value is DynamicViewRef<DynamicContent>} `true` if the value is an instance of `DynamicComponentRef`\n * or `DynamicTemplateRef`, indicating it is a dynamic view reference; otherwise, `false`.\n *\n * @example\n * ```ts\n * // Given a value that could be a dynamic view reference or something else\n * const value: unknown = getSomeValue();\n *\n * if (isDynamicView(value)) {\n *   // TypeScript now knows `value` is a dynamic view reference, so you can access its methods safely\n *   value.detectChanges();\n * } else {\n *   console.log('Value is not a dynamic view reference');\n * }\n * ```\n */\nexport function isDynamicView(value: unknown): value is DynamicViewRef<DynamicContent> {\n  return value instanceof DynamicComponentRef || value instanceof DynamicTemplateRef;\n}\n","import { InjectionToken, TemplateRef } from '@angular/core';\n\nexport interface DynamicViewContextWithImplicitTemplate<T = unknown> {\n  $implicit: TemplateRef<T>;\n}\n\n/**\n * @internal\n * Injection token for the dynamic view context.\n */\nexport const DYNAMIC_VIEW_CONTEXT = new InjectionToken('@odx/angular/cdk/dynamic-view::DynamicViewContext');\n","\nimport { inject, InjectionToken, DOCUMENT } from '@angular/core';\n\n/**\n * @internal\n * Injection token for the default host element for dynamic views.\n */\nexport const ODX_DYNAMIC_VIEW_DEFAULT_HOST = new InjectionToken<Element>('@odx/angular/cdk/dynamic-view::DynamicViewDefaultHost', {\n  providedIn: 'root',\n  factory: () => inject(DOCUMENT).body,\n});\n\n/**\n * @internal\n * Retrieves the default host for dynamic views.\n *\n * @returns {Element} The default host element for dynamic views.\n */\nexport function getDynamicViewDefaultHost(): Element {\n  return inject(ODX_DYNAMIC_VIEW_DEFAULT_HOST);\n}\n","import { inject, Injectable, Injector } from '@angular/core';\nimport { isComponent, isTemplateRef } from '@odx/angular/utils';\nimport { DynamicViewComponent } from './dynamic-view.component';\nimport { DynamicContent, DynamicViewRef } from './facade';\nimport { isDynamicTextContent } from './helpers';\nimport { DynamicComponentRef, DynamicViewOptions } from './models';\nimport { DynamicTemplateRef } from './models/dynamic-template-ref';\nimport { DYNAMIC_VIEW_CONTEXT, getDynamicViewDefaultHost } from './tokens';\n\n/**\n * A service for creating and managing dynamic views in an Angular application.\n * It supports rendering Angular components, templates, and text content dynamically,\n * allowing for flexible and dynamic content composition.\n */\n@Injectable({ providedIn: 'root' })\nexport class DynamicViewService {\n  private readonly injector = inject(Injector);\n  private readonly defaultHost = getDynamicViewDefaultHost();\n\n  /**\n   * Creates and returns a reference to a dynamic view based on the provided content and options.\n   * The method supports dynamic creation of components, template references, and text content,\n   * providing a unified API for dynamic content rendering.\n   *\n   * @template T - The type of the content to be dynamically rendered.\n   * @param {T} content - The content to be rendered dynamically. This can be a component class,\n   * a template reference, or text content.\n   * @param {Partial<DynamicViewOptions<T>>} [options={}] - Optional configuration for the dynamic view creation,\n   * including a custom injector, context, host element, and additional providers for the dynamic component's injector.\n   * @returns {DynamicViewRef<T>} A reference to the dynamically created view, encapsulating the rendered content\n   * and providing methods for interaction and management.\n   * @throws {Error} Throws an error if the content type is not supported.\n   * @example\n   * ```ts\n   * // Create a dynamic view for a component\n   * const componentRef = dynamicViewService.createView(MyComponent, { context: { ... } });\n   *\n   * // Create a dynamic view for a template reference\n   * const templateRef = dynamicViewService.createView(myTemplate, { context: { ... } });\n   *\n   * // Create a dynamic view for text content\n   * const textRef = dynamicViewService.createView('Dynamic text content', {});\n   * ```\n   */\n  public createView<T extends DynamicContent>(content: T, options: Partial<DynamicViewOptions<T>> = {}): DynamicViewRef<T> {\n    const viewOptions: DynamicViewOptions<T> = {\n      ...options,\n      host: options.host ?? this.defaultHost,\n      injector: Injector.create({\n        providers: [{ provide: DYNAMIC_VIEW_CONTEXT, useValue: options.context }, options.providers ?? []],\n        parent: options.injector ?? this.injector,\n      }),\n    };\n    if (isTemplateRef(content)) {\n      return new DynamicTemplateRef({ ...viewOptions, template: content });\n    }\n    if (isComponent(content)) {\n      return new DynamicComponentRef({ ...viewOptions, context: options.context, component: content });\n    }\n    if (isDynamicTextContent(content)) {\n      return new DynamicComponentRef({\n        ...viewOptions,\n        component: DynamicViewComponent,\n        context: { content },\n      }) as never;\n    }\n    throw new Error('Content type is not supported');\n  }\n}\n","import { Directive, EmbeddedViewRef, inject, Injector, Input, OnChanges, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { hasChanged, isComponent, NgChanges } from '@odx/angular/utils';\nimport { DynamicViewService } from './dynamic-view.service';\nimport { DynamicContent, DynamicViewRef, GetDynamicViewContext } from './facade';\nimport { createProjectableNodes, isDynamicTextContent, isDynamicView } from './helpers';\n\n/**\n * A directive that dynamically renders content based on the provided input. It supports rendering\n * Angular components, templates, and text content, allowing for dynamic and flexible content\n * management within Angular applications.\n *\n * @template T - A type parameter that extends `DynamicContent<unknown>`, representing the type of content to be dynamically rendered.\n */\n@Directive({\n  selector: 'ng-template[odxDynamicView]',\n  standalone: true,\n})\nexport class DynamicViewDirective<T extends DynamicContent<unknown> = DynamicContent<unknown>> implements OnDestroy, OnInit, OnChanges {\n  private readonly dynamicViewService = inject(DynamicViewService);\n  private readonly viewContainer = inject(ViewContainerRef);\n  private readonly template = inject(TemplateRef);\n  private viewRef: DynamicViewRef<T> | null = null;\n  private contentViewRef: DynamicViewRef<TemplateRef<unknown>> | null = null;\n\n  /**\n   * The content to be dynamically rendered. This can be a component, template reference, or text content.\n   * The content is wrapped in a `DynamicViewRef`, providing additional control over the dynamically rendered view.\n   *\n   * @type {T | DynamicViewRef<T> | null}\n   * @default null\n   */\n  @Input('odxDynamicView')\n  public content?: T | DynamicViewRef<T> | null = null;\n\n  /**\n   * An optional injector to be used for dynamically created components.\n   * This allows for custom dependency injection\n   * into dynamically rendered components.\n   *\n   * @type {Injector | undefined}\n   */\n  // eslint-disable-next-line @angular-eslint/no-input-rename\n  @Input('odxDynamicViewInjector')\n  public injector?: Injector;\n\n  /**\n   * An optional context providing function for dynamically created views. This function returns the context\n   * object to be passed to the dynamically rendered content, allowing for dynamic interaction with the content.\n   *\n   * @type {GetDynamicViewContext<T> | undefined}\n   */\n  // eslint-disable-next-line @angular-eslint/no-input-rename\n  @Input('odxDynamicViewContext')\n  public context?: GetDynamicViewContext<T>;\n\n  public ngOnInit(): void {\n    this.render();\n  }\n\n  public ngOnChanges(changes: NgChanges<DynamicViewDirective<DynamicContent>>): void {\n    if (hasChanged(changes, 'injector')) {\n      this.render();\n    }\n    if (hasChanged(changes, 'content')) {\n      const hasChangedTextContent = isDynamicTextContent(changes.content?.previousValue) && isDynamicTextContent(changes.content?.currentValue);\n      this.render(!hasChangedTextContent);\n    }\n    if (hasChanged(changes, 'context')) {\n      this.viewRef?.update(changes.context?.currentValue ?? {});\n    }\n  }\n\n  public ngOnDestroy(): void {\n    this.destroy();\n  }\n\n  /**\n   * Retrieves the current `DynamicViewRef` associated with the rendered content, providing access\n   * to the view reference for additional operations like updating context or manual destruction.\n   *\n   * @returns {DynamicViewRef<T> | null} The current view reference for the dynamically rendered content, if available.\n   */\n  public getView(): DynamicViewRef<T> | null {\n    return this.viewRef;\n  }\n\n  private render(reRender = true) {\n    if (!this.content) {\n      this.destroy();\n      return;\n    }\n    if (!reRender && this.viewRef) {\n      this.viewRef?.update({ content: this.content } as object);\n      return;\n    }\n    this.viewRef?.destroy();\n    if (isDynamicView(this.content)) {\n      this.viewRef = this.content;\n      const hostView = this.viewRef.getView();\n      if (hostView) {\n        this.viewContainer.insert(hostView);\n      }\n    } else {\n      let projectableNodes: Node[][] = [];\n      if (isComponent(this.content)) {\n        this.contentViewRef = this.dynamicViewService.createView(this.template, { injector: this.injector });\n        const rootNodes = (this.contentViewRef.getView() as EmbeddedViewRef<unknown>).rootNodes;\n        projectableNodes = createProjectableNodes(this.content, rootNodes);\n      }\n      this.viewRef = this.dynamicViewService.createView(this.content, {\n        context: this.context ?? undefined,\n        injector: this.injector ?? this.viewContainer.injector,\n        projectableNodes,\n        host: this.viewContainer,\n      });\n    }\n  }\n\n  private destroy() {\n    this.contentViewRef?.destroy();\n    this.viewRef?.destroy();\n    this.contentViewRef = null;\n    this.viewRef = null;\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAaa,oBAAoB,CAAA;AAPjC,IAAA,WAAA,GAAA;QAQmB,IAAA,CAAA,OAAO,GAAG,aAAa,EAAE;AACzB,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAA,CAAA,mBAAmB,GAAwB,IAAI;AAsBxD,IAAA;IApBC,IACW,OAAO,CAAC,KAAyB,EAAA;AAC1C,QAAA,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE;YACvB,IAAI,CAAC,WAAW,EAAE;AAClB,YAAA,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,KAAI;AACrF,gBAAA,IAAI,CAAC,UAA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