{"version":3,"sources":["../src/annyang.ts"],"sourcesContent":["const MIN_RESTART_INTERVAL_MS = 1000;\nconst RESTART_WARNING_INTERVAL = 10;\n\nlet recognition: SpeechRecognition;\nlet listening: boolean = false;\nlet autoRestart: boolean = true;\nlet restartTimer: ReturnType<typeof setTimeout> | undefined;\nlet debugState: boolean = false;\nconst debugStyle: string = 'font-weight: bold; color: #00f;';\n\nexport interface CallbackMap {\n  start: () => void;\n  end: () => void;\n  soundstart: () => void;\n  result: (phrases: string[]) => void;\n  resultMatch: (userSaid: string, commandText: string, phrases: string[]) => void;\n  resultNoMatch: (phrases: string[]) => void;\n  error: (event: SpeechRecognitionErrorEvent) => void;\n  errorNetwork: (event: SpeechRecognitionErrorEvent) => void;\n  errorPermissionBlocked: (event: SpeechRecognitionErrorEvent) => void;\n  errorPermissionDenied: (event: SpeechRecognitionErrorEvent) => void;\n}\n\nexport type CallbackType = keyof CallbackMap;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyFunction = (...args: any[]) => void;\n\ninterface StoredCallback {\n  callback: AnyFunction;\n  context: object | undefined;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst commandsList: Map<string, { command: RegExp; callback: (...args: any[]) => void }> = new Map();\nconst callbacks: Map<CallbackType, StoredCallback[]> = new Map([\n  ['start', []],\n  ['error', []],\n  ['end', []],\n  ['soundstart', []],\n  ['result', []],\n  ['resultMatch', []],\n  ['resultNoMatch', []],\n  ['errorNetwork', []],\n  ['errorPermissionBlocked', []],\n  ['errorPermissionDenied', []],\n]);\nlet lastStartedAt: number = 0;\nlet autoRestartCount: number = 0;\nlet pauseListening: boolean = false;\n\nconst cancelRestart = () => {\n  if (restartTimer !== undefined) {\n    clearTimeout(restartTimer);\n    restartTimer = undefined;\n  }\n};\n\n// The command matching code is a modified version of Backbone.Router by Jeremy Ashkenas, under the MIT license.\nconst optionalParam = /\\s*\\((.*?)\\)\\s*/g;\nconst optionalRegex = /(\\(\\?:[^)]+\\))\\?/g;\nconst namedParam = /(\\(\\?)?:\\w+/g;\nconst splatParam = /\\*\\w+/g;\nconst escapeRegExp = /[{}[\\]+?.\\\\^$|]/g;\nconst commandToRegExp = (command: string) => {\n  const parts = command.split(/([:*]\\w+)/);\n  const last = parts.length - 1;\n  const ending = parts[last].replace(/[.!?]+$/, '');\n  // Only relax sentence endings after literal text, never after a captured value\n  // or an optional suffix that could disappear and expose a capture.\n  const literalEnding = /\\S/.test(ending) && (last === 0 || !ending.trimEnd().endsWith(')'));\n  if (literalEnding) parts[last] = ending;\n  const parsedCommand = parts\n    .map((part, index) =>\n      index % 2 ? part : part.replace(escapeRegExp, '\\\\$&').replace(/([\\p{L}\\p{N}]),?(?=\\s+[\\p{L}\\p{N}])/gu, '$1,?')\n    )\n    .join('')\n    .replace(optionalParam, '(?:$1)?')\n    .replace(namedParam, (match, optional) => {\n      return optional ? match : '([^\\\\s]+)';\n    })\n    .replace(splatParam, '(.*?)')\n    .replace(optionalRegex, '\\\\s*$1?\\\\s*');\n  return new RegExp(`^${parsedCommand}${literalEnding ? '[.!?]*' : ''}$`, 'iu');\n};\n\n// Get the SpeechRecognition object, accounting for possible browser prefixes\nconst getSpeechRecognition = () => globalThis.SpeechRecognition || globalThis.webkitSpeechRecognition;\n\n// Check if annyang is already initialized\nconst isInitialized = () => {\n  return recognition !== undefined;\n};\n\n// Method for logging to the console when debug mode is on\nconst logMessage = (text: string, extraParameters?: string | string[]) => {\n  if (debugState) {\n    if (text.indexOf('%c') === -1 && !extraParameters) {\n      console.log(text);\n    } else {\n      console.log(text, extraParameters || debugStyle);\n    }\n  }\n};\n\n// Add a command to the commands list\nconst registerCommand = (command: RegExp, callback: AnyFunction, originalPhrase: string) => {\n  commandsList.set(originalPhrase, { command, callback });\n  logMessage(`Command successfully loaded: %c${originalPhrase}`, debugStyle);\n};\n\n// This method receives an array of callbacks and invokes each of them\nconst invokeCallbacks = (callbacksArr: StoredCallback[] = [], ...args: unknown[]) => {\n  callbacksArr.slice().forEach(cb => {\n    cb.callback.apply(cb.context, args);\n  });\n};\n\n// Initialize annyang\nconst init = () => {\n  if (!getSpeechRecognition()) {\n    return;\n  }\n\n  // Abort previous instances of recognition already running\n  if (recognition && recognition.abort) {\n    recognition.abort();\n  }\n\n  // initiate SpeechRecognition\n  recognition = new (getSpeechRecognition())();\n\n  // Set the max number of alternative transcripts to try and match with a command\n  recognition.maxAlternatives = 5;\n\n  // In HTTPS, turn off continuous mode for faster results.\n  // In HTTP,  turn on  continuous mode for much slower results, but no repeating security notices\n  recognition.continuous = globalThis.location.protocol === 'http:';\n\n  // Sets the language to the default 'en-US'. This can be changed with annyang.setLanguage()\n  recognition.lang = 'en-US';\n\n  recognition.onstart = () => {\n    listening = true;\n    invokeCallbacks(callbacks.get('start'));\n  };\n\n  recognition.onsoundstart = () => {\n    invokeCallbacks(callbacks.get('soundstart'));\n  };\n\n  recognition.onerror = event => {\n    invokeCallbacks(callbacks.get('error'), event);\n    switch (event.error) {\n      case 'network':\n        invokeCallbacks(callbacks.get('errorNetwork'), event);\n        break;\n      case 'not-allowed':\n      case 'service-not-allowed':\n        // if permission to use the mic is denied, turn off auto-restart\n        autoRestart = false;\n        // determine if permission was denied by user or automatically.\n        if (new Date().getTime() - lastStartedAt < 200) {\n          invokeCallbacks(callbacks.get('errorPermissionBlocked'), event);\n        } else {\n          invokeCallbacks(callbacks.get('errorPermissionDenied'), event);\n        }\n        break;\n      default:\n        break;\n    }\n  };\n\n  recognition.onend = () => {\n    listening = false;\n    invokeCallbacks(callbacks.get('end'));\n    // annyang will auto restart if it is closed automatically and not by user action.\n    if (autoRestart) {\n      // play nicely with the browser, and never restart annyang automatically more than once per second\n      const timeSinceLastStart = new Date().getTime() - lastStartedAt;\n      autoRestartCount += 1;\n      if (autoRestartCount % RESTART_WARNING_INTERVAL === 0) {\n        logMessage(\n          'Speech Recognition is repeatedly stopping and starting. See http://is.gd/annyang_restarts for tips.'\n        );\n      }\n      if (timeSinceLastStart < MIN_RESTART_INTERVAL_MS) {\n        cancelRestart();\n        restartTimer = setTimeout(() => {\n          restartTimer = undefined;\n          if (autoRestart) start({ paused: pauseListening });\n        }, MIN_RESTART_INTERVAL_MS - timeSinceLastStart);\n      } else {\n        start({ paused: pauseListening });\n      }\n    }\n  };\n\n  recognition.onresult = (event: SpeechRecognitionEvent) => {\n    if (pauseListening) {\n      logMessage('Speech heard, but annyang is paused');\n      return;\n    }\n\n    // Map the results to an array\n    const SpeechRecognitionResults = event.results[event.resultIndex];\n    const results = Array.from(SpeechRecognitionResults, result => result.transcript);\n    parseResults(results);\n  };\n};\n\n// If annyang isn't initialized, initialize it\nconst initIfNeeded = () => {\n  if (!isInitialized()) {\n    init();\n  }\n};\n\nconst parseResults = (recognitionResults: string[]) => {\n  invokeCallbacks(callbacks.get('result'), recognitionResults);\n\n  // Log all recognition alternatives for debugging, regardless of match\n  for (const rawText of recognitionResults) {\n    logMessage(`Speech recognized: %c${rawText.trim()}`, debugStyle);\n  }\n\n  // Try to match each alternative to a command\n  for (const rawText of recognitionResults) {\n    const commandText = rawText.trim();\n    for (const [originalPhrase, currentCommand] of commandsList) {\n      const matchedCommand = currentCommand.command.exec(commandText);\n      if (matchedCommand) {\n        const parameters = matchedCommand.slice(1);\n        logMessage(`command matched: %c${originalPhrase}`, debugStyle);\n        if (parameters.length) {\n          logMessage('with parameters', parameters);\n        }\n        currentCommand.callback(...parameters);\n        invokeCallbacks(callbacks.get('resultMatch'), commandText, originalPhrase, recognitionResults);\n        return;\n      }\n    }\n  }\n  invokeCallbacks(callbacks.get('resultNoMatch'), recognitionResults);\n};\n\n/**\n * Is SpeechRecognition supported in this environment?\n *\n * @returns {boolean} true if SpeechRecognition is supported by the browser\n */\nconst isSpeechRecognitionSupported = () => !!getSpeechRecognition();\n\nexport type CommandCallback = (...args: string[]) => void;\n\nexport interface CommandsList {\n  [key: string]:\n    | CommandCallback\n    | {\n        regexp: RegExp;\n        callback: CommandCallback;\n      };\n}\n\n/**\n * Add commands that annyang will respond to.\n * By default this will add to the existing commands. Pass `true` as the second parameter to remove all existing commands first.\n *\n * #### Examples:\n * ````javascript\n * const commands1 = {'hello :name': helloFunction, 'howdy': helloFunction};\n * const commands2 = {'hi': helloFunction};\n *\n * annyang.addCommands(commands1);\n * annyang.addCommands(commands2);\n * // annyang will now listen for all three commands defined in commands1 and commands2\n *\n * annyang.addCommands(commands2, true);\n * // annyang will now only listen for the command in commands2\n * ````\n *\n * @param {Object} commands - Commands that annyang should listen for\n * @param {boolean} [resetCommands=false] - Remove all existing commands before adding new commands? * @see [Commands Object](#commands-object)\n */\nconst addCommands = (commands: CommandsList, resetCommands = false) => {\n  if (resetCommands) {\n    commandsList.clear();\n  }\n\n  for (const phrase of Object.keys(commands)) {\n    const cb = commands[phrase];\n\n    if (typeof cb === 'function') {\n      // convert command to regex then register the command\n      registerCommand(commandToRegExp(phrase), cb, phrase);\n    } else if (typeof cb === 'object' && cb.regexp instanceof RegExp) {\n      // register the command\n      registerCommand(new RegExp(cb.regexp.source, 'i'), cb.callback, phrase);\n    } else {\n      logMessage(`Can not register command: %c${phrase}`, debugStyle);\n    }\n  }\n};\n\n/**\n * Remove existing commands. Called with a single phrase, an array of phrases, or with no params to remove all commands.\n *\n * #### Examples:\n * ````javascript\n * const commands = {'hello': helloFunction, 'howdy': helloFunction, 'hi': helloFunction};\n *\n * // Remove all existing commands\n * annyang.removeCommands();\n *\n * // Add some commands\n * annyang.addCommands(commands);\n *\n * // Don't respond to hello\n * annyang.removeCommands('hello');\n *\n * // Don't respond to howdy or hi\n * annyang.removeCommands(['howdy', 'hi']);\n * ````\n * @param {string|string[]|undefined} [commandsToRemove] - Commands to remove\n */\nconst removeCommands = (commandsToRemove?: string | string[] | undefined) => {\n  if (commandsToRemove === undefined) {\n    commandsList.clear();\n  } else {\n    const commandsToRemoveArray = Array.isArray(commandsToRemove) ? commandsToRemove : [commandsToRemove];\n    commandsToRemoveArray.forEach(command => commandsList.delete(command));\n  }\n};\n\nexport interface StartOptions {\n  autoRestart?: boolean;\n  continuous?: boolean;\n  paused?: boolean;\n}\n\n/**\n * Start listening.\n * It's a good idea to call this after adding some commands first (but not mandatory)\n *\n * Receives an optional options object which supports the following options:\n *\n * - `autoRestart`  (boolean) Should annyang restart itself if it is closed indirectly (e.g. because of silence or window conflicts)?\n * - `continuous`   (boolean) Allow forcing continuous mode on or off. annyang is pretty smart about this, so only set this if you know what you're doing.\n * - `paused`       (boolean) Start annyang in paused mode.\n *\n * #### Examples:\n * ````javascript\n * // Start listening, don't restart automatically\n * annyang.start({ autoRestart: false });\n * // Start listening, don't restart automatically, stop recognition after first phrase recognized\n * annyang.start({ autoRestart: false, continuous: false });\n * ````\n * @param {Object} [options] - Optional options.\n */\nconst start = (options: StartOptions = {}) => {\n  cancelRestart();\n  if (!isSpeechRecognitionSupported()) {\n    return;\n  }\n  initIfNeeded();\n  pauseListening = !!options.paused;\n  if (options.autoRestart !== undefined) {\n    autoRestart = !!options.autoRestart;\n  } else {\n    autoRestart = true;\n  }\n  if (options.continuous !== undefined) {\n    recognition.continuous = !!options.continuous;\n  }\n\n  lastStartedAt = new Date().getTime();\n  try {\n    recognition.start();\n  } catch (e: unknown) {\n    logMessage(e instanceof Error ? e.message : String(e));\n  }\n};\n\n/**\n * Stop listening and turn off the mic.\n *\n * Alternatively, to only temporarily pause annyang responding to commands without stopping the SpeechRecognition engine or closing the mic, use pause() instead.\n * @see [pause()](#pause)\n */\nconst abort = () => {\n  autoRestart = false;\n  cancelRestart();\n  autoRestartCount = 0;\n  if (isInitialized()) {\n    recognition.abort();\n  }\n};\n\n/**\n * Pause listening. annyang will stop responding to commands (until the resume or start methods are called), without turning off the browser's SpeechRecognition engine or the mic.\n *\n * Alternatively, to stop the SpeechRecognition engine and close the mic, use abort() instead.\n * @see [abort()](#abort)\n */\nconst pause = () => {\n  pauseListening = true;\n};\n\n/**\n * Resumes listening and restore command callback execution when a command is matched.\n * If SpeechRecognition was aborted (stopped), start it.\n */\nconst resume = () => {\n  start();\n};\n\n/**\n * Add a callback function to be called in case one of the following events happens:\n *\n * * `start` - Fired as soon as the browser's Speech Recognition engine starts listening.\n *\n * * `soundstart` - Fired as soon as any sound (possibly speech) has been detected.\n *\n *     This will fire once per Speech Recognition starting. See https://is.gd/annyang_sound_start.\n *\n * * `error` - Fired when the browser's Speech Recognition engine returns an error, this generic error callback will be followed by more accurate error callbacks (both will fire if both are defined).\n *\n *     The Callback function will be called with the error event as the first argument.\n *\n * * `errorNetwork` - Fired when Speech Recognition fails because of a network error.\n *\n *     The Callback function will be called with the error event as the first argument.\n *\n * * `errorPermissionBlocked` - Fired when the browser blocks the permission request to use Speech Recognition.\n *\n *     The Callback function will be called with the error event as the first argument.\n *\n * * `errorPermissionDenied` - Fired when the user blocks the permission request to use Speech Recognition.\n *\n *     The Callback function will be called with the error event as the first argument.\n *\n * * `end` - Fired when the browser's Speech Recognition engine stops.\n *\n * * `result` - Fired as soon as some speech was identified. This generic callback will be followed by either the `resultMatch` or `resultNoMatch` callbacks.\n *\n *     The Callback functions for this event will be called with an array of possible phrases the user said as the first argument.\n *\n * * `resultMatch` - Fired when annyang was able to match between what the user said and a registered command.\n *\n *     The Callback functions for this event will be called with three arguments in the following order:\n *\n *     * The phrase the user said that matched a command.\n *     * The command that was matched.\n *     * An array of possible alternative phrases the user might have said.\n *\n * * `resultNoMatch` - Fired when what the user said didn't match any of the registered commands.\n *\n *     Callback functions for this event will be called with an array of possible phrases the user might have said as the first argument.\n *\n * #### Examples:\n * ````javascript\n * annyang.addCallback('resultMatch', (userSaid, commandText, phrases) => {\n *   console.log(userSaid); // sample output: 'hello'\n *   console.log(commandText); // sample output: 'hello (there)'\n *   console.log(phrases); // sample output: ['hello', 'halo', 'yellow', 'polo', 'hello kitty']\n * });\n *\n * // Returns an unsubscribe function\n * const unsubscribe = annyang.addCallback('error', () => {\n *   console.log('There was an error!');\n * });\n * unsubscribe(); // removes the callback\n * ````\n * @param {string} type - Name of event that will trigger this callback\n * @param {function} callback - The function to call when event is triggered\n * @param {Object} [context] - Optional context for the callback function\n * @returns {function} A function that removes this callback when called\n */\nconst addCallback = <T extends CallbackType>(\n  type: T,\n  callback: CallbackMap[T],\n  context: object | undefined = undefined\n): (() => void) => {\n  const callbacksOfType = callbacks.get(type);\n  if (typeof callback === 'function' && callbacksOfType) {\n    const entry: StoredCallback = {\n      callback: callback as AnyFunction,\n      context,\n    };\n    callbacksOfType.push(entry);\n    return () => {\n      const arr = callbacks.get(type);\n      if (arr) {\n        const idx = arr.indexOf(entry);\n        if (idx !== -1) arr.splice(idx, 1);\n      }\n    };\n  }\n  return () => {};\n};\n\n/**\n * Remove callbacks from events.\n *\n * - Pass an event name and a callback command to remove that callback command from that event type.\n * - Pass just an event name to remove all callback commands from that event type.\n * - Pass undefined as event name and a callback command to remove that callback command from all event types.\n * - Pass no params to remove all callback commands from all event types.\n *\n * #### Examples:\n * ````javascript\n * annyang.addCallback('start', myFunction1);\n * annyang.addCallback('start', myFunction2);\n * annyang.addCallback('end', myFunction1);\n * annyang.addCallback('end', myFunction2);\n *\n * // Remove all callbacks from all events:\n * annyang.removeCallback();\n *\n * // Remove all callbacks attached to end event:\n * annyang.removeCallback('end');\n *\n * // Remove myFunction2 from being called on start:\n * annyang.removeCallback('start', myFunction2);\n *\n * // Remove myFunction1 from being called on all events:\n * annyang.removeCallback(undefined, myFunction1);\n * ````\n *\n * @param type Name of event type to remove callback from\n * @param callback The callback function to remove\n * @returns undefined\n */\nconst removeCallback = (type?: CallbackType, callback?: CallbackMap[CallbackType]) => {\n  callbacks.forEach((callbacksArray, callbackType) => {\n    if (type === undefined || type === callbackType) {\n      if (callback === undefined) {\n        callbacks.get(callbackType)!.length = 0;\n      } else {\n        callbacks.set(\n          callbackType,\n          callbacksArray.filter(cb => cb.callback !== callback)\n        );\n      }\n    }\n  });\n};\n\n/**\n * Returns true if speech recognition is currently on.\n * Returns false if speech recognition is off or annyang is paused.\n *\n * @returns true if SpeechRecognition is on and annyang is not paused\n */\nconst isListening = () => {\n  return listening && !pauseListening;\n};\n\nexport type AnnyangState = 'idle' | 'listening' | 'paused';\n\n/**\n * Returns the current state of annyang.\n *\n * @returns {'idle' | 'listening' | 'paused'} The current state\n */\nconst getState = (): AnnyangState => {\n  if (!listening) return 'idle';\n  if (pauseListening) return 'paused';\n  return 'listening';\n};\n\n/**\n * Set the language the user will speak in. If this method is not called, annyang defaults to 'en-US'.\n *\n * @param {string} language - The language (locale)\n * @see [Languages](https://github.com/TalAter/annyang/blob/master/docs/FAQ.md#what-languages-are-supported)\n */\nconst setLanguage = (language: string): void => {\n  if (!isSpeechRecognitionSupported()) {\n    return;\n  }\n  initIfNeeded();\n  recognition.lang = language;\n};\n\n/**\n * Turn on the output of debug messages to the console.\n *\n * @param {boolean} [newState=true] - Turn debug messages on or off\n */\nconst debug = (newState: boolean = true): void => {\n  debugState = !!newState;\n};\n\n/**\n * Match text against registered commands and fire the corresponding callbacks.\n * Works independently of the speech recognition engine — does not require `start()`, and works even in\n * environments where SpeechRecognition is not supported.\n *\n * Can accept either a string containing a single sentence or an array containing multiple sentences to be checked\n * in order until one of them matches a command (similar to the way Speech Recognition Alternatives are parsed)\n *\n * #### Examples:\n * ````javascript\n * annyang.trigger('Time for some thrilling heroics');\n * annyang.trigger(\n *     ['Time for some thrilling heroics', 'Time for some thrilling aerobics']\n *   );\n * ````\n *\n * @param sentences - A sentence as a string or an array of strings of possible sentences\n */\nconst trigger = (sentences: string | string[] = []) => {\n  parseResults(Array.isArray(sentences) ? sentences : [sentences]);\n};\n\n/**\n * Returns the instance of the browser's SpeechRecognition object used by annyang.\n * Useful in case you want direct access to the browser's Speech Recognition engine.\n *\n * @returns SpeechRecognition The browser's Speech Recognizer instance currently used by annyang\n */\nconst getSpeechRecognizer = (): SpeechRecognition | undefined => {\n  return recognition;\n};\n\n/**\n * @deprecated annyang no longer requires manual initialization. It initializes automatically on `start()` or `addCommands()`. Remove any calls to `init()`.\n */\nconst initDeprecated = () => {\n  console.warn(\n    'annyang.init() is deprecated and no longer needed. ' +\n      'annyang initializes automatically on start() or addCommands(). Remove this call.'\n  );\n};\n\nexport {\n  abort,\n  addCallback,\n  addCommands,\n  debug,\n  getSpeechRecognizer,\n  getState,\n  initDeprecated as init,\n  isListening,\n  isSpeechRecognitionSupported,\n  pause,\n  removeCallback,\n  removeCommands,\n  resume,\n  setLanguage,\n  start,\n  trigger,\n};\n\nconst annyang = {\n  isSpeechRecognitionSupported,\n  addCommands,\n  removeCommands,\n  start,\n  abort,\n  pause,\n  resume,\n  addCallback,\n  removeCallback,\n  isListening,\n  setLanguage,\n  trigger,\n  debug,\n  getSpeechRecognizer,\n  getState,\n  init: initDeprecated,\n  get state() {\n    return getState();\n  },\n} as const;\n\nexport default annyang;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AAEjC,IAAI;AACJ,IAAI,YAAqB;AACzB,IAAI,cAAuB;AAC3B,IAAI;AACJ,IAAI,aAAsB;AAC1B,IAAM,aAAqB;AA0B3B,IAAM,eAAqF,oBAAI,IAAI;AACnG,IAAM,YAAiD,oBAAI,IAAI;AAAA,EAC7D,CAAC,SAAS,CAAC,CAAC;AAAA,EACZ,CAAC,SAAS,CAAC,CAAC;AAAA,EACZ,CAAC,OAAO,CAAC,CAAC;AAAA,EACV,CAAC,cAAc,CAAC,CAAC;AAAA,EACjB,CAAC,UAAU,CAAC,CAAC;AAAA,EACb,CAAC,eAAe,CAAC,CAAC;AAAA,EAClB,CAAC,iBAAiB,CAAC,CAAC;AAAA,EACpB,CAAC,gBAAgB,CAAC,CAAC;AAAA,EACnB,CAAC,0BAA0B,CAAC,CAAC;AAAA,EAC7B,CAAC,yBAAyB,CAAC,CAAC;AAC9B,CAAC;AACD,IAAI,gBAAwB;AAC5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