{"version":3,"file":"ng-primitives-state.mjs","sources":["../../../../packages/ng-primitives/state/src/index.ts","../../../../packages/ng-primitives/state/src/ng-primitives-state.ts"],"sourcesContent":["/* eslint-disable @angular-eslint/no-uncalled-signals */\nimport { coerceElement } from '@angular/cdk/coercion';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n  afterRenderEffect,\n  ChangeDetectorRef,\n  computed,\n  DestroyRef,\n  effect,\n  ElementRef,\n  FactoryProvider,\n  forwardRef,\n  inject,\n  InjectionToken,\n  InjectOptions,\n  Injector,\n  InputSignal,\n  InputSignalWithTransform,\n  isSignal,\n  linkedSignal,\n  NgZone,\n  PLATFORM_ID,\n  ProviderToken,\n  runInInjectionContext,\n  signal,\n  Signal,\n  untracked,\n  WritableSignal,\n} from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\n/**\n * This converts the state object to a writable state object.\n * This means that inputs become signals which are writable.\n */\nexport type State<T> = {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n    ? WritableSignal<U>\n    : T[K] extends InputSignal<infer R>\n      ? WritableSignal<R>\n      : T[K];\n};\n\n/**\n * This is similar to the state object, but we don't expose properties that are not\n * inputs.\n */\nexport type CreatedState<T> = {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n    ? WritableSignal<U>\n    : T[K] extends InputSignal<infer R>\n      ? WritableSignal<R>\n      : never;\n};\n\nexport type InjectedState<T> = Signal<State<T>>;\n\n/**\n * Create a new injection token for the state.\n * @param description The description of the token\n */\nexport function createStateToken<T>(description: string): InjectionToken<T> {\n  return new InjectionToken<Signal<State<T>>>(`Ngp${description}StateToken`);\n}\n\nexport interface CreateStateProviderOptions {\n  /**\n   * Whether we should check for the state in the parent injector.\n   */\n  inherit?: boolean;\n}\n\nexport type StateInjectionOptions =\n  | {\n      hoisted?: boolean;\n      optional?: boolean;\n      skipSelf?: boolean;\n    }\n  | undefined;\n\n/**\n * Create a new provider for the state. It first tries to inject the state from the parent injector,\n * as this allows for the state to be hoisted to a higher level in the component tree. This can\n * be useful to avoid issues where the injector can't be shared in some cases when ng-content is used.\n * @param token The token for the state\n */\nexport function createStateProvider<T>(\n  token: ProviderToken<T>,\n): (options?: CreateStateProviderOptions) => FactoryProvider {\n  return ({ inherit }: CreateStateProviderOptions = {}) => ({\n    provide: token,\n    useFactory: () => {\n      if (inherit === false) {\n        // if we are not checking the parent, we want to create a new state\n        return signal({});\n      }\n      // if we are checking the parent, we want to check if the state is already defined\n      return inject(token, { optional: true, skipSelf: true }) ?? signal({});\n    },\n  });\n}\n\ntype CreateStateInjectorOptions = {\n  /**\n   * Whether the state may not be immediately available. This can happen when the child is instantiated before the parent.\n   */\n  deferred?: boolean;\n};\n\n/**\n * Create a new state injector for the state.\n * @param token The token for the state\n */\nexport function createStateInjector<T>(\n  token: ProviderToken<State<T>>,\n  options: { deferred: true },\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined>;\nexport function createStateInjector<T>(\n  token: ProviderToken<State<T>>,\n  options?: CreateStateInjectorOptions,\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U>>;\nexport function createStateInjector<T>(\n  token: ProviderToken<State<T>>,\n  options: CreateStateInjectorOptions = {},\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined> {\n  return <U = T>(injectOptions: InjectOptions = {}) => {\n    const value = inject(token, injectOptions) as Signal<State<U> | undefined> | null;\n\n    if (options.deferred) {\n      return computed(() =>\n        value && Object.keys(value() ?? {}).length === 0 ? undefined : value?.(),\n      ) as Signal<State<U> | undefined>;\n    }\n\n    return (value as Signal<State<U>>) ?? signal(undefined);\n  };\n}\n\n/**\n * Convert the original state object into a writable state object.\n * @param token The token for the state\n */\nexport function createState(token: ProviderToken<WritableSignal<State<unknown>>>) {\n  return <U>(state: U): CreatedState<U> => {\n    const internalState = inject(token);\n\n    internalState.update(obj => {\n      // Iterating over properties\n      for (const key in state) {\n        const value = state[key as keyof U];\n\n        // We want to make this a controlled input if it is an InputSignal or InputSignalWithTransform\n        if (isSignalInput(value)) {\n          // @ts-ignore\n          obj[key] = createControlledInput(value);\n        } else {\n          // @ts-ignore\n          obj[key] = value;\n        }\n      }\n\n      // Iterating over prototype methods\n      const prototype = Object.getPrototypeOf(state);\n\n      for (const key of Object.getOwnPropertyNames(prototype)) {\n        const descriptor = Object.getOwnPropertyDescriptor(prototype, key);\n\n        // if this is a getter or setter, we need to define it on the object\n        if (descriptor?.get || descriptor?.set) {\n          Object.defineProperty(obj, key, descriptor);\n        } else if (typeof prototype[key as keyof U] === 'function') {\n          (obj as Record<string, unknown>)[key] = prototype[key as keyof U].bind(state);\n        } else {\n          // @ts-ignore\n          obj[key] = prototype[key as keyof U];\n        }\n      }\n\n      return { ...obj };\n    });\n\n    return internalState() as unknown as CreatedState<U>;\n  };\n}\n\n// this is a bit hacky, but we need to do it to track whether this is controlled\nfunction createControlledInput(\n  property: InputSignal<unknown> | InputSignalWithTransform<unknown, unknown>,\n): WritableSignal<unknown> {\n  const value = signal(property());\n  let isControlled = false;\n\n  const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n  if (\n    !symbol ||\n    !inputDefinition ||\n    typeof inputDefinition.applyValueToInputSignal !== 'function'\n  ) {\n    console.warn(\n      'Angular has changed its internal Input implementation, report this issue to ng-primitives.',\n    );\n    // fallback to a linked signal which is partially controlled\n    return linkedSignal(() => property());\n  }\n\n  const originalApply = inputDefinition.applyValueToInputSignal.bind(inputDefinition);\n  const originalSet = value.set.bind(value);\n  const originalUpdate = value.update.bind(value);\n\n  inputDefinition.applyValueToInputSignal = (inputSignalNode: unknown, newValue: unknown) => {\n    isControlled = true;\n    originalSet(newValue);\n    originalApply(inputSignalNode, newValue);\n  };\n\n  value.set = (newValue: unknown) => {\n    if (!isControlled) {\n      originalSet(newValue);\n    }\n  };\n\n  value.update = (updateFn: (value: unknown) => unknown) => {\n    if (!isControlled) {\n      originalUpdate(updateFn);\n    }\n  };\n\n  return value;\n}\n\nfunction isSignalInput(\n  property: unknown,\n): property is InputSignal<unknown> | InputSignalWithTransform<unknown, unknown> {\n  if (!isSignal(property)) {\n    return false;\n  }\n\n  const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n\n  if (!symbol) {\n    return false;\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n  if (!inputDefinition) {\n    return false;\n  }\n\n  return 'transformFn' in inputDefinition || 'applyValueToInputSignal' in inputDefinition;\n}\n\nexport interface CreatePrimitiveOptions {\n  injector?: Injector;\n  elementRef?: ElementRef<HTMLElement>;\n}\n\ntype PrimitiveState<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n  props: unknown,\n) => infer R\n  ? R\n  : TFactory extends (...args: any[]) => infer R\n    ? R\n    : never;\n\ntype BasePrimitiveInjectionFn<TState> = {\n  (): Signal<TState>;\n  (options: StateInjectionOptions): Signal<TState | null>;\n  (options?: StateInjectionOptions): Signal<TState | null> | Signal<TState>;\n};\n\ntype PrimitiveInjectionFn<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n  props: unknown,\n) => infer R\n  ? {\n      (): Signal<R>;\n      (options: StateInjectionOptions): Signal<R | null>;\n      (options?: StateInjectionOptions): Signal<R | null> | Signal<R>;\n    }\n  : BasePrimitiveInjectionFn<PrimitiveState<TFactory>>;\n\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n  name: string,\n  fn: TFactory,\n  options?: CreatePrimitiveOptions,\n): [\n  InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n  TFactory,\n  PrimitiveInjectionFn<TFactory>,\n  (opts?: { inherit?: boolean }) => FactoryProvider,\n];\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n  name: string,\n  fn: TFactory,\n  options: CreatePrimitiveOptions = {},\n): [\n  InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n  TFactory,\n  PrimitiveInjectionFn<TFactory>,\n  (opts?: { inherit?: boolean }) => FactoryProvider,\n] {\n  // Create a unique injection token for the primitive's state signal\n  const token = new InjectionToken<WritableSignal<PrimitiveState<TFactory>>>(`Primitive: ${name}`);\n\n  // Create the state signal within the appropriate injection context\n  const factory = ((props: Parameters<TFactory>[0]) => {\n    // determine the injector to use\n    let injector = options.injector ?? inject(Injector);\n\n    // If an ElementRef is provided in options, create a child injector\n    if (options.elementRef) {\n      injector = Injector.create({\n        providers: [{ provide: ElementRef, useValue: options.elementRef }],\n        parent: injector,\n      });\n    }\n\n    return runInInjectionContext(injector, () => {\n      const state = inject(token, { optional: true });\n      const instance = fn(props);\n      state?.set(instance as PrimitiveState<TFactory>);\n      return instance;\n    });\n  }) as TFactory;\n\n  // create an injection function that provides the state signal\n  function injectFn<T = PrimitiveState<TFactory>>(): Signal<T>;\n  function injectFn<T = PrimitiveState<TFactory>>(\n    options: { hoisted: true } & InjectOptions,\n  ): Signal<T | null>;\n  function injectFn<T = PrimitiveState<TFactory>>(\n    options?: StateInjectionOptions,\n  ): Signal<T | null> | Signal<T> {\n    const hoisted = options?.hoisted ?? false;\n    const optional = options?.optional ?? false;\n    const skipSelf = options?.skipSelf ?? false;\n\n    if (hoisted || optional) {\n      return (inject(token, { optional: true, skipSelf }) ??\n        signal(null)) as unknown as Signal<T | null>;\n    }\n\n    return inject(token, { optional, skipSelf }) as unknown as Signal<T>;\n  }\n\n  // create a function to provide the state\n  const provideFn = (opts?: { inherit?: boolean }): FactoryProvider => {\n    const inherit = opts?.inherit ?? true;\n    return {\n      provide: token,\n      useFactory: () => {\n        if (inherit === false) {\n          return signal(null);\n        }\n\n        return inject(token, { optional: true, skipSelf: true }) ?? signal(null);\n      },\n    };\n  };\n\n  return [token, factory as TFactory, injectFn as PrimitiveInjectionFn<TFactory>, provideFn];\n}\n\n/**\n * Wraps an external signal in a `linkedSignal` so it can be written to internally\n * while still re-syncing whenever the source input changes.\n *\n * Only use this when the primitive needs to mutate the value internally (e.g. a\n * setter, toggle, or other internal update) but must also remain in sync with the\n * input. If the value is read-only — passed straight through to bindings or exposed\n * to consumers without internal mutation — use the input signal directly instead.\n *\n * When `value` is `undefined`, falls back to a plain writable signal seeded with\n * `defaultValue`, supporting uncontrolled usage.\n *\n * @param value - The external signal to synchronize with\n * @param defaultValue - The default value to use when `value` is `undefined`\n * @returns A writable signal linked to the external signal\n */\nexport function controlled<T>(value: Signal<T>): WritableSignal<T>;\nexport function controlled<T>(value: Signal<T> | undefined, defaultValue: T): WritableSignal<T>;\nexport function controlled<T>(value: Signal<T> | undefined, defaultValue?: T): WritableSignal<T> {\n  return value ? linkedSignal(() => value()) : signal(defaultValue as T);\n}\n\nexport interface ControlledStateOptions<T> {\n  /**\n   * The controlled value signal. When defined (not `undefined`), the component\n   * is in controlled mode and this value always wins.\n   */\n  readonly value: Signal<T | undefined>;\n  /**\n   * The default value signal for uncontrolled mode.\n   */\n  readonly defaultValue?: Signal<T>;\n  /**\n   * Callback fired when the value changes.\n   */\n  readonly onChange?: (value: T) => void;\n}\n\nexport interface SetterOptions {\n  /**\n   * Whether to fire `onChange` and emit on the `change` observable.\n   * Defaults to `true`. Set to `false` for cases like form `writeValue`\n   * where the internal state should sync without notifying listeners.\n   */\n  readonly emit?: boolean;\n}\n\nexport type ControlledState<T> = [\n  value: Signal<T>,\n  set: (value: T, options?: SetterOptions) => void,\n  change: Observable<T>,\n];\n\nexport function controlledState<T>({\n  value,\n  onChange,\n  defaultValue,\n}: ControlledStateOptions<T>): ControlledState<T> {\n  const change = emitter<T>();\n  const UNSET = Symbol('UNSET');\n  const userValue = signal<T | typeof UNSET>(UNSET);\n\n  // Latching flag: once the controlled value has been defined, the component\n  // is permanently controlled and set() must not update internal state.\n  // This is intentionally mutated inside `resolved` — it must latch\n  // synchronously during signal evaluation so that set() sees the correct\n  // state. A pure computation cannot express \"once true, always true\" without\n  // external state.\n  let isControlled = value() !== undefined;\n\n  const resolved = linkedSignal(() => {\n    const v = value();\n    if (v !== undefined) {\n      isControlled = true;\n      return v;\n    }\n    const uv = userValue();\n    return uv !== UNSET ? (uv as T) : defaultValue?.();\n  });\n\n  function set(newValue: T, options?: SetterOptions) {\n    if (resolved() === newValue && options?.emit !== false) {\n      return;\n    }\n    if (!isControlled) {\n      userValue.set(newValue);\n    }\n    if (options?.emit !== false) {\n      onChange?.(newValue);\n      change.emit(newValue);\n    }\n  }\n\n  return [resolved.asReadonly() as Signal<T>, set, change.asObservable()];\n}\n\nfunction setAttribute(\n  element: ElementRef<HTMLElement>,\n  attr: string,\n  value: string | null | undefined,\n): void {\n  // if the attribute is \"disabled\" and the value is 'false', we need to remove the attribute\n  if (attr === 'disabled' && value === 'false') {\n    element.nativeElement.removeAttribute(attr);\n    return;\n  }\n\n  if (value !== null && value !== undefined) {\n    element.nativeElement.setAttribute(attr, value);\n  } else {\n    element.nativeElement.removeAttribute(attr);\n  }\n}\n\nexport function attrBinding(\n  element: ElementRef<HTMLElement>,\n  attr: string,\n  value:\n    | (() => string | number | boolean | null | undefined)\n    | string\n    | number\n    | boolean\n    | null\n    | undefined,\n): void {\n  // If the value is static (not a function), set it immediately without an effect\n  if (typeof value !== 'function') {\n    setAttribute(element, attr, value?.toString() ?? null);\n    return;\n  }\n\n  isomorphicEffect(() => {\n    const valueResult = value();\n    setAttribute(element, attr, valueResult?.toString() ?? null);\n  });\n}\n\nfunction getStyleUnit(style: string): string {\n  const parts = style.split('.');\n\n  if (parts.length > 1) {\n    const unit = parts[parts.length - 1];\n\n    switch (unit) {\n      case 'px':\n      case 'em':\n      case 'rem':\n      case '%':\n      case 'vh':\n      case 'vw':\n      case 'vmin':\n      case 'vmax':\n      case 'cm':\n      case 'mm':\n      case 'in':\n      case 'pt':\n      case 'pc':\n      case 'ex':\n      case 'ch':\n        return unit;\n      default:\n        return '';\n    }\n  }\n\n  return '';\n}\n\nexport function styleBinding(\n  element: ElementRef<HTMLElement>,\n  style: string,\n  value: (() => string | number | null) | string | number | null,\n): void {\n  isomorphicEffect(() => {\n    const styleValue = typeof value === 'function' ? value() : value;\n    // we should look for units in the style name, just like Angular does e.g. width.px\n    const styleUnit = getStyleUnit(style);\n    const styleName = styleUnit ? style.replace(`.${styleUnit}`, '') : style;\n\n    if (styleValue !== null) {\n      element.nativeElement.style.setProperty(styleName, styleValue + styleUnit);\n    } else {\n      element.nativeElement.style.removeProperty(styleName);\n    }\n  });\n}\n\nexport function dataBinding(\n  element: ElementRef<HTMLElement>,\n  attr: string,\n  value: (() => string | boolean | null) | string | boolean | null,\n): void {\n  if (!attr.startsWith('data-')) {\n    throw new Error(`dataBinding: attribute \"${attr}\" must start with \"data-\"`);\n  }\n\n  isomorphicEffect(() => {\n    let valueResult = typeof value === 'function' ? value() : value;\n\n    if (valueResult === false) {\n      valueResult = null;\n    } else if (valueResult === true) {\n      valueResult = '';\n    } else if (valueResult !== null && typeof valueResult !== 'string') {\n      valueResult = String(valueResult);\n    }\n\n    setAttribute(element, attr, valueResult);\n  });\n}\n\nexport function listener<K extends keyof HTMLElementEventMap>(\n  element: HTMLElement | ElementRef<HTMLElement> | Document,\n  event: K,\n  handler: (event: HTMLElementEventMap[K]) => void,\n  options?: { injector?: Injector; config?: AddEventListenerOptions | boolean },\n): () => void;\nexport function listener(\n  element: HTMLElement | ElementRef<HTMLElement> | Document,\n  event: string,\n  handler: (event: Event) => void,\n  options?: { injector?: Injector; config?: AddEventListenerOptions | boolean },\n): () => void;\nexport function listener<K extends keyof HTMLElementEventMap>(\n  element: HTMLElement | ElementRef<HTMLElement> | Document,\n  event: K | string,\n  handler: (event: HTMLElementEventMap[K] | Event) => void,\n  options?: { injector?: Injector; config?: AddEventListenerOptions | boolean },\n): () => void {\n  return runInInjectionContext(options?.injector ?? inject(Injector), () => {\n    const ngZone = inject(NgZone);\n    const destroyRef = inject(DestroyRef);\n    const nativeElement = coerceElement(element);\n\n    // A browser can dispatch an event synchronously while Angular renders, so the\n    // handler would inherit the active reactive consumer and any signal write would\n    // throw NG0600. Angular wraps its own template listeners the same way.\n    const wrappedHandler = ((eventObject: Event) =>\n      untracked(() => handler(eventObject))) as EventListener;\n\n    const removeListener = () =>\n      nativeElement.removeEventListener(event, wrappedHandler, options?.config);\n    destroyRef.onDestroy(removeListener);\n    ngZone.runOutsideAngular(() =>\n      nativeElement.addEventListener(event, wrappedHandler, options?.config),\n    );\n\n    return removeListener;\n  });\n}\n\nexport function onMount(callback: () => void): void {\n  const injector = inject(Injector);\n  afterRenderEffect(() => runInInjectionContext(injector, callback), { injector });\n}\n\nexport function onDestroy(callback: () => void): void {\n  const destroyRef = inject(DestroyRef);\n  destroyRef.onDestroy(callback);\n}\n\n/**\n * Previously, with our state approach, we allowed signals to be written directly using their setters.\n * However, with our new approach, we want people to use the appropriate set method instead. This function takes in a writable\n * signal and returns a proxy that warns the user when set is called directly.\n */\nexport function deprecatedSetter<T>(\n  signal: WritableSignal<T>,\n  methodName: string,\n): WritableSignal<T>;\nexport function deprecatedSetter<T>(\n  signal: Signal<T>,\n  methodName: string,\n  setter: (value: T) => void,\n): WritableSignal<T>;\nexport function deprecatedSetter<T>(\n  signal: Signal<T>,\n  methodName: string,\n  setter?: (value: T) => void,\n): WritableSignal<T> {\n  return new Proxy(signal as WritableSignal<T>, {\n    get(target, prop) {\n      if (prop === 'set') {\n        return (value: T) => {\n          console.warn(\n            `Deprecation warning: Use ${methodName}() instead of setting the value directly.`,\n          );\n          if (setter) {\n            setter(value);\n          } else {\n            (target as WritableSignal<T>).set(value);\n          }\n        };\n      }\n      if (prop === 'update') {\n        return (updateFn: (value: T) => T) => {\n          console.warn(\n            `Deprecation warning: Use ${methodName}() instead of setting the value directly.`,\n          );\n          const newValue = updateFn(target());\n          if (setter) {\n            setter(newValue);\n          } else {\n            (target as WritableSignal<T>).set(newValue);\n          }\n        };\n      }\n      return target[prop as keyof WritableSignal<T>];\n    },\n  });\n}\n\n/**\n * A utility function to inject an inherited state from a parent injector. This is useful for cases\n * where a primitive needs to inherit state from a parent primitive, such as in roving focus groups.\n * We could use inject with a forwardRef, but forwardRef returns an any - no thanks...\n */\nexport function injectInheritedState<T>(\n  token: () => InjectionToken<T>,\n  injectOptions: InjectOptions = {},\n): T | null {\n  return (\n    inject<T>(\n      forwardRef(() => token()),\n      { optional: true, skipSelf: true, ...injectOptions },\n    ) ?? null\n  );\n}\n\nexport interface Emitter<T> {\n  emit(value: T): void;\n  asObservable(): Observable<T>;\n}\n\n/**\n * An emitter is a simple wrapper around a Subject that ensures\n * that change detection is run when an event is emitted and that\n * the subject is automatically completed when the component is destroyed.\n */\nexport function emitter<T>({\n  injector = inject(Injector),\n}: { injector?: Injector } = {}): Emitter<T> {\n  return runInInjectionContext(injector, () => {\n    const eventEmitter = new Subject<T>();\n    const changeDetector = inject(ChangeDetectorRef);\n\n    // Complete the subject on destroy\n    onDestroy(() => eventEmitter.complete());\n\n    return {\n      emit(value: T): void {\n        eventEmitter.next(value);\n        queueMicrotask(() => changeDetector.markForCheck());\n      },\n      asObservable(): Observable<T> {\n        return eventEmitter.asObservable();\n      },\n    };\n  });\n}\n\nfunction isomorphicEffect(callback: () => void): void {\n  const injector = inject(Injector);\n  const platformId = injector.get(PLATFORM_ID);\n\n  if (isPlatformBrowser(platformId)) {\n    afterRenderEffect(() => callback());\n  } else {\n    // On the server, we just run the effect immediately\n    effect(() => callback());\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAAA;AA2DA;;;AAGG;AACG,SAAU,gBAAgB,CAAI,WAAmB,EAAA;AACrD,IAAA,OAAO,IAAI,cAAc,CAAmB,MAAM,WAAW,CAAA,UAAA,CAAY,CAAC;AAC5E;AAiBA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,KAAuB,EAAA;IAEvB,OAAO,CAAC,EAAE,OAAO,EA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