{"version":3,"sources":["../src/dev-indicators.ts","../src/auth-config.ts","../src/security.ts"],"sourcesContent":["export type FarmBuildActivityPosition = \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\";\n\nexport interface FarmDevIndicatorsConfig {\n  /** Show build and HMR activity in the browser during development. */\n  buildActivity?: boolean;\n  /** Corner used by the build activity indicator. */\n  buildActivityPosition?: FarmBuildActivityPosition;\n}\n\nexport interface ResolvedFarmDevIndicatorsConfig {\n  buildActivity: boolean;\n  buildActivityPosition: FarmBuildActivityPosition;\n}\n\nexport function resolveFarmDevIndicatorsConfig(\n  config: FarmDevIndicatorsConfig | undefined,\n  mode: \"development\" | \"production\" = \"development\",\n): ResolvedFarmDevIndicatorsConfig {\n  return {\n    buildActivity: mode === \"development\" && (config?.buildActivity ?? true),\n    buildActivityPosition: config?.buildActivityPosition ?? \"bottom-right\",\n  };\n}\n\nexport function generateFarmDevIndicatorsClientRuntime(\n  config: ResolvedFarmDevIndicatorsConfig,\n): string {\n  if (!config.buildActivity) return \"\";\n\n  const position = {\n    \"bottom-right\": \"right: 16px; bottom: 16px;\",\n    \"bottom-left\": \"left: 16px; bottom: 16px;\",\n    \"top-right\": \"right: 16px; top: 16px;\",\n    \"top-left\": \"left: 16px; top: 16px;\",\n  }[config.buildActivityPosition];\n  const styles = `\n    #__farm_build_activity__ {\n      position: fixed;\n      ${position}\n      z-index: 2147483645;\n      display: inline-flex;\n      align-items: center;\n      gap: 7px;\n      min-height: 30px;\n      padding: 0 10px;\n      border: 1px solid rgb(255 255 255 / 0.16);\n      border-radius: 999px;\n      background: rgb(17 17 17 / 0.9);\n      box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);\n      color: rgb(250 250 250);\n      font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n      letter-spacing: -0.01em;\n      opacity: 0;\n      pointer-events: none;\n      transform: translateY(4px);\n      transition: opacity 120ms ease-out, transform 120ms ease-out;\n    }\n    #__farm_build_activity__[data-visible=\"true\"] {\n      opacity: 1;\n      transform: translateY(0);\n    }\n    #__farm_build_activity__::before {\n      width: 8px;\n      height: 8px;\n      border: 1.5px solid rgb(255 255 255 / 0.32);\n      border-top-color: currentColor;\n      border-radius: 50%;\n      content: \"\";\n      animation: farm-build-activity-spin 650ms linear infinite;\n    }\n    #__farm_build_activity__[data-state=\"ready\"]::before {\n      border-color: currentColor;\n      animation: none;\n    }\n    #__farm_build_activity__[data-state=\"error\"] {\n      border-color: rgb(248 113 113 / 0.55);\n      color: rgb(254 202 202);\n    }\n    #__farm_build_activity__[data-state=\"error\"]::before {\n      border-color: currentColor;\n      animation: none;\n    }\n    @keyframes farm-build-activity-spin { to { transform: rotate(360deg); } }\n    @media (prefers-reduced-motion: reduce) {\n      #__farm_build_activity__ { transition: none; }\n      #__farm_build_activity__::before { animation-duration: 1.4s; }\n    }\n  `;\n\n  return `\nif (import.meta.hot) {\n  (() => {\n    const hot = import.meta.hot;\n    const indicatorId = \"__farm_build_activity__\";\n    const styleId = \"__farm_build_activity_styles__\";\n    const runtimeKey = \"__FARM_BUILD_ACTIVITY_RUNTIME__\";\n    const reloadMarker = \"__FARM_BUILD_ACTIVITY_RELOADING__\";\n    let hideTimer;\n\n    const ensureIndicator = () => {\n      let style = document.getElementById(styleId);\n      if (!style) {\n        style = document.createElement(\"style\");\n        style.id = styleId;\n        style.textContent = ${JSON.stringify(styles)};\n        document.head.appendChild(style);\n      }\n\n      let indicator = document.getElementById(indicatorId);\n      if (!indicator) {\n        indicator = document.createElement(\"div\");\n        indicator.id = indicatorId;\n        indicator.setAttribute(\"role\", \"status\");\n        indicator.setAttribute(\"aria-live\", \"polite\");\n        document.body.appendChild(indicator);\n      }\n      return indicator;\n    };\n\n    const show = (state, label) => {\n      window.clearTimeout(hideTimer);\n      const indicator = ensureIndicator();\n      indicator.dataset.state = state;\n      indicator.dataset.visible = \"true\";\n      indicator.textContent = label;\n    };\n    const hide = () => {\n      const indicator = document.getElementById(indicatorId);\n      if (indicator) indicator.dataset.visible = \"false\";\n    };\n    const onBeforeUpdate = () => show(\"building\", \"Farm updating\");\n    const onAfterUpdate = () => {\n      show(\"ready\", \"Farm ready\");\n      hideTimer = window.setTimeout(hide, 500);\n    };\n    const onError = () => show(\"error\", \"Build failed\");\n    const onBeforeFullReload = () => {\n      try {\n        window.sessionStorage.setItem(reloadMarker, \"1\");\n      } catch {}\n      show(\"building\", \"Farm updating\");\n    };\n\n    window[runtimeKey]?.dispose?.();\n    ensureIndicator();\n    let completedReload = false;\n    try {\n      completedReload = window.sessionStorage.getItem(reloadMarker) === \"1\";\n      window.sessionStorage.removeItem(reloadMarker);\n    } catch {}\n    if (completedReload) onAfterUpdate();\n    else hide();\n    hot.on(\"vite:beforeUpdate\", onBeforeUpdate);\n    hot.on(\"vite:afterUpdate\", onAfterUpdate);\n    hot.on(\"vite:error\", onError);\n    hot.on(\"vite:beforeFullReload\", onBeforeFullReload);\n    window[runtimeKey] = {\n      dispose() {\n        window.clearTimeout(hideTimer);\n        hot.off(\"vite:beforeUpdate\", onBeforeUpdate);\n        hot.off(\"vite:afterUpdate\", onAfterUpdate);\n        hot.off(\"vite:error\", onError);\n        hot.off(\"vite:beforeFullReload\", onBeforeFullReload);\n        document.getElementById(indicatorId)?.remove();\n      },\n    };\n  })();\n}\n`;\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { FarmIntegration } from \"./integrations\";\n\nexport interface FarmAuthEmailAndPasswordConfig {\n  /** Require a verified email before creating a session. @default false */\n  requireEmailVerification?: boolean;\n  /** Smallest accepted password length. @default 8 */\n  minPasswordLength?: number;\n  /** Largest accepted password length. @default 128 */\n  maxPasswordLength?: number;\n}\n\nexport interface FarmAuthSessionConfig {\n  /** Session lifetime in seconds. @default 604800 */\n  expiresIn?: number;\n  /** Session refresh interval in seconds. @default 86400 */\n  updateAge?: number;\n}\n\nexport interface FarmAuthDatabaseConfig {\n  /**\n   * Postgres connection string. Defaults to DATABASE_URL.\n   * Local development falls back to SQLite when no URL is present.\n   */\n  url?: string;\n  /** Local SQLite path. @default \".farm/auth.sqlite\" */\n  path?: string;\n  /** Automatically update the auth schema in development. @default true */\n  migrateInDevelopment?: boolean;\n}\n\nexport interface FarmAuthConfig {\n  /** Set false to disable auth without removing its configuration. @default true */\n  enabled?: boolean;\n  /** Display name used by authentication emails and metadata. */\n  appName?: string;\n  /** Route prefix for the auth endpoints. @default \"/api/auth\" */\n  basePath?: string;\n  /**\n   * Email/password authentication. It is enabled by default; set false to\n   * disable it when adding another sign-in method.\n   */\n  emailAndPassword?: boolean | FarmAuthEmailAndPasswordConfig;\n  session?: FarmAuthSessionConfig;\n  database?: FarmAuthDatabaseConfig;\n}\n\nexport type FarmAuthUserConfig = boolean | FarmAuthConfig;\n\nexport interface ResolvedFarmAuthConfig {\n  enabled: boolean;\n  appName?: string;\n  basePath: string;\n  emailAndPassword: {\n    enabled: boolean;\n    requireEmailVerification: boolean;\n    minPasswordLength: number;\n    maxPasswordLength: number;\n  };\n  session: {\n    expiresIn: number;\n    updateAge: number;\n  };\n  database: {\n    url?: string;\n    path: string;\n    migrateInDevelopment: boolean;\n  };\n}\n\ninterface FarmAuthRuntimeModule {\n  createFarmAuthIntegration(\n    config: ResolvedFarmAuthConfig,\n    options: {\n      root: string;\n      mode: \"development\" | \"production\";\n    },\n  ): FarmIntegration;\n}\n\nexport function resolveFarmAuthConfig(\n  input: FarmAuthUserConfig | undefined,\n): ResolvedFarmAuthConfig {\n  const config = input === true ? {} : input && typeof input === \"object\" ? input : {};\n  const passwordConfig = typeof config.emailAndPassword === \"object\" ? config.emailAndPassword : {};\n\n  const resolved: ResolvedFarmAuthConfig = {\n    enabled: input !== undefined && input !== false && config.enabled !== false,\n    appName: config.appName,\n    basePath: normalizeBasePath(config.basePath),\n    emailAndPassword: {\n      enabled: config.emailAndPassword !== false,\n      requireEmailVerification: passwordConfig.requireEmailVerification ?? false,\n      minPasswordLength: passwordConfig.minPasswordLength ?? 8,\n      maxPasswordLength: passwordConfig.maxPasswordLength ?? 128,\n    },\n    session: {\n      expiresIn: config.session?.expiresIn ?? 60 * 60 * 24 * 7,\n      updateAge: config.session?.updateAge ?? 60 * 60 * 24,\n    },\n    database: {\n      url: config.database?.url,\n      path: config.database?.path || \".farm/auth.sqlite\",\n      migrateInDevelopment: config.database?.migrateInDevelopment ?? true,\n    },\n  };\n\n  validateFarmAuthConfig(resolved);\n  return resolved;\n}\n\nexport async function resolveFarmAuthIntegration(\n  config: ResolvedFarmAuthConfig,\n  options: {\n    root: string;\n    mode: \"development\" | \"production\";\n  },\n): Promise<FarmIntegration | undefined> {\n  if (!config.enabled) return undefined;\n\n  const root = path.resolve(options.root);\n  let modulePath: string;\n  try {\n    const resolveFromApp = createRequire(path.join(root, \"package.json\"));\n    modulePath = resolveFromApp.resolve(\"@farm.js/auth/internal\");\n  } catch {\n    throw new Error(\n      \"The `auth` config requires @farm.js/auth. Install it with `pnpm add @farm.js/auth` and try again.\",\n    );\n  }\n\n  const runtime = (await import(\n    /* @vite-ignore */ pathToFileURL(modulePath).href\n  )) as FarmAuthRuntimeModule;\n  if (typeof runtime.createFarmAuthIntegration !== \"function\") {\n    throw new Error(\n      \"The installed @farm.js/auth package is incompatible with this version of @farm.js/core.\",\n    );\n  }\n\n  return runtime.createFarmAuthIntegration(config, {\n    ...options,\n    root,\n  });\n}\n\nfunction normalizeBasePath(value: string | undefined): string {\n  const route = (value || \"/api/auth\").trim();\n  if (!route) return \"/api/auth\";\n  assertStableBasePath(route);\n  const withLeadingSlash = route.startsWith(\"/\") ? route : `/${route}`;\n  const normalized = withLeadingSlash.replace(/\\/+/g, \"/\").replace(/\\/+$/, \"\");\n  return normalized || \"/api/auth\";\n}\n\nfunction assertStableBasePath(route: string): void {\n  if (route.includes(\"?\") || route.includes(\"#\")) {\n    throw new Error(\"auth.basePath cannot contain a query string or fragment.\");\n  }\n  if (route.startsWith(\"//\") || /^[a-z][a-z\\d+.-]*:\\/\\//i.test(route)) {\n    throw new Error('auth.basePath must be an application pathname such as \"/api/auth\".');\n  }\n  if (hasUnstablePathCharacters(route)) {\n    throw new Error(\"auth.basePath cannot contain backslashes or control characters.\");\n  }\n  for (const segment of route.split(\"/\")) {\n    let decoded = segment;\n    try {\n      decoded = decodeURIComponent(segment);\n    } catch {\n      // Malformed escapes remain literal URL pathname segments.\n    }\n    if (hasUnstablePathCharacters(decoded) || decoded.includes(\"/\")) {\n      throw new Error(\"auth.basePath cannot contain encoded path separators.\");\n    }\n    if (decoded === \".\" || decoded === \"..\") {\n      throw new Error('auth.basePath cannot contain \".\" or \"..\" path segments.');\n    }\n  }\n}\n\nfunction hasUnstablePathCharacters(value: string): boolean {\n  return (\n    value.includes(\"\\\\\") ||\n    Array.from(value).some((character) => {\n      const code = character.charCodeAt(0);\n      return code <= 31 || (code >= 127 && code <= 159);\n    })\n  );\n}\n\nfunction validateFarmAuthConfig(config: ResolvedFarmAuthConfig): void {\n  const { minPasswordLength, maxPasswordLength } = config.emailAndPassword;\n  if (!Number.isInteger(minPasswordLength) || minPasswordLength < 1) {\n    throw new Error(\"auth.emailAndPassword.minPasswordLength must be a positive integer.\");\n  }\n  if (!Number.isInteger(maxPasswordLength) || maxPasswordLength < minPasswordLength) {\n    throw new Error(\n      \"auth.emailAndPassword.maxPasswordLength must be an integer greater than or equal to minPasswordLength.\",\n    );\n  }\n  if (!Number.isInteger(config.session.expiresIn) || config.session.expiresIn < 1) {\n    throw new Error(\"auth.session.expiresIn must be a positive integer.\");\n  }\n  if (!Number.isInteger(config.session.updateAge) || config.session.updateAge < 0) {\n    throw new Error(\"auth.session.updateAge must be a non-negative integer.\");\n  }\n}\n","export type FarmCspDirectiveValue = string | readonly string[] | boolean | null | undefined;\n\nexport type FarmCspDirectives = Readonly<Record<string, FarmCspDirectiveValue>>;\n\nexport interface FarmCspOptions {\n  /** A pre-serialized CSP value. Cannot be combined with directives. */\n  policy?: string;\n  /** CSP directives using camelCase or kebab-case names. */\n  directives?: FarmCspDirectives;\n  /** Emit Content-Security-Policy-Report-Only instead of enforcing the policy. */\n  reportOnly?: boolean;\n}\n\nexport type FarmCspConfig = string | FarmCspOptions;\n\nexport interface FarmSecurityConfig {\n  /** App-wide Content Security Policy applied to pages, APIs, and static output. */\n  csp?: FarmCspConfig | false;\n  /** @deprecated Use csp. */\n  contentSecurityPolicy?: never;\n}\n\nexport interface ResolvedFarmCspConfig {\n  value: string;\n  reportOnly: boolean;\n}\n\nexport interface ResolvedFarmSecurityConfig {\n  csp: ResolvedFarmCspConfig | false;\n}\n\nexport function resolveFarmSecurityConfig(\n  input: FarmSecurityConfig | ResolvedFarmSecurityConfig | undefined,\n): ResolvedFarmSecurityConfig {\n  if (input === undefined) return { csp: false };\n  if (!isPlainRecord(input)) {\n    throw new TypeError(\"security must be an object containing the csp option.\");\n  }\n  if (Object.prototype.hasOwnProperty.call(input, \"contentSecurityPolicy\")) {\n    throw new TypeError(\n      \"security.contentSecurityPolicy is not supported. Use security.csp instead.\",\n    );\n  }\n\n  const csp = input.csp;\n  if (csp === undefined || csp === false) return { csp: false };\n\n  if (typeof csp === \"string\") {\n    return {\n      csp: {\n        value: validateSerializedCsp(csp),\n        reportOnly: false,\n      },\n    };\n  }\n\n  if (!isPlainRecord(csp)) {\n    throw new TypeError(\"security.csp must be a policy string, false, or an options object.\");\n  }\n\n  const reportOnly = validateReportOnly(csp.reportOnly);\n  if (Object.prototype.hasOwnProperty.call(csp, \"value\")) {\n    if (\n      Object.prototype.hasOwnProperty.call(csp, \"policy\") ||\n      Object.prototype.hasOwnProperty.call(csp, \"directives\")\n    ) {\n      throw new TypeError(\n        \"Resolved security.csp values cannot include policy or directives options.\",\n      );\n    }\n    return {\n      csp: {\n        value: validateSerializedCsp(csp.value),\n        reportOnly,\n      },\n    };\n  }\n\n  const { policy, directives } = csp;\n  if (policy !== undefined && directives !== undefined) {\n    throw new TypeError(\"security.csp accepts either policy or directives, not both.\");\n  }\n  if (policy === undefined && directives === undefined) {\n    throw new TypeError(\"security.csp requires a policy string or directives object.\");\n  }\n\n  return {\n    csp: {\n      value:\n        policy !== undefined\n          ? validateSerializedCsp(policy)\n          : serializeFarmCspDirectives(directives as FarmCspDirectives),\n      reportOnly,\n    },\n  };\n}\n\nexport function serializeFarmCspDirectives(directives: FarmCspDirectives): string {\n  if (!isPlainRecord(directives)) {\n    throw new TypeError(\"security.csp.directives must be an object.\");\n  }\n  const serialized: string[] = [];\n  const normalizedNames = new Set<string>();\n\n  for (const [configuredName, configuredValue] of Object.entries(directives)) {\n    if (configuredValue === false || configuredValue === null || configuredValue === undefined) {\n      continue;\n    }\n\n    const name = normalizeDirectiveName(configuredName);\n    if (normalizedNames.has(name)) {\n      throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);\n    }\n    normalizedNames.add(name);\n\n    const values =\n      configuredValue === true\n        ? []\n        : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(\n            validateDirectiveValue,\n          );\n    serialized.push(values.length > 0 ? `${name} ${values.join(\" \")}` : name);\n  }\n\n  if (serialized.length === 0) {\n    throw new TypeError(\"security.csp.directives must contain at least one enabled directive.\");\n  }\n  return serialized.join(\"; \");\n}\n\nexport function getFarmSecurityHeader(\n  security: ResolvedFarmSecurityConfig,\n): { key: string; value: string } | undefined {\n  if (!security.csp) return undefined;\n  return {\n    key: security.csp.reportOnly\n      ? \"Content-Security-Policy-Report-Only\"\n      : \"Content-Security-Policy\",\n    value: security.csp.value,\n  };\n}\n\n/**\n * Whether a resolved CSP would block the inline scripts the framework injects\n * into SSR documents (theme bootstrap, hydration bootstraps).\n *\n * The scripts carry no nonce or hash yet (see the CSP-nonce RFC), so they run\n * only when the governing directive — `script-src`, falling back to\n * `default-src` — permits inline script either via `'unsafe-inline'` or by\n * listing a nonce/hash source. A policy with no script-governing directive at\n * all does not restrict inline scripts, so it is not flagged. When a nonce or\n * hash is already present the app is assumed to be managing inline sources\n * deliberately and is left alone, to avoid nagging a correct-by-construction\n * setup.\n */\nexport function farmCspBlocksFrameworkInlineScripts(security: ResolvedFarmSecurityConfig): boolean {\n  if (!security.csp) return false;\n\n  const directives = parseCspDirectives(security.csp.value);\n  const governing = directives.get(\"script-src\") ?? directives.get(\"default-src\");\n  if (!governing) return false;\n\n  const allowsInline = governing.some((source) => {\n    const value = source.toLowerCase();\n    return (\n      value === \"'unsafe-inline'\" ||\n      value.startsWith(\"'nonce-\") ||\n      value.startsWith(\"'sha256-\") ||\n      value.startsWith(\"'sha384-\") ||\n      value.startsWith(\"'sha512-\")\n    );\n  });\n  return !allowsInline;\n}\n\nfunction parseCspDirectives(value: string): Map<string, string[]> {\n  const directives = new Map<string, string[]>();\n  for (const segment of value.split(\";\")) {\n    const parts = segment.trim().split(/\\s+/).filter(Boolean);\n    if (parts.length === 0) continue;\n    const name = parts[0]!.toLowerCase();\n    if (!directives.has(name)) directives.set(name, parts.slice(1));\n  }\n  return directives;\n}\n\nfunction normalizeDirectiveName(value: string): string {\n  const name = value\n    .trim()\n    .replace(/([a-z0-9])([A-Z])/g, \"$1-$2\")\n    .toLowerCase();\n  if (!/^[a-z][a-z0-9-]*$/.test(name)) {\n    throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);\n  }\n  return name;\n}\n\nfunction validateDirectiveValue(value: string): string {\n  if (typeof value !== \"string\") {\n    throw new TypeError(\"security.csp directive values must be strings or booleans.\");\n  }\n  const normalized = value.trim();\n  if (!normalized || /[;\\r\\n]/.test(normalized) || normalized.includes(\"\\0\")) {\n    throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);\n  }\n  return normalized;\n}\n\nfunction validateSerializedCsp(value: unknown): string {\n  if (typeof value !== \"string\") {\n    throw new TypeError(\"security.csp policy must be a non-empty single-line string.\");\n  }\n  const normalized = value.trim().replace(/;+$/g, \"\").trim();\n  if (!normalized || /[\\r\\n]/.test(normalized) || normalized.includes(\"\\0\")) {\n    throw new TypeError(\"security.csp policy must be a non-empty single-line string.\");\n  }\n  return normalized;\n}\n\nfunction validateReportOnly(value: unknown): boolean {\n  if (value === undefined) return false;\n  if (typeof value !== \"boolean\") {\n    throw new TypeError(\"security.csp.reportOnly must be a boolean.\");\n  }\n  return value;\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n  if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n  const prototype = Object.getPrototypeOf(value);\n  return prototype === Object.prototype || prototype === null;\n}\n"],"mappings":";;;;;AAcO,SAAS,+BACd,QACA,OAAqC,eACJ;AACjC,SAAO;AAAA,IACL,eAAe,SAAS,kBAAkB,QAAQ,iBAAiB;AAAA,IACnE,uBAAuB,QAAQ,yBAAyB;AAAA,EAC1D;AACF;AARgB;AAUT,SAAS,uCACd,QACQ;AACR,MAAI,CAAC,OAAO,cAAe,QAAO;AAElC,QAAM,WAAW;AAAA,IACf,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,aAAa;AAAA,IACb,YAAY;AAAA,EACd,EAAE,OAAO,qBAAqB;AAC9B,QAAM,SAAS;AAAA;AAAA;AAAA,QAGT,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDd,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAeqB,KAAK,UAAU,MAAM,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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