{"version":3,"sources":["../../src/scripts/compile-typescript.ts","../../src/compile-to-code.ts","../../src/lex.ts","../../src/parse.ts","../../src/compile-to-string.ts","../../src/icu.ts"],"sourcesContent":["import { compileToCode } from '../compile-to-code'\nimport { ICUUtil } from '../icu'\nimport type { FuncParam, LocaleCatalog, TranslationEntry } from './collect-translations'\nimport type { IntlConfig } from './intl-config'\n\ntype GeneratedEntry =\n  TranslationEntry\n  | { type: 'nested', value: Record<string, GeneratedEntry> }\n\nexport interface CompileResult {\n  source: string,\n  errors: string[],\n}\n\nfunction capitalize(value: string): string {\n  if (value.length === 0) return value\n  return value.charAt(0).toUpperCase() + value.slice(1)\n}\n\nfunction quoteKey(key: string): string {\n  const escaped = key\n    .replace(/\\\\/g, '\\\\\\\\')\n    .replace(/'/g, '\\\\\\'')\n    .replace(/\\r/g, '\\\\r')\n    .replace(/\\n/g, '\\\\n')\n  return `'${escaped}'`\n}\n\nfunction errorMessage(error: unknown): string {\n  return error instanceof Error ? error.message : String(error)\n}\n\nfunction numericFormats(params: readonly FuncParam[]): Record<string, 'int' | 'float'> | undefined {\n  const formats: Record<string, 'int' | 'float'> = {}\n  for (const param of params) {\n    if (param.numeric) formats[param.name] = param.numeric\n  }\n  if (Object.keys(formats).length === 0) return undefined\n  return formats\n}\n\nfunction generateCode(\n  obj: Record<string, GeneratedEntry>,\n  errors: string[],\n  indentLevel = 1\n): string {\n  const indent = '  '.repeat(indentLevel)\n  const entries = Object.entries(obj).sort((left, right) => left[0].localeCompare(right[0]))\n  let source = ''\n\n  for (const [key, entry] of entries) {\n    const quotedKey = quoteKey(key)\n    const isLast = entries[entries.length - 1][0] === key\n    const comma = isLast ? '' : ','\n\n    try {\n      if (entry.type === 'func') {\n        const ast = ICUUtil.parse(ICUUtil.lex(entry.value))\n        let compiled = compileToCode(ast, { numericFormats: numericFormats(entry.params) }).map((value, index, array) => {\n          if (value.startsWith(' ')) return value\n          if (index - 1 < 0 || !array[index - 1].startsWith(' ')) {\n            return `_out += ${value}`\n          }\n          return value\n        })\n        if (compiled.filter(value => value.startsWith('_out +=')).length === 1) {\n          const first = compiled.findIndex(value => value.startsWith('_out +='))\n          compiled[first] = 'return ' + compiled[first].slice(8)\n        } else {\n          compiled = [\n            'let _out: string = \\'\\'',\n            ...compiled,\n            'return _out',\n          ]\n        }\n        const functionLines: string[] = [\n          `({ ${entry.params.map(value => value.name).join(', ')} }): string => {`,\n          ...compiled.map(value => `  ${value}`),\n          '}',\n        ]\n        source += `${indent}${quotedKey}: ${functionLines.join(`\\n${indent}`)}${comma}\\n`\n      } else if (entry.type === 'text') {\n        const ast = ICUUtil.parse(ICUUtil.lex(entry.value))\n        const compiled = compileToCode(ast, { isOnlyText: true })\n        const text = compiled.length === 1 ? compiled[0] : `\\`${entry.value}\\``\n        source += `${indent}${quotedKey}: ${text}${comma}\\n`\n      } else {\n        source += `${indent}${quotedKey}: {\\n`\n        source += generateCode(entry.value, errors, indentLevel + 1)\n        source += `${indent}}${comma}\\n`\n      }\n    } catch (error) {\n      const shown = entry.type === 'nested' ? key : entry.value\n      errors.push(`Failed to compile key [${key}] with value \"${shown}\": ${errorMessage(error)}`)\n    }\n  }\n\n  return source\n}\n\nfunction generateType(catalog: LocaleCatalog, locales: readonly string[]): string {\n  const indent = '  '\n  const fullObject: Record<string, TranslationEntry> = {}\n\n  for (const locale of locales) {\n    const localizedEntries = Object.entries(catalog[locale] ?? {}).sort((left, right) => {\n      return left[0].localeCompare(right[0])\n    })\n    for (const [name, entry] of localizedEntries) {\n      if (!fullObject[name]) fullObject[name] = entry\n    }\n  }\n\n  let source = ''\n  for (const [key, entry] of Object.entries(fullObject)) {\n    const quotedKey = quoteKey(key)\n    if (entry.type === 'func') {\n      const params = entry.params.map(param => `${param.name}: ${param.typing}`).join(', ')\n      source += `${indent}${quotedKey}: (values: { ${params} }) => string,\\n`\n    } else {\n      source += `${indent}${quotedKey}: string,\\n`\n    }\n  }\n\n  return source\n}\n\nexport function compileToTypescript(\n  catalog: LocaleCatalog,\n  supportedLocales: readonly string[],\n  exportName: string\n): CompileResult {\n  const errors: string[] = []\n  const localesVarName = `${exportName}Locales`\n  const localesTypeName = `${capitalize(exportName)}Locales`\n  const typeName = `${capitalize(exportName)}Entries`\n  const value: Record<string, GeneratedEntry> = {}\n\n  for (const locale of supportedLocales) {\n    value[locale] = { type: 'nested', value: catalog[locale] ?? {} }\n  }\n\n  let source = '// AUTO-GENERATED. DO NOT EDIT.\\n'\n  source += '/* eslint-disable @stylistic/quote-props */\\n'\n  source += '/* eslint-disable no-useless-escape */\\n'\n  source += '/* eslint-disable @typescript-eslint/no-unused-vars */\\n'\n  source += 'import type { Translation } from \\'@helpwave/internationalization\\'\\n'\n  source += 'import { TranslationGen } from \\'@helpwave/internationalization\\'\\n\\n'\n  source += `export const ${localesVarName} = [${supportedLocales.map(locale => quoteKey(locale)).join(', ')}] as const\\n\\n`\n  source += `export type ${localesTypeName} = typeof ${localesVarName}[number]\\n\\n`\n  source += `export type ${typeName} = {\\n${generateType(catalog, supportedLocales)}}\\n\\n`\n  source += `export const ${exportName}: Translation<${localesTypeName}, Partial<${typeName}>> = {\\n${generateCode(value, errors)}}\\n\\n`\n\n  return { source, errors }\n}\n\nexport function compileTranslations(\n  catalog: LocaleCatalog,\n  config: IntlConfig,\n  exportName: string\n): CompileResult {\n  switch (config.compileTo) {\n    case 'typescript':\n      return compileToTypescript(catalog, config.supportedLocales, exportName)\n    default: {\n      const target: never = config.compileTo\n      return {\n        source: '',\n        errors: [`Compile target \"${String(target)}\" is not supported.`],\n      }\n    }\n  }\n}\n","import type { ICUASTNode } from './parse'\n\nfunction escapeForTemplateJS(s: string): string {\n  return s\n    .replace(/\\\\/g, `\\\\\\\\`)\n    .replace(/`/g, `\\\\\\``)\n    .replace(/\\$/g, `\\\\$`)\n}\n\ntype CompileContextResult = {\n  numberParam?: string,\n  numericFormats?: Record<string, 'int' | 'float'>,\n  inNode: boolean,\n  indentLevel: number,\n  isOnlyText: boolean,\n}\n\ntype CompileContext = Partial<CompileContextResult>\n\nconst defaultCompileContext: CompileContextResult = {\n  indentLevel: 0,\n  inNode: false,\n  isOnlyText: false,\n}\n\nexport function compileToCode(\n  node: ICUASTNode,\n  initialContext?: CompileContext\n): string[] {\n  const context: CompileContextResult = { ...defaultCompileContext, ...initialContext }\n  const lines: string[] = []\n  let currentLine = ''\n\n  function indent(level: number = context.indentLevel) {\n    return ' '.repeat(level * 2)\n  }\n\n  function formatValue(name: string): string {\n    const kind = context.numericFormats?.[name]\n    if (kind === 'int') return `TranslationGen.round(${name})`\n    return name\n  }\n\n  function flushCurrent() {\n    if (currentLine) {\n      if (context.inNode) {\n        lines.push(currentLine)\n      } else {\n        const nextLine = `${indent()}\\`${currentLine}\\``\n        lines.push(nextLine)\n      }\n    }\n    currentLine = ''\n  }\n\n  switch (node.type) {\n    case 'Text':\n      currentLine += escapeForTemplateJS(node.value)\n      break\n    case 'NumberField':\n      if (context.numberParam) {\n        currentLine += `$\\{${formatValue(context.numberParam)}}`\n      } else {\n        currentLine += `{${context.numberParam}}`\n      }\n      break\n    case 'SimpleReplace':\n      currentLine += `$\\{${formatValue(node.variableName)}}`\n      break\n    case 'Node': {\n      for (const partNode of node.parts) {\n        const compiled = compileToCode(partNode, { ...context, inNode: true })\n        if (partNode.type === 'OptionReplace' || partNode.type === 'Node') {\n          flushCurrent()\n          lines.push(...compiled)\n        } else {\n          currentLine += compiled[0]\n        }\n      }\n      break\n    }\n    case 'OptionReplace': {\n      if (context.isOnlyText) {\n        currentLine += `{${node.variableName}, ${node.operatorName}, {options}}`\n        break\n      }\n      flushCurrent()\n      const resolver = node.operatorName === 'plural' ?\n        'TranslationGen.resolvePlural': 'TranslationGen.resolveSelect'\n      lines.push(`${resolver}(${node.variableName}, {`)\n\n      const entries = Object.entries(node.options)\n\n      for (const [key, entryNode] of entries) {\n        const expr = compileToCode(entryNode, {\n          ...context,\n          numberParam:  node.operatorName === 'plural' ? node.variableName : context.numberParam,\n          indentLevel: context.indentLevel + 1,\n          inNode: false,\n        })\n        if (expr.length === 0) continue\n        lines.push(indent(context.indentLevel + 1) + `'${key}': ${expr[0].trimStart()}`, ...expr.slice(1))\n        lines[lines.length - 1] += ','\n      }\n\n      lines.push(indent() + `})`)\n      return lines\n    }\n  }\n  flushCurrent()\n  return lines\n}","import { escapeCharacter } from './icu'\n\nexport type ICUToken =\n  | { type: 'LBRACE' }\n  | { type: 'RBRACE' }\n  | { type: 'COMMA' }\n  | { type: 'HASHTAG' }\n  | { type: 'ESCAPE' }\n  | { type: 'WHITESPACE', value: string }\n  | { type: 'TEXT', value: string }\n\n/**\n * Takes in a sting and converts it to a list of ICUToken's\n * ICU uses single quotes to quote literal text. This means:\n * '' -> '\n * '...anything...' -> literal anything (but two single quotes inside become one)\n *  @param input The string to tokenize\n */\nexport function lex(input: string): ICUToken[] {\n  const tokens: ICUToken[] = []\n\n  function pushAppend(text: string, type: 'TEXT' | 'WHITESPACE') {\n    if (tokens.length > 0) {\n      const last = tokens[tokens.length - 1]\n      if (last.type === type) {\n        last.value += text\n        return\n      }\n    }\n    tokens.push({ type, value: text })\n  }\n\n  for (let index = 0; index < input.length; index++) {\n    const character = input[index]\n    switch (character) {\n      case '{':\n        tokens.push({ type: 'LBRACE' })\n        break\n      case '}':\n        tokens.push({ type: 'RBRACE' })\n        break\n      case '#':\n        tokens.push({ type: 'HASHTAG' })\n        break\n      case ',':\n        tokens.push({ type: 'COMMA' })\n        break\n      case escapeCharacter:\n        tokens.push({ type: 'ESCAPE' })\n        break\n      case ' ':\n        pushAppend(character, 'WHITESPACE')\n        break\n      default:\n        pushAppend(character, 'TEXT')\n        break\n    }\n  }\n\n  return tokens\n}","import type { ICUToken } from './lex'\nimport { escapeCharacter } from './icu'\nconst replaceOperations = ['plural', 'select'] as const\ntype ReplaceOperation = typeof replaceOperations[number]\n\nexport type ICUASTNode =\n  | { type: 'Node', parts: ICUASTNode[] }\n  | { type: 'Text', value: string }\n  | { type: 'NumberField' }\n  | { type: 'SimpleReplace', variableName: string } // {name}\n  | { type: 'OptionReplace', variableName: string, operatorName: ReplaceOperation, options: Record<string, ICUASTNode> } // {var, select, key{msg} ...}\n\ntype ParserState = { name: 'escape' } |\n  { name: 'normal' } |\n  {\n    name: 'replaceFunction',\n    expect: ReplaceExpectState,\n    variableName: string,\n    subtree: ICUASTNode[],\n    operatorName?: ReplaceOperation,\n    optionName: string,\n    options: Record<string, ICUASTNode>,\n  }\n\ntype ReplaceExpectState =\n  'variableName'\n  | 'variableNameCommaOrSimpleReplaceClose'\n  | 'operatorName'\n  | 'operatorNameComma'\n  | 'optionNameOrReplaceClose'\n  | 'optionOpen'\n  | 'optionContentOrClose'\n\ntype ParserContext = {\n  state: ParserState[],\n  last?: ICUToken,\n}\n\n/**\n * Converts a list of ICUToken's to a tree of ICUSAstNode's\n * @param tokens\n */\nexport function parse(tokens: ICUToken[]): ICUASTNode {\n  const result: ICUASTNode[] = []\n\n  const context: ParserContext = {\n    state: [{ name: 'normal' }],\n  }\n\n  function getState() {\n    const state = context.state[context.state.length - 1]\n    if (!state) {\n      throw new Error('ICU Parser: Reached invalid state')\n    }\n    return state\n  }\n\n  function getStateName() {\n    return getState().name\n  }\n\n  function pushText(text: string, target: ICUASTNode[] = result) {\n    if (target.length > 0) {\n      const last = target[target.length - 1]\n      if (last.type === 'Text') {\n        last.value += text\n        return\n      }\n    }\n    target.push({ type: 'Text', value: text })\n  }\n\n  function inNormal(token: ICUToken) {\n    switch (token.type) {\n      case 'RBRACE':\n        throw Error('ICU Parser: Read an unescaped \"}\" before reading a \"{\"')\n      case 'LBRACE':\n        context.state.push({\n          name: 'replaceFunction',\n          expect: 'variableName',\n          variableName: '',\n          optionName: '',\n          options: {},\n          subtree: [],\n        })\n        break\n      case 'ESCAPE':\n        context.state.push({ name: 'escape' })\n        break\n      case 'COMMA':\n        pushText(',')\n        break\n      case 'HASHTAG':\n        pushText('#')\n        break\n      case 'TEXT':\n        pushText(token.value)\n        break\n      case 'WHITESPACE':\n        pushText(token.value)\n        break\n    }\n  }\n\n  function inEscape(token: ICUToken) {\n    const prevState = context.state[context.state.length - 1]\n    let pushFunction: (value: string) => void = pushText\n    if (prevState && prevState.name === 'replaceFunction' && prevState.expect === 'operatorName') {\n      pushFunction = (value: string) => pushText(value, prevState.subtree)\n    }\n\n    switch (token.type) {\n      case 'ESCAPE':\n        if (context.last?.type === 'ESCAPE') {\n          pushFunction(escapeCharacter)\n        }\n        context.state.pop()\n        break\n      case 'COMMA':\n        pushFunction(',')\n        break\n      case 'HASHTAG':\n        pushFunction('#')\n        break\n      case 'LBRACE':\n        pushFunction('{')\n        break\n      case 'RBRACE':\n        pushFunction('}')\n        break\n      default:\n        pushFunction(token.value)\n    }\n  }\n\n  // Closing and opening brackets are already removed\n  function inReplaceFunction(token: ICUToken) {\n    const state = getState()\n    if (state.name !== 'replaceFunction') {\n      throw Error(`ICU Parser: Invalid State of Parser. Contact Package developer.`)\n    }\n    switch (token.type) {\n      case 'ESCAPE':\n        if (state.expect !== 'optionContentOrClose') {\n          throw Error(`ICU Parser: Invalid Escape character \"'\". Escape characters are only valid outside of replacement functions or in the option content.`)\n        }\n        context.state.push({ name: 'escape' })\n        break\n      case 'LBRACE':\n        if (state.expect === 'optionOpen') {\n          state.expect = 'optionContentOrClose'\n        } else if (state.expect === 'optionContentOrClose') {\n          context.state.push({\n            name: 'replaceFunction',\n            expect: 'variableName',\n            variableName: '',\n            optionName: '',\n            options: {},\n            subtree: []\n          })\n        } else {\n          throw Error(`ICU Parser: Invalid placement of \"{\" in replacement function.`)\n        }\n        break\n      case 'RBRACE':\n        if (state.expect === 'variableNameCommaOrSimpleReplaceClose') {\n          context.state.pop()\n          const prevState = getState()\n          const node: ICUASTNode = {\n            type: 'SimpleReplace',\n            variableName: state.variableName\n          }\n          if (prevState.name === 'replaceFunction') {\n            prevState.subtree.push(node)\n          } else {\n            result.push(node)\n          }\n        } else if (state.expect === 'optionContentOrClose') {\n          const subTree =  state.subtree\n          state.options[state.optionName] = subTree.length === 1 ? subTree[0] : { type: 'Node', parts: subTree }\n          state.expect = 'optionNameOrReplaceClose'\n          state.subtree = []\n        } else if (state.expect === 'optionNameOrReplaceClose') {\n          context.state.pop()\n          const prevState = getState()\n          if(!state.operatorName) {\n            throw Error(`ICU Parser: Internal Parser Error. Operator name undefined in state.`)\n          }\n          const node: ICUASTNode = {\n            type: 'OptionReplace',\n            variableName: state.variableName,\n            operatorName: state.operatorName,\n            options: state.options,\n          }\n          if (prevState.name === 'replaceFunction') {\n            prevState.subtree.push(node)\n          } else {\n            result.push(node)\n          }\n        } else {\n          throw Error(`ICU Parser: Invalid placement of \"}\" in replacement function.`)\n        }\n        break\n      case 'HASHTAG': {\n        if (state.expect === 'optionContentOrClose') {\n          if (state.operatorName === 'plural') {\n            state.subtree.push({ type: 'NumberField' })\n          } else {\n            pushText('#', state.subtree)\n          }\n        } else {\n          throw Error(`ICU Parser: Invalid placement of \"#\". \"#\" are only valid outside of replacement functions or in the option content.`)\n        }\n        break\n      }\n      case 'COMMA':\n        if (state.expect === 'operatorNameComma') {\n          state.expect = 'optionNameOrReplaceClose'\n        } else if (state.expect === 'variableNameCommaOrSimpleReplaceClose') {\n          state.expect = 'operatorName'\n        } else if (state.expect === 'optionContentOrClose') {\n          pushText(',', state.subtree)\n        } else {\n          throw Error(`ICU Parser: Invalid placement of \",\" in replacement function.`)\n        }\n        break\n      case 'WHITESPACE':\n        if (state.expect === 'optionContentOrClose') {\n          pushText(token.value, state.subtree)\n        }\n        break\n      case 'TEXT':\n        if (state.expect === 'variableName') {\n          state.variableName = token.value\n          state.expect = 'variableNameCommaOrSimpleReplaceClose'\n        } else if (state.expect === 'operatorName') {\n          if (replaceOperations.some(value => value === token.value)) {\n            state.operatorName = token.value as ReplaceOperation\n          } else {\n            throw Error(`ICU Parser: ${token.value} is an invalid replacement function operator. Allowed are ${replaceOperations.map(value => `\"${value}\"`).join(', ')}`)\n          }\n          state.expect = 'operatorNameComma'\n        } else if (state.expect === 'optionNameOrReplaceClose') {\n          state.optionName = token.value\n          state.expect = 'optionOpen'\n        } else if (state.expect === 'optionContentOrClose') {\n          pushText(token.value, state.subtree)\n        } else {\n          throw Error('ICU Parser: Invalid position of a Text block in a replacement function.')\n        }\n        break\n    }\n  }\n\n  for (let index = 0; index < tokens.length; index++) {\n    const token = tokens[index]\n    const state = getStateName()\n\n    if (state === 'normal') {\n      inNormal(token)\n    } else if (state === 'replaceFunction') {\n      inReplaceFunction(token)\n    } else if (state === 'escape') {\n      inEscape(token)\n    }\n    context.last = token\n  }\n\n  const state = getStateName()\n\n  if (state === 'replaceFunction') {\n    throw Error(`ICU Parse: Encountered unclosed \"{\"`)\n  } else if (state === 'escape') {\n    throw Error(`ICU Parse: Encountered unclosed escape \"'\"`)\n  }\n  return result.length !== 1 ? { type: 'Node', parts: result } : result[0]\n}","import type { ICUASTNode } from '@/src/parse'\n\nexport function getPluralKey(num: number)  {\n  return num === 0 ? '=0' :\n      num === 1 ? '=1' :\n        num === 2 ? '=2' :\n          num > 2 && num < 5 ? 'few' :\n            num >= 5 ? 'many' : 'other'\n}\n\ntype CompilerContext = {\n  hashtagReplacer?: number,\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ICUCompilerValues = Record<string, any>\n\n/**\n * Compiles a ICUASTNode tree to a string\n * @param node Tree to compile\n * @param values The values that replace the variable in the tree\n * @param context The context values of previous compile iterations\n */\nexport function compileToString(node: ICUASTNode, values: ICUCompilerValues, context: CompilerContext = {}): string {\n  switch (node.type) {\n    case 'Node': {\n      return node.parts.map(p => compileToString(p, values, context)).join('')\n    }\n    case 'Text':\n      return node.value\n    case 'SimpleReplace': {\n      const name = node.variableName\n      if (values && values[name] !== undefined) return String(values[name])\n      console.warn(`ICU Compile: missing value for ${name}`)\n      return `{${name}}`\n    }\n    case 'OptionReplace': {\n      const name = node.variableName\n      const operation = node.operatorName\n      const val = values ? values[name] : undefined\n      switch (operation) {\n        case 'plural': {\n          const num = Number(val)\n          if (isNaN(num)) {\n            console.warn(`ICU Compile: plural expected numeric value for ${name}, got ${val}`)\n            return `{${name}}`\n          }\n          const pluralKey = getPluralKey(num)\n\n          const chosen = node.options[pluralKey] ?? node.options['other']\n          if (!chosen) {\n            console.warn(`ICU Compile: plural for ${name} could not find key ${pluralKey} and no other`)\n            return `{${name}}`\n          }\n          return compileToString(chosen, values, { ...context, hashtagReplacer: num })\n        }\n        case 'select': {\n          if (val === undefined) {\n            console.warn(`ICU Compile: missing value for select ${name}`)\n            const other = node.options['other']\n            return other ? compileToString(other, values, context) : `{${name}}`\n          }\n          const chosen = node.options[String(val)] ?? node.options['other']\n          if (!chosen) {\n            console.warn(`ICU Compile: select ${name} chose undefined option \"${val}\" and no \"other\" provided`)\n            return `{${name}}`\n          }\n          return compileToString(chosen, values, context)\n        }\n        default: {\n          return `{${name}, ${operation}}`\n        }\n      }\n    }\n    case 'NumberField': {\n      if (context.hashtagReplacer !== undefined) {\n        return `${context.hashtagReplacer}`\n      } else {\n        return '{#}'\n      }\n    }\n  }\n}","import { lex } from './lex'\nimport { parse } from './parse'\nimport { compileToString } from './compile-to-string'\nimport type { ICUCompilerValues } from './compile-to-string'\n\nexport const escapeCharacter = \"'\"\n\nfunction interpret(message: string, values: ICUCompilerValues): string {\n  try {\n    return compileToString(parse(lex(message)), values)\n  } catch (e) {\n    console.error(`Failed to interpret message: ${message}`, e)\n    return message\n  }\n}\n\nexport const ICUUtil = {\n  lex,\n  parse,\n  compile: compileToString,\n  interpret,\n  escapeCharacter\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,SAAS,oBAAoB,GAAmB;AAC9C,SAAO,EACJ,QAAQ,OAAO,MAAM,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,OAAO,KAAK;AACzB;AAYA,IAAM,wBAA8C;AAAA,EAClD,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,YAAY;AACd;AAEO,SAAS,cACd,MACA,gBACU;AACV,Q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