@angular/elements
Version:
Angular - library for using Angular Components as Custom Elements
1 lines • 36.1 kB
Source Map (JSON)
{"version":3,"file":"elements.mjs","sources":["../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/elements/src/utils.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/elements/src/extract-projectable-nodes.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/elements/src/component-factory-strategy.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/elements/src/create-custom-element.ts","../../../../../k8-fastbuild-ST-fdfa778d11ba/bin/packages/elements/src/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {ComponentFactoryResolver, Injector, Type} from '@angular/core';\n\n/**\n * Provide methods for scheduling the execution of a callback.\n */\nexport const scheduler = {\n /**\n * Schedule a callback to be called after some delay.\n *\n * Returns a function that when executed will cancel the scheduled function.\n */\n schedule(taskFn: () => void, delay: number): () => void {\n const id = setTimeout(taskFn, delay);\n return () => clearTimeout(id);\n },\n};\n\n/**\n * Convert a camelCased string to kebab-cased.\n */\nexport function camelToDashCase(input: string): string {\n return input.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\n/**\n * Check whether the input is an `Element`.\n */\nexport function isElement(node: Node | null): node is Element {\n return !!node && node.nodeType === Node.ELEMENT_NODE;\n}\n\n/**\n * Check whether the input is a function.\n */\nexport function isFunction(value: any): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Convert a kebab-cased string to camelCased.\n */\nexport function kebabToCamelCase(input: string): string {\n return input.replace(/-([a-z\\d])/g, (_, char) => char.toUpperCase());\n}\n\nlet _matches: (this: any, selector: string) => boolean;\n\n/**\n * Check whether an `Element` matches a CSS selector.\n * NOTE: this is duplicated from @angular/upgrade, and can\n * be consolidated in the future\n */\nexport function matchesSelector(el: any, selector: string): boolean {\n if (!_matches) {\n const elProto = <any>Element.prototype;\n _matches =\n elProto.matches ||\n elProto.matchesSelector ||\n elProto.mozMatchesSelector ||\n elProto.msMatchesSelector ||\n elProto.oMatchesSelector ||\n elProto.webkitMatchesSelector;\n }\n return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;\n}\n\n/**\n * Test two values for strict equality, accounting for the fact that `NaN !== NaN`.\n */\nexport function strictEquals(value1: any, value2: any): boolean {\n return value1 === value2 || (value1 !== value1 && value2 !== value2);\n}\n\n/** Gets a map of default set of attributes to observe and the properties they affect. */\nexport function getDefaultAttributeToPropertyInputs(\n inputs: {propName: string; templateName: string; transform?: (value: any) => any}[],\n) {\n const attributeToPropertyInputs: {\n [key: string]: [propName: string, transform: ((value: any) => any) | undefined];\n } = {};\n inputs.forEach(({propName, templateName, transform}) => {\n attributeToPropertyInputs[camelToDashCase(templateName)] = [propName, transform];\n });\n\n return attributeToPropertyInputs;\n}\n\n/**\n * Gets a component's set of inputs. Uses the injector to get the component factory where the inputs\n * are defined.\n */\nexport function getComponentInputs(\n component: Type<any>,\n injector: Injector,\n): {\n propName: string;\n templateName: string;\n transform?: (value: any) => any;\n isSignal: boolean;\n}[] {\n const componentFactoryResolver = injector.get(ComponentFactoryResolver);\n const componentFactory = componentFactoryResolver.resolveComponentFactory(component);\n return componentFactory.inputs;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// NOTE: This is a (slightly improved) version of what is used in ngUpgrade's\n// `DowngradeComponentAdapter`.\n// TODO(gkalpak): Investigate if it makes sense to share the code.\n\nimport {isElement, matchesSelector} from './utils';\n\nexport function extractProjectableNodes(host: HTMLElement, ngContentSelectors: string[]): Node[][] {\n const nodes = host.childNodes;\n const projectableNodes: Node[][] = ngContentSelectors.map(() => []);\n let wildcardIndex = -1;\n\n ngContentSelectors.some((selector, i) => {\n if (selector === '*') {\n wildcardIndex = i;\n return true;\n }\n return false;\n });\n\n for (let i = 0, ii = nodes.length; i < ii; ++i) {\n const node = nodes[i];\n const ngContentIndex = findMatchingIndex(node, ngContentSelectors, wildcardIndex);\n\n if (ngContentIndex !== -1) {\n projectableNodes[ngContentIndex].push(node);\n }\n }\n\n return projectableNodes;\n}\n\nfunction findMatchingIndex(node: Node, selectors: string[], defaultIndex: number): number {\n let matchingIndex = defaultIndex;\n\n if (isElement(node)) {\n selectors.some((selector, i) => {\n if (selector !== '*' && matchesSelector(node, selector)) {\n matchingIndex = i;\n return true;\n }\n return false;\n });\n }\n\n return matchingIndex;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// Needed for the global `Zone` ambient types to be available.\nimport type {} from 'zone.js';\n\nimport {\n ApplicationRef,\n ComponentFactory,\n ComponentFactoryResolver,\n ComponentRef,\n EventEmitter,\n Injector,\n NgZone,\n Type,\n ɵChangeDetectionScheduler as ChangeDetectionScheduler,\n ɵNotificationSource as NotificationSource,\n ɵViewRef as ViewRef,\n ɵisViewDirty as isViewDirty,\n ɵmarkForRefresh as markForRefresh,\n OutputRef,\n} from '@angular/core';\nimport {merge, Observable, ReplaySubject} from 'rxjs';\nimport {switchMap} from 'rxjs/operators';\n\nimport {\n NgElementStrategy,\n NgElementStrategyEvent,\n NgElementStrategyFactory,\n} from './element-strategy';\nimport {extractProjectableNodes} from './extract-projectable-nodes';\nimport {scheduler} from './utils';\n\n/** Time in milliseconds to wait before destroying the component ref when disconnected. */\nconst DESTROY_DELAY = 10;\n\n/**\n * Factory that creates new ComponentNgElementStrategy instance. Gets the component factory with the\n * constructor's injector's factory resolver and passes that factory to each strategy.\n */\nexport class ComponentNgElementStrategyFactory implements NgElementStrategyFactory {\n componentFactory: ComponentFactory<any>;\n\n inputMap = new Map<string, string>();\n\n constructor(component: Type<any>, injector: Injector) {\n this.componentFactory = injector\n .get(ComponentFactoryResolver)\n .resolveComponentFactory(component);\n for (const input of this.componentFactory.inputs) {\n this.inputMap.set(input.propName, input.templateName);\n }\n }\n\n create(injector: Injector) {\n return new ComponentNgElementStrategy(this.componentFactory, injector, this.inputMap);\n }\n}\n\n/**\n * Creates and destroys a component ref using a component factory and handles change detection\n * in response to input changes.\n */\nexport class ComponentNgElementStrategy implements NgElementStrategy {\n // Subject of `NgElementStrategyEvent` observables corresponding to the component's outputs.\n private eventEmitters = new ReplaySubject<Observable<NgElementStrategyEvent>[]>(1);\n\n /** Merged stream of the component's output events. */\n readonly events = this.eventEmitters.pipe(switchMap((emitters) => merge(...emitters)));\n\n /** Reference to the component that was created on connect. */\n private componentRef: ComponentRef<any> | null = null;\n\n /** Callback function that when called will cancel a scheduled destruction on the component. */\n private scheduledDestroyFn: (() => void) | null = null;\n\n /** Initial input values that were set before the component was created. */\n private readonly initialInputValues = new Map<string, any>();\n\n /** Service for setting zone context. */\n private readonly ngZone: NgZone;\n\n /** The zone the element was created in or `null` if Zone.js is not loaded. */\n private readonly elementZone: Zone | null;\n\n /**\n * The `ApplicationRef` shared by all instances of this custom element (and potentially others).\n */\n private readonly appRef: ApplicationRef;\n\n /**\n * Angular's change detection scheduler, which works independently of zone.js.\n */\n private cdScheduler: ChangeDetectionScheduler;\n\n constructor(\n private componentFactory: ComponentFactory<any>,\n private injector: Injector,\n private inputMap: Map<string, string>,\n ) {\n this.ngZone = this.injector.get(NgZone);\n this.appRef = this.injector.get(ApplicationRef);\n this.cdScheduler = injector.get(ChangeDetectionScheduler);\n this.elementZone = typeof Zone === 'undefined' ? null : this.ngZone.run(() => Zone.current);\n }\n\n /**\n * Initializes a new component if one has not yet been created and cancels any scheduled\n * destruction.\n */\n connect(element: HTMLElement) {\n this.runInZone(() => {\n // If the element is marked to be destroyed, cancel the task since the component was\n // reconnected\n if (this.scheduledDestroyFn !== null) {\n this.scheduledDestroyFn();\n this.scheduledDestroyFn = null;\n return;\n }\n\n if (this.componentRef === null) {\n this.initializeComponent(element);\n }\n });\n }\n\n /**\n * Schedules the component to be destroyed after some small delay in case the element is just\n * being moved across the DOM.\n */\n disconnect() {\n this.runInZone(() => {\n // Return if there is no componentRef or the component is already scheduled for destruction\n if (this.componentRef === null || this.scheduledDestroyFn !== null) {\n return;\n }\n\n // Schedule the component to be destroyed after a small timeout in case it is being\n // moved elsewhere in the DOM\n this.scheduledDestroyFn = scheduler.schedule(() => {\n if (this.componentRef !== null) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n }, DESTROY_DELAY);\n });\n }\n\n /**\n * Returns the component property value. If the component has not yet been created, the value is\n * retrieved from the cached initialization values.\n */\n getInputValue(property: string): any {\n return this.runInZone(() => {\n if (this.componentRef === null) {\n return this.initialInputValues.get(property);\n }\n\n return this.componentRef.instance[property];\n });\n }\n\n /**\n * Sets the input value for the property. If the component has not yet been created, the value is\n * cached and set when the component is created.\n */\n setInputValue(property: string, value: any): void {\n if (this.componentRef === null) {\n this.initialInputValues.set(property, value);\n return;\n }\n\n this.runInZone(() => {\n this.componentRef!.setInput(this.inputMap.get(property) ?? property, value);\n\n // `setInput` won't mark the view dirty if the input didn't change from its previous value.\n if (isViewDirty(this.componentRef!.hostView as ViewRef<unknown>)) {\n // `setInput` will have marked the view dirty already, but also mark it for refresh. This\n // guarantees the view will be checked even if the input is being set from within change\n // detection. This provides backwards compatibility, since we used to unconditionally\n // schedule change detection in addition to the current zone run.\n markForRefresh(this.componentRef!.changeDetectorRef as ViewRef<unknown>);\n\n // Notifying the scheduler with `NotificationSource.CustomElement` causes a `tick()` to be\n // scheduled unconditionally, even if the scheduler is otherwise disabled.\n this.cdScheduler.notify(NotificationSource.CustomElement);\n }\n });\n }\n\n /**\n * Creates a new component through the component factory with the provided element host and\n * sets up its initial inputs, listens for outputs changes, and runs an initial change detection.\n */\n protected initializeComponent(element: HTMLElement) {\n const childInjector = Injector.create({providers: [], parent: this.injector});\n const projectableNodes = extractProjectableNodes(\n element,\n this.componentFactory.ngContentSelectors,\n );\n this.componentRef = this.componentFactory.create(childInjector, projectableNodes, element);\n\n this.initializeInputs();\n this.initializeOutputs(this.componentRef);\n\n this.appRef.attachView(this.componentRef.hostView);\n this.componentRef.hostView.detectChanges();\n }\n\n /** Set any stored initial inputs on the component's properties. */\n protected initializeInputs(): void {\n for (const [propName, value] of this.initialInputValues) {\n this.setInputValue(propName, value);\n }\n\n this.initialInputValues.clear();\n }\n\n /** Sets up listeners for the component's outputs so that the events stream emits the events. */\n protected initializeOutputs(componentRef: ComponentRef<any>): void {\n const eventEmitters: Observable<NgElementStrategyEvent>[] = this.componentFactory.outputs.map(\n ({propName, templateName}) => {\n const emitter: EventEmitter<any> | OutputRef<any> = componentRef.instance[propName];\n return new Observable((observer) => {\n const sub = emitter.subscribe((value) => observer.next({name: templateName, value}));\n return () => sub.unsubscribe();\n });\n },\n );\n\n this.eventEmitters.next(eventEmitters);\n }\n\n /** Runs in the angular zone, if present. */\n private runInZone(fn: () => unknown) {\n return this.elementZone && Zone.current !== this.elementZone ? this.ngZone.run(fn) : fn();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injector, Type, isSignal} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {ComponentNgElementStrategyFactory} from './component-factory-strategy';\nimport {NgElementStrategy, NgElementStrategyFactory} from './element-strategy';\nimport {getComponentInputs, getDefaultAttributeToPropertyInputs} from './utils';\n\n/**\n * Prototype for a class constructor based on an Angular component\n * that can be used for custom element registration. Implemented and returned\n * by the {@link createCustomElement createCustomElement() function}.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @publicApi\n */\nexport interface NgElementConstructor<P> {\n /**\n * An array of observed attribute names for the custom element,\n * derived by transforming input property names from the source component.\n */\n readonly observedAttributes: string[];\n\n /**\n * Initializes a constructor instance.\n * @param injector If provided, overrides the configured injector.\n */\n new (injector?: Injector): NgElement & WithProperties<P>;\n}\n\n/**\n * Implements the functionality needed for a custom element.\n *\n * @publicApi\n */\nexport abstract class NgElement extends HTMLElement {\n /**\n * The strategy that controls how a component is transformed in a custom element.\n */\n protected abstract ngElementStrategy: NgElementStrategy;\n /**\n * A subscription to change, connect, and disconnect events in the custom element.\n */\n protected ngElementEventsSubscription: Subscription | null = null;\n\n /**\n * Prototype for a handler that responds to a change in an observed attribute.\n * @param attrName The name of the attribute that has changed.\n * @param oldValue The previous value of the attribute.\n * @param newValue The new value of the attribute.\n * @param namespace The namespace in which the attribute is defined.\n * @returns Nothing.\n */\n abstract attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void;\n /**\n * Prototype for a handler that responds to the insertion of the custom element in the DOM.\n * @returns Nothing.\n */\n abstract connectedCallback(): void;\n /**\n * Prototype for a handler that responds to the deletion of the custom element from the DOM.\n * @returns Nothing.\n */\n abstract disconnectedCallback(): void;\n}\n\n/**\n * Additional type information that can be added to the NgElement class,\n * for properties that are added based\n * on the inputs and methods of the underlying component.\n *\n * @publicApi\n */\nexport type WithProperties<P> = {\n [property in keyof P]: P[property];\n};\n\n/**\n * A configuration that initializes an NgElementConstructor with the\n * dependencies and strategy it needs to transform a component into\n * a custom element class.\n *\n * @publicApi\n */\nexport interface NgElementConfig {\n /**\n * The injector to use for retrieving the component's factory.\n */\n injector: Injector;\n /**\n * An optional custom strategy factory to use instead of the default.\n * The strategy controls how the transformation is performed.\n */\n strategyFactory?: NgElementStrategyFactory;\n}\n\n/**\n * @description Creates a custom element class based on an Angular component.\n *\n * Builds a class that encapsulates the functionality of the provided component and\n * uses the configuration information to provide more context to the class.\n * Takes the component factory's inputs and outputs to convert them to the proper\n * custom element API and add hooks to input changes.\n *\n * The configuration's injector is the initial injector set on the class,\n * and used by default for each created instance.This behavior can be overridden with the\n * static property to affect all newly created instances, or as a constructor argument for\n * one-off creations.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @param component The component to transform.\n * @param config A configuration that provides initialization information to the created class.\n * @returns The custom-element construction class, which can be registered with\n * a browser's `CustomElementRegistry`.\n *\n * @publicApi\n */\nexport function createCustomElement<P>(\n component: Type<any>,\n config: NgElementConfig,\n): NgElementConstructor<P> {\n const inputs = getComponentInputs(component, config.injector);\n\n const strategyFactory =\n config.strategyFactory || new ComponentNgElementStrategyFactory(component, config.injector);\n\n const attributeToPropertyInputs = getDefaultAttributeToPropertyInputs(inputs);\n\n class NgElementImpl extends NgElement {\n // Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static\n // field externs. So using quoted access to explicitly prevent renaming.\n static readonly ['observedAttributes'] = Object.keys(attributeToPropertyInputs);\n\n protected override get ngElementStrategy(): NgElementStrategy {\n // TODO(andrewseguin): Add e2e tests that cover cases where the constructor isn't called. For\n // now this is tested using a Google internal test suite.\n if (!this._ngElementStrategy) {\n const strategy = (this._ngElementStrategy = strategyFactory.create(\n this.injector || config.injector,\n ));\n\n // Re-apply pre-existing input values (set as properties on the element) through the\n // strategy.\n // TODO(alxhub): why are we doing this? this makes no sense.\n inputs.forEach(({propName, transform}) => {\n if (!this.hasOwnProperty(propName)) {\n // No pre-existing value for `propName`.\n return;\n }\n\n // Delete the property from the DOM node and re-apply it through the strategy.\n const value = (this as any)[propName];\n delete (this as any)[propName];\n strategy.setInputValue(propName, value, transform);\n });\n }\n\n return this._ngElementStrategy!;\n }\n\n private _ngElementStrategy?: NgElementStrategy;\n\n constructor(private readonly injector?: Injector) {\n super();\n }\n\n override attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void {\n const [propName, transform] = attributeToPropertyInputs[attrName]!;\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n }\n\n override connectedCallback(): void {\n // For historical reasons, some strategies may not have initialized the `events` property\n // until after `connect()` is run. Subscribe to `events` if it is available before running\n // `connect()` (in order to capture events emitted during initialization), otherwise subscribe\n // afterwards.\n //\n // TODO: Consider deprecating/removing the post-connect subscription in a future major version\n // (e.g. v11).\n\n let subscribedToEvents = false;\n\n if (this.ngElementStrategy.events) {\n // `events` are already available: Subscribe to it asap.\n this.subscribeToEvents();\n subscribedToEvents = true;\n }\n\n this.ngElementStrategy.connect(this);\n\n if (!subscribedToEvents) {\n // `events` were not initialized before running `connect()`: Subscribe to them now.\n // The events emitted during the component initialization have been missed, but at least\n // future events will be captured.\n this.subscribeToEvents();\n }\n }\n\n override disconnectedCallback(): void {\n // Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`.\n if (this._ngElementStrategy) {\n this._ngElementStrategy.disconnect();\n }\n\n if (this.ngElementEventsSubscription) {\n this.ngElementEventsSubscription.unsubscribe();\n this.ngElementEventsSubscription = null;\n }\n }\n\n private subscribeToEvents(): void {\n // Listen for events from the strategy and dispatch them as custom events.\n this.ngElementEventsSubscription = this.ngElementStrategy.events.subscribe((e) => {\n const customEvent = new CustomEvent(e.name, {detail: e.value});\n this.dispatchEvent(customEvent);\n });\n }\n }\n\n // Add getters and setters to the prototype for each property input.\n inputs.forEach(({propName, transform, isSignal: _isSignal}) => {\n Object.defineProperty(NgElementImpl.prototype, propName, {\n get(): any {\n const inputValue = this.ngElementStrategy.getInputValue(propName);\n return _isSignal && isSignal(inputValue) ? inputValue() : inputValue;\n },\n set(newValue: any): void {\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n },\n configurable: true,\n enumerable: true,\n });\n });\n\n return NgElementImpl as any as NgElementConstructor<P>;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Version} from '@angular/core';\n\n/**\n * @publicApi\n */\nexport const VERSION = /* @__PURE__ */ new Version('21.0.6');\n"],"names":["scheduler","schedule","taskFn","delay","id","setTimeout","clearTimeout","camelToDashCase","input","replace","char","toLowerCase","isElement","node","nodeType","Node","ELEMENT_NODE","_matches","matchesSelector","el","selector","elProto","Element","prototype","matches","mozMatchesSelector","msMatchesSelector","oMatchesSelector","webkitMatchesSelector","call","getDefaultAttributeToPropertyInputs","inputs","attributeToPropertyInputs","forEach","propName","templateName","transform","getComponentInputs","component","injector","componentFactoryResolver","get","ComponentFactoryResolver","componentFactory","resolveComponentFactory","extractProjectableNodes","host","ngContentSelectors","nodes","childNodes","projectableNodes","map","wildcardIndex","some","i","ii","length","ngContentIndex","findMatchingIndex","push","selectors","defaultIndex","matchingIndex","DESTROY_DELAY","ComponentNgElementStrategyFactory","inputMap","Map","constructor","set","create","ComponentNgElementStrategy","eventEmitters","ReplaySubject","events","pipe","switchMap","emitters","merge","componentRef","scheduledDestroyFn","initialInputValues","ngZone","elementZone","appRef","cdScheduler","NgZone","ApplicationRef","ChangeDetectionScheduler","Zone","run","current","connect","element","runInZone","initializeComponent","disconnect","destroy","getInputValue","property","instance","setInputValue","value","setInput","isViewDirty","hostView","markForRefresh","changeDetectorRef","notify","childInjector","Injector","providers","parent","initializeInputs","initializeOutputs","attachView","detectChanges","clear","outputs","emitter","Observable","observer","sub","subscribe","next","name","unsubscribe","fn","NgElement","HTMLElement","ngElementEventsSubscription","createCustomElement","config","strategyFactory","NgElementImpl","Object","keys","ngElementStrategy","_ngElementStrategy","strategy","hasOwnProperty","attributeChangedCallback","attrName","oldValue","newValue","namespace","connectedCallback","subscribedToEvents","subscribeToEvents","disconnectedCallback","e","customEvent","CustomEvent","detail","dispatchEvent","isSignal","_isSignal","defineProperty","inputValue","configurable","enumerable","VERSION","Version"],"mappings":";;;;;;;;;;AAYO,MAAMA,SAAS,GAAG;AAMvBC,EAAAA,QAAQA,CAACC,MAAkB,EAAEC,KAAa,EAAA;AACxC,IAAA,MAAMC,EAAE,GAAGC,UAAU,CAACH,MAAM,EAAEC,KAAK,CAAC;AACpC,IAAA,OAAO,MAAMG,YAAY,CAACF,EAAE,CAAC;AAC/B;CACD;AAKK,SAAUG,eAAeA,CAACC,KAAa,EAAA;AAC3C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