{"version":3,"file":"index.cjs","names":["component","z","GeneratorRegistry"],"sources":["../../forge-express-nunjucks/src/adapter/routePath.ts","../../forge-express-nunjucks/src/adapter/ExpressSnapshotFactory.ts","../../forge-express-nunjucks/src/adapter/ExpressHandlerFactory.ts","../../forge-express-nunjucks/src/renderer/NunjucksRenderer.ts","../../forge-express-nunjucks/src/adapter/createExpressRouter.ts","../../forge-express-nunjucks/src/adapter/ExpressFrameworkAdapter.ts","../../forge-express-nunjucks/src/utils/buildNunjucksComponent.ts","../../forge-express-nunjucks/src/utils/nunjucksComponent.ts","../../forge-express-nunjucks/src/generators/nunjucksGenerators.ts"],"sourcesContent":["/**\n * Extract a pathname from either an absolute URL or a relative request URL.\n */\nexport function extractPathname(url: string): string {\n  try {\n    return new URL(url).pathname\n  } catch {\n    const [withoutHash] = url.split('#', 1)\n    const [path] = withoutHash.split('?', 1)\n\n    return path\n  }\n}\n\n/**\n * Resolve route params embedded in a path template.\n */\nexport function resolvePathParams(path: string, params: Record<string, string>): string {\n  return path.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, (match, name) => params[name] ?? match)\n}\n","import type express from 'express'\nimport type {\n  ForgeRoute,\n  HttpMethod,\n  RequestLocation,\n  RequestSnapshot,\n} from '@ministryofjustice/hmpps-forge/core/framework'\nimport { extractPathname, resolvePathParams } from './routePath'\nimport type { RequestWithState } from './types'\n\nexport default class ExpressSnapshotFactory {\n  static create(route: ForgeRoute, req: express.Request, res: express.Response): RequestSnapshot {\n    const params = this.normalizeParams(req.params)\n    const location = this.createRequestLocation(route, req, params)\n\n    return {\n      nodeId: route.nodeId,\n      method: this.normalizeMethod(req.method),\n      location,\n      params,\n      query: this.normalizeQuery(req.query),\n      post: this.normalizePost(req.body),\n      headers: this.normalizeHeaders(req.headers),\n      cookies: this.normalizeCookies(req.cookies),\n      state: this.createRequestState(req, res),\n      session: req.session,\n    }\n  }\n\n  private static createRequestLocation(\n    route: ForgeRoute,\n    req: express.Request,\n    params: Record<string, string>,\n  ): RequestLocation {\n    const origin = `${req.protocol}://${req.hostname}`\n    const href = `${origin}${req.originalUrl}`\n    const pathname = extractPathname(req.originalUrl)\n    const basePath = resolvePathParams(route.basePath, params)\n\n    return { origin, href, pathname, basePath }\n  }\n\n  private static createRequestState(req: express.Request, res: express.Response): Record<string, unknown> {\n    const { settings: _expressSettings, ...appLocals } = req.app.locals\n    const requestState = (req as RequestWithState).state ?? {}\n\n    return { ...appLocals, ...res.locals, ...requestState }\n  }\n\n  private static normalizeMethod(method: string): HttpMethod {\n    if (method === 'HEAD') {\n      return 'GET'\n    }\n\n    if (method === 'GET' || method === 'POST') {\n      return method\n    }\n\n    throw new TypeError(`Unsupported HTTP method: ${method}`)\n  }\n\n  private static normalizeParams(params: Record<string, string | string[] | undefined>): Record<string, string> {\n    return Object.fromEntries(\n      Object.entries(params)\n        .map(([name, value]) => [name, Array.isArray(value) ? value[0] : value])\n        .filter((entry): entry is [string, string] => entry[1] !== undefined),\n    )\n  }\n\n  private static normalizeHeaders(headers: express.Request['headers']): Record<string, string | string[] | undefined> {\n    return headers as Record<string, string | string[] | undefined>\n  }\n\n  private static normalizeCookies(cookies: unknown): Record<string, string | undefined> {\n    return (cookies as Record<string, string | undefined>) ?? {}\n  }\n\n  private static normalizeQuery(query: express.Request['query']): Record<string, string | string[]> {\n    return (query as Record<string, string | string[]>) ?? {}\n  }\n\n  private static normalizePost(body: unknown): Record<string, unknown> {\n    return (body as Record<string, unknown>) ?? {}\n  }\n}\n","import type express from 'express'\nimport type { Forge } from '@ministryofjustice/hmpps-forge/core'\nimport type {\n  ForgeOutcome,\n  ForgeRenderer,\n  ForgeRoute,\n  Logger,\n  ResponseBindings,\n} from '@ministryofjustice/hmpps-forge/core/framework'\nimport { extractPathname } from './routePath'\nimport ExpressSnapshotFactory from './ExpressSnapshotFactory'\n\nexport default class ExpressHandlerFactory {\n  static create(\n    forge: Forge,\n    route: ForgeRoute,\n    logger: Logger | Console,\n    renderer: ForgeRenderer<unknown>,\n  ): express.RequestHandler {\n    return async (req, res, next) => {\n      const requestPath = extractPathname(req.originalUrl ?? req.path)\n\n      logger.debug(`${req.method} request to step at path ${requestPath}`)\n\n      try {\n        const snapshot = ExpressSnapshotFactory.create(route, req, res)\n        const responseBindings = this.createResponseBindings(res)\n        const outcome = await forge.execute({ snapshot, responseBindings, renderer })\n\n        this.commitOutcome(outcome, res, next)\n      } catch (error) {\n        next(error)\n      }\n    }\n  }\n\n  private static createResponseBindings(res: express.Response): ResponseBindings {\n    return {\n      setHeader(name, value) {\n        res.setHeader(name, value)\n      },\n      setCookie(name, value, options) {\n        res.cookie(name, value, options ?? {})\n      },\n    }\n  }\n\n  private static commitOutcome(\n    outcome: ForgeOutcome<unknown>,\n    res: express.Response,\n    next: express.NextFunction,\n  ): void {\n    if (outcome.kind === 'navigate') {\n      res.redirect(outcome.url)\n\n      return\n    }\n\n    if (outcome.kind === 'error') {\n      const status = outcome.error.status ?? outcome.error.statusCode ?? 500\n\n      next(this.toHttpError(status, outcome.error))\n\n      return\n    }\n\n    if (!outcome.output) {\n      next(this.toHttpError(500, new Error('Render outcome produced no output - renderer not bound')))\n\n      return\n    }\n\n    res.type('html').send(outcome.output)\n  }\n\n  /**\n   * Express's final handler and error middleware read `status`/`statusCode` to pick the response\n   * code, and `expose` to decide whether `err.message` is shown in production. Both status\n   * properties are set because middleware is split on which one it reads.\n   */\n  private static toHttpError(status: number, error: Error): Error {\n    return Object.assign(error, { status, statusCode: status, expose: status < 500 })\n  }\n}\n","import nunjucks from 'nunjucks'\nimport type {\n  BlockDefinition,\n  EvaluatedBlock,\n  RenderedBlock,\n  ComponentRegistryEntry,\n} from '@ministryofjustice/hmpps-forge/core/components'\nimport type { ForgeRenderer, NodeId, RenderContext, RouteTreeNode } from '@ministryofjustice/hmpps-forge/core/framework'\nimport type { TemplateBlock, TemplateContext, TemplateNavigationItem } from './types'\n\nexport interface NunjucksRendererOptions {\n  /**\n   * Nunjucks environment used to load and render page templates. The same\n   * environment is handed to components at render time via their `renderer`\n   * parameter, so component templates and macros resolve against it too.\n   * Compiled templates are cached per renderer instance.\n   */\n  nunjucksEnv: nunjucks.Environment\n\n  /**\n   * Template used when neither the step nor its journey ancestors resolve a\n   * `view.template`. The `.njk` extension is appended automatically when not\n   * present.\n   *\n   * @default 'form-step'\n   */\n  defaultTemplate?: string\n\n  /**\n   * When true, the `blocks` array handed to page templates carries `{ html, block }`\n   * entries pairing each rendered string with its `RenderBlock` data (id, variant,\n   * block type, and evaluated properties including any authored `metadata`),\n   * index-aligned with `RenderContext.blocks` - invisible blocks stay in the array\n   * with `html: ''`. When false, `blocks` is plain rendered HTML strings.\n   *\n   * @default false\n   *\n   * @example\n   * ```njk\n   * {% for entry in blocks %}\n   *   {% if entry.block.properties.metadata.region == 'sidebar' %}\n   *     {{ entry.html | safe }}\n   *   {% endif %}\n   * {% endfor %}\n   * ```\n   */\n  includeBlockData?: boolean\n}\n\nexport default class NunjucksRenderer implements ForgeRenderer<string> {\n  private static readonly TEMPLATE_EXTENSION = '.njk'\n\n  private static readonly FALLBACK_TEMPLATE = 'form-step'\n\n  private readonly nunjucksEnv: nunjucks.Environment\n\n  private readonly defaultTemplate: string\n\n  private readonly includeBlockData: boolean\n\n  private readonly templateCache = new Map<string, nunjucks.Template>()\n\n  private readonly cachedRenderer: unknown\n\n  constructor(options: NunjucksRendererOptions) {\n    this.nunjucksEnv = options.nunjucksEnv\n    this.defaultTemplate = options.defaultTemplate ?? NunjucksRenderer.FALLBACK_TEMPLATE\n    this.includeBlockData = options.includeBlockData ?? false\n\n    const env = this.nunjucksEnv\n    const cache = this.templateCache\n\n    this.cachedRenderer = {\n      render(name: string, ctx?: object): string {\n        let tmpl = cache.get(name)\n\n        if (!tmpl) {\n          tmpl = env.getTemplate(name)\n          cache.set(name, tmpl)\n        }\n\n        return tmpl.render(ctx)\n      },\n    }\n  }\n\n  renderBlock(entry: ComponentRegistryEntry<BlockDefinition, string>, block: EvaluatedBlock<BlockDefinition>): string {\n    const rendered = entry.render(block, this.cachedRenderer)\n\n    if (typeof rendered !== 'string') {\n      throw new Error(`Component variant \"${block.variant}\" must render an HTML string for the Nunjucks adapter.`)\n    }\n\n    return rendered\n  }\n\n  /** Bracket a block's HTML with paired comment markers so devtools can locate it in the rendered DOM. */\n  markBlock(nodeId: NodeId, output: string): string {\n    return `<!--forge:${nodeId}-->${output}<!--/forge:${nodeId}-->`\n  }\n\n  wrapNestedBlock(block: BlockDefinition, output: string): RenderedBlock {\n    return { block, html: output }\n  }\n\n  assemblePage(\n    context: RenderContext,\n    renderedBlocks: readonly string[],\n    requestState: Record<string, unknown>,\n  ): string {\n    const templateContext: TemplateContext = {\n      ...requestState,\n      ...context.step.view?.locals,\n      blocks: this.buildTemplateBlocks(context, renderedBlocks),\n      step: context.step,\n      ancestors: context.ancestors,\n      routeTree: context.routeTree,\n      navigation: buildNavigationCompatibilityTree(context.routeTree),\n      answers: context.answers,\n      data: context.data,\n      fieldValidationErrors: context.fieldValidationErrors,\n      domainValidationErrors: context.domainValidationErrors,\n    }\n\n    const template = this.resolveTemplate(context)\n\n    return this.renderTemplate(template, templateContext)\n  }\n\n  private buildTemplateBlocks(\n    context: RenderContext,\n    renderedBlocks: readonly string[],\n  ): readonly string[] | readonly TemplateBlock[] {\n    if (!this.includeBlockData) {\n      return renderedBlocks\n    }\n\n    return renderedBlocks.map((html, index) => ({ html, block: context.blocks[index] }))\n  }\n\n  private resolveTemplate(context: RenderContext): string {\n    const template = context.step.view?.template ?? this.defaultTemplate\n\n    if (!template.endsWith(NunjucksRenderer.TEMPLATE_EXTENSION)) {\n      return `${template}${NunjucksRenderer.TEMPLATE_EXTENSION}`\n    }\n\n    return template\n  }\n\n  private renderTemplate(template: string, context: TemplateContext): string {\n    let tmpl = this.templateCache.get(template)\n\n    if (!tmpl) {\n      tmpl = this.nunjucksEnv.getTemplate(template)\n      this.templateCache.set(template, tmpl)\n    }\n\n    return tmpl.render(context)\n  }\n}\n\nfunction buildNavigationCompatibilityTree(routeTree: RouteTreeNode[]): TemplateNavigationItem[] {\n  return routeTree.flatMap(node => toNavigationCompatibilityItems(node))\n}\n\nfunction toNavigationCompatibilityItems(node: RouteTreeNode): TemplateNavigationItem[] {\n  const children = node.children.flatMap(child => toNavigationCompatibilityItems(child))\n\n  if (!node.route) {\n    return children\n  }\n\n  return [\n    {\n      type: node.route.kind,\n      title: node.route.title,\n      description: node.route.description,\n      path: node.path,\n      active: node.active,\n      metadata: node.metadata ?? node.route.metadata,\n      children,\n    },\n  ]\n}\n","import express from 'express'\nimport type nunjucks from 'nunjucks'\nimport type { Forge } from '@ministryofjustice/hmpps-forge/core'\nimport ExpressHandlerFactory from './ExpressHandlerFactory'\nimport NunjucksRenderer from '../renderer/NunjucksRenderer'\n\n/**\n * Options for {@link createExpressRouter}. Passed through verbatim to the\n * `NunjucksRenderer` the router builds, so each mounted router gets its own\n * renderer configuration.\n */\nexport interface ExpressForgeRouterOptions {\n  /**\n   * Nunjucks environment used to load and render page templates. The same\n   * environment is handed to components at render time via their `renderer`\n   * parameter, so component templates and macros resolve against it too.\n   */\n  nunjucksEnv: nunjucks.Environment\n\n  /**\n   * Template used when neither the step nor its journey ancestors resolve a\n   * `view.template`. The `.njk` extension is appended automatically when not\n   * present.\n   *\n   * @default 'form-step'\n   */\n  defaultTemplate?: string\n\n  /**\n   * When true, the `blocks` array handed to page templates carries `{ html, block }`\n   * entries pairing each rendered string with its `RenderBlock` data (id, variant,\n   * block type, and evaluated properties including any authored `metadata`).\n   * When false, `blocks` is plain rendered HTML strings.\n   *\n   * @default false\n   */\n  includeBlockData?: boolean\n}\n\nexport function createExpressRouter(forge: Forge, options: ExpressForgeRouterOptions): express.Router {\n  const logger = forge.getLogger()\n  const router = express.Router({ mergeParams: true })\n  const renderer = new NunjucksRenderer(options)\n\n  forge.getTopology().routes.forEach(route => {\n    const handler = ExpressHandlerFactory.create(forge, route, logger, renderer)\n\n    route.methods.forEach(method => {\n      if (method === 'GET') {\n        router.get(route.templatePath, handler)\n      } else {\n        router.post(route.templatePath, handler)\n      }\n    })\n  })\n\n  return router\n}\n","import type express from 'express'\nimport type { Forge, ForgeRouterAdapter } from '@ministryofjustice/hmpps-forge/core'\nimport { createExpressRouter } from './createExpressRouter'\nimport type { ExpressForgeRouterOptions } from './createExpressRouter'\n\n// Mirrors forge-core's internal `ForgeDeprecations` (which isn't a public export) so this package\n// need not import core internals. The `Symbol.for` key is process-global, so this shares core's\n// seen-codes set and dedupes against its warnings across bundles in the same process.\nconst SEEN_CODES = Symbol.for('forge:deprecations')\n\ninterface DeprecationsGlobal {\n  [SEEN_CODES]?: Set<string>\n}\n\nfunction seenCodes(): Set<string> {\n  const store = globalThis as DeprecationsGlobal\n  const existing = store[SEEN_CODES]\n\n  if (existing) {\n    return existing\n  }\n\n  const seen = new Set<string>()\n  store[SEEN_CODES] = seen\n\n  return seen\n}\n\nfunction warnOnce(code: string, message: string): void {\n  const seen = seenCodes()\n\n  if (seen.has(code)) {\n    return\n  }\n\n  seen.add(code)\n  process.emitWarning(message, { type: 'DeprecationWarning', code })\n}\n\n/**\n * @deprecated Build the router directly with `createExpressRouter(forge, options)`.\n */\nexport interface ExpressForgeAdapter extends ForgeRouterAdapter {\n  build(forge: Forge): express.Router\n}\n\n/**\n * @deprecated Build the router directly with `createExpressRouter(forge, options)`.\n */\nexport const ExpressFrameworkAdapter = {\n  configure(options: ExpressForgeRouterOptions): ExpressForgeAdapter {\n    warnOnce(\n      'FORGE_DEP_ExpressFrameworkAdapter',\n      'ExpressFrameworkAdapter is deprecated - build the router directly with createExpressRouter(forge, options).',\n    )\n\n    return {\n      build: (forge: Forge) => createExpressRouter(forge, options),\n    }\n  },\n}\n","import nunjucks from 'nunjucks'\n\nimport {\n  BlockDefinition,\n  EvaluatedBlock,\n  ComponentRegistryEntry,\n  BuildComponentOptions,\n} from '@ministryofjustice/hmpps-forge/core/components'\n\n/**\n * Render function for Nunjucks components.\n * Receives the evaluated block and a nunjucks environment (passed as renderer by TemplateRenderer).\n */\nexport type NunjucksComponentRenderer<T extends BlockDefinition> = (\n  block: EvaluatedBlock<T>,\n  nunjucksEnv: nunjucks.Environment,\n) => string\n\n/**\n * Creates a Nunjucks component that receives its renderer at render time.\n *\n * Prefer `nunjucksComponent` for new components - one block interface plus one call\n * replaces the props interface, block interface, wrapper function and this registration.\n * This function will be deprecated once the built-in components have moved over.\n *\n * @param variant - The block variant identifier\n * @param render - Render function that receives (block, nunjucksEnv)\n * @param options - Optional input schema and fixed-shape `multiple` flag for the entry\n * @returns A component ready for registration with Forge\n *\n * @example\n * ```typescript\n * export const myTextInput = buildNunjucksComponent<MyTextInput>(\n *   'myTextInput',\n *   (block, nunjucksEnv) => {\n *     return nunjucksEnv.render('components/text-input.njk', { block })\n *   }\n * )\n * ```\n */\nexport const buildNunjucksComponent = <T extends BlockDefinition>(\n  variant: string,\n  render: NunjucksComponentRenderer<T>,\n  options: BuildComponentOptions = {},\n): ComponentRegistryEntry<T, string> => ({\n  variant,\n  render: (block, renderer) => render(block, renderer as nunjucks.Environment),\n  ...(options.inputSchema !== undefined && { inputSchema: options.inputSchema }),\n  ...(options.multiple !== undefined && { multiple: options.multiple }),\n})\n","import type nunjucks from 'nunjucks'\n\nimport { component } from '@ministryofjustice/hmpps-forge/core/components'\nimport type { BlockDefinition, ComponentOptions, ForgeComponent } from '@ministryofjustice/hmpps-forge/core/components'\n\n/**\n * Defines a Nunjucks component from a single block interface - `component()` with the\n * renderer pinned, so the render callback receives a typed `nunjucks.Environment`.\n *\n * @example\n * ```typescript\n * export interface MyTextInput extends FieldBlockDefinition {\n *   label: ResolvableString\n * }\n *\n * export const MyTextInput = nunjucksComponent<MyTextInput>('myTextInput', {\n *   field: true,\n *   render: (props, nunjucksEnv) =>\n *     nunjucksEnv.render('components/text-input.njk', { params: { name: props.code } }),\n * })\n * ```\n */\nexport function nunjucksComponent<TBlock extends BlockDefinition>(\n  variant: string,\n  options: ComponentOptions<TBlock, string, nunjucks.Environment>,\n): ForgeComponent<TBlock, string> {\n  return component<TBlock, string, nunjucks.Environment>(variant, options)\n}\n","import nunjucks from 'nunjucks'\nimport { z } from 'zod'\nimport { GeneratorRegistry } from '@ministryofjustice/hmpps-forge/core/authoring'\n\n/**\n * Throws if the template uses any forbidden tags. Wired into the generator's\n * `prepare` hook so errors surface at journey-definition time, before any\n * request is served.\n *\n * Tags that reach outside the template (loader-driven) or define reusable\n * fragments are rejected. NunjucksGenerators.String is meant for inline\n * display composition, not for second-class authoring. Anything more\n * structural belongs in a custom generator or component.\n */\nexport const assertTemplateIsAllowed = (template: string): void => {\n  const FORBIDDEN_TAGS = ['import', 'from', 'include', 'extends', 'macro'] as const\n  const FORBIDDEN_TAG_PATTERN = new RegExp(String.raw`\\{%-?\\s*(${FORBIDDEN_TAGS.join('|')})\\b`)\n  const match = FORBIDDEN_TAG_PATTERN.exec(template)\n\n  if (!match) {\n    return\n  }\n\n  throw new Error(\n    `NunjucksGenerators.String templates cannot use {% ${match[1]} %}. ` +\n      `Allowed constructs are {% if %}, {% for %}, {% set %}, filters, and ` +\n      `variable interpolation. For reusable composition, extract a custom generator or component.`,\n  )\n}\n\n// Shared environment used by the String generator. The user's application-\n// level nunjucks env is intentionally not reused - these templates must always\n// render with autoescape on, regardless of whatever the app has configured for\n// page rendering.\nconst safeEnvironment = new nunjucks.Environment(null, {\n  autoescape: true,\n  throwOnUndefined: false,\n})\n\n/**\n * env.renderString() recompiles the source on every call, which is wasteful\n * when authors declare a template at journey-definition time and render it\n * per-request. Compile once per source string and reuse the Template instance\n * across renders.\n */\nconst templateCache = new Map<string, nunjucks.Template>()\n\n/**\n * Shape for the Nunjucks-backed generator.\n */\ninterface NunjucksStringGeneratorProps {\n  template: string\n  data?: Record<string, unknown>\n}\n\nconst nunjucksStringArgsSchema = z.tuple([\n  z.looseObject({\n    template: z.string(),\n    data: z.record(z.string(), z.unknown()).optional(),\n  }),\n])\n\nconst nunjucksGenerators = new GeneratorRegistry()\n\nexport const NunjucksGenerators = {\n  /**\n   * Render a Nunjucks template to a ResolvableString expression.\n   *\n   * Values interpolated via `{{ name }}` are HTML-escaped automatically. Use\n   * `{{ name | safe }}` when the value is trusted HTML. Forge evaluates\n   * expressions inside `data` before the template runs, so the template sees\n   * resolved primitives only.\n   *\n   * Templates are intentionally restricted to inline display composition:\n   * `{% import %}`, `{% from %}`, `{% include %}`, `{% extends %}`, and\n   * `{% macro %}` are rejected at author-call time. If you need reusable\n   * composition logic, extract a custom generator or component instead.\n   */\n  String: nunjucksGenerators.register('String', {\n    argumentsSchema: nunjucksStringArgsSchema,\n    prepare: (props: NunjucksStringGeneratorProps) => {\n      assertTemplateIsAllowed(props.template)\n\n      return [props]\n    },\n    factory: () => (props: NunjucksStringGeneratorProps) => {\n      let compiled = templateCache.get(props.template)\n\n      if (!compiled) {\n        assertTemplateIsAllowed(props.template)\n        compiled = new nunjucks.Template(props.template, safeEnvironment, undefined, true)\n        templateCache.set(props.template, compiled)\n      }\n\n      return compiled.render(props.data ?? {})\n    },\n  }),\n}\n\nexport { nunjucksGenerators as nunjucksFunctions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAAgB,gBAAgB,KAAqB;CACnD,IAAI;EACF,OAAO,IAAI,IAAI,GAAG,CAAC,CAAC;CACtB,QAAQ;EACN,MAAM,CAAC,eAAe,IAAI,MAAM,KAAK,CAAC;EACtC,MAAM,CAAC,QAAQ,YAAY,MAAM,KAAK,CAAC;EAEvC,OAAO;CACT;AACF;;;;AAKA,SAAgB,kBAAkB,MAAc,QAAwC;CACtF,OAAO,KAAK,QAAQ,+BAA+B,OAAO,SAAS,OAAO,SAAS,KAAK;AAC1F;;;ACTA,IAAqB,yBAArB,MAA4C;CAC1C,OAAO,OAAO,OAAmB,KAAsB,KAAwC;EAC7F,MAAM,SAAS,KAAK,gBAAgB,IAAI,MAAM;EAC9C,MAAM,WAAW,KAAK,sBAAsB,OAAO,KAAK,MAAM;EAE9D,OAAO;GACL,QAAQ,MAAM;GACd,QAA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