{"version":3,"file":"src-CH1H0YH7.mjs","names":[],"sources":["../src/core/lofi.ts","../src/core/resolve-url.ts","../src/core/sprite-data.ts","../src/utils.ts","../src/core/variants.ts","../src/core/player.ts","../src/index.ts"],"sourcesContent":["import type { Howl } from 'howler';\nimport type { LofiOptions } from './types';\n\nexport const DEFAULT_LOFI_OPTIONS: Required<LofiOptions> = {\n  bits: 4,\n  downsample: 0.25,\n};\n\nconst PROCESSOR_NAME = 'button-sounds-bitcrusher';\n\n// Classic sample-and-hold bitcrusher, as an AudioWorkletProcessor. Loaded via a blob URL so the package doesn’t ship a separate worklet file.\nconst PROCESSOR_SOURCE = `\nclass BitcrusherProcessor extends AudioWorkletProcessor {\n  constructor() {\n    super();\n    this.phase = 0;\n    this.last = [];\n  }\n\n  static get parameterDescriptors() {\n    return [\n      { name: 'bits', defaultValue: 4, minValue: 1, maxValue: 16, automationRate: 'k-rate' },\n      { name: 'downsample', defaultValue: 0.25, minValue: 0, maxValue: 1, automationRate: 'k-rate' },\n    ];\n  }\n\n  process(inputs, outputs, parameters) {\n    const input = inputs[0];\n    const output = outputs[0];\n    if (!input || !input.length || !output || !output.length) {\n      return true;\n    }\n\n    const bits = parameters.bits[0];\n    const downsample = parameters.downsample[0];\n    const step = Math.pow(0.5, bits);\n    const frames = output[0].length;\n\n    for (let i = 0; i < frames; i++) {\n      this.phase += downsample;\n      const take = this.phase >= 1;\n      if (take) {\n        this.phase -= 1;\n      }\n\n      for (let ch = 0; ch < output.length; ch++) {\n        const inputChannel = input[ch] || input[0];\n        if (take) {\n          const sample = inputChannel ? inputChannel[i] : 0;\n          this.last[ch] = step * Math.floor(sample / step + 0.5);\n        }\n        output[ch][i] = this.last[ch] ?? 0;\n      }\n    }\n\n    return true;\n  }\n}\n\nregisterProcessor('${PROCESSOR_NAME}', BitcrusherProcessor);\n`;\n\nconst workletLoads = new WeakMap<AudioContext, Promise<void>>();\n\ntype HowlGainNode = GainNode & {\n  bufferSource?: AudioBufferSourceNode;\n};\n\ninterface HowlSound {\n  _node: HowlGainNode;\n}\n\ntype HowlWithInternals = Howl & {\n  _soundById: (id: number) => HowlSound | null;\n};\n\nfunction clamp(value: number, min: number, max: number): number {\n  return Math.min(max, Math.max(min, value));\n}\n\n// Fill in defaults and clamp to the documented ranges.\nexport function resolveLofiOptions(\n  options: LofiOptions = {},\n): Required<LofiOptions> {\n  return {\n    bits: clamp(Math.round(options.bits ?? DEFAULT_LOFI_OPTIONS.bits), 1, 16),\n    downsample: clamp(\n      options.downsample ?? DEFAULT_LOFI_OPTIONS.downsample,\n      0,\n      1,\n    ),\n  };\n}\n\nfunction loadWorklet(ctx: AudioContext): Promise<void> {\n  const blob = new Blob([PROCESSOR_SOURCE], { type: 'text/javascript' });\n  const url = URL.createObjectURL(blob);\n  return ctx.audioWorklet\n    .addModule(url)\n    .catch(() => {\n      // Already registered by another copy of the library, or blocked (CSP). Creating the node will tell us which.\n    })\n    .finally(() => {\n      URL.revokeObjectURL(url);\n    });\n}\n\n// Register the bitcrusher worklet on this AudioContext (no-op if AudioWorklet isn’t available). Safe to call more than once.\nexport function prepareLofi(ctx: AudioContext | undefined): Promise<void> {\n  if (!ctx?.audioWorklet) return Promise.resolve();\n\n  let pending = workletLoads.get(ctx);\n  if (!pending) {\n    pending = loadWorklet(ctx);\n    workletLoads.set(ctx, pending);\n  }\n  return pending;\n}\n\n// We use AudioWorklet by default, which has been supported by all major browsers since 2020, but AudioWorklet also only works in HTTPS and can be disabled with strict CSPs. So, we use ScriptProcessorNode as a fallback option, which requires silencing ESLint.\n/* eslint-disable @typescript-eslint/no-deprecated */\nfunction createScriptBitcrusher(\n  ctx: AudioContext,\n  options: Required<LofiOptions>,\n): AudioNode | null {\n  if (typeof ctx.createScriptProcessor !== 'function') return null;\n\n  // Small buffer so a ~200ms click doesn’t pick up a huge slug of extra latency.\n  const node = ctx.createScriptProcessor(256, 2, 2);\n  let phase = 0;\n  const last: Array<number> = [];\n  const step = Math.pow(0.5, options.bits);\n  const { downsample } = options;\n\n  node.onaudioprocess = (event) => {\n    const input = event.inputBuffer;\n    const output = event.outputBuffer;\n    const frames = output.length;\n    const channels = output.numberOfChannels;\n\n    for (let i = 0; i < frames; i++) {\n      phase += downsample;\n      const take = phase >= 1;\n      if (take) {\n        phase -= 1;\n      }\n\n      for (let ch = 0; ch < channels; ch++) {\n        const inputData = input.getChannelData(\n          Math.min(ch, input.numberOfChannels - 1),\n        );\n        const outputData = output.getChannelData(ch);\n        if (take) {\n          last[ch] = step * Math.floor((inputData[i] ?? 0) / step + 0.5);\n        }\n        outputData[i] = last[ch] ?? 0;\n      }\n    }\n  };\n\n  return node;\n}\n/* eslint-enable @typescript-eslint/no-deprecated */\n\nfunction createBitcrusher(\n  ctx: AudioContext,\n  options: Required<LofiOptions>,\n): AudioNode | null {\n  if (typeof ctx.audioWorklet !== 'undefined') {\n    try {\n      const node = new AudioWorkletNode(ctx, PROCESSOR_NAME, {\n        numberOfInputs: 1,\n        numberOfOutputs: 1,\n        outputChannelCount: [2],\n      });\n      node.parameters\n        .get('bits')\n        ?.setValueAtTime(options.bits, ctx.currentTime);\n      node.parameters\n        .get('downsample')\n        ?.setValueAtTime(options.downsample, ctx.currentTime);\n      return node;\n    } catch {\n      // Worklet never registered; fall through to ScriptProcessor.\n    }\n  }\n\n  return createScriptBitcrusher(ctx, options);\n}\n\nfunction getSound(howl: Howl, soundId: number): HowlSound | null {\n  return (howl as HowlWithInternals)._soundById(soundId);\n}\n\nfunction insertBitcrusher(\n  ctx: AudioContext,\n  howl: Howl,\n  soundId: number,\n  options: Required<LofiOptions>,\n): void {\n  const sound = getSound(howl, soundId);\n  const source = sound?._node.bufferSource;\n  if (!sound || !source) return;\n\n  const crusher = createBitcrusher(ctx, options);\n  if (!crusher) return;\n\n  // Howler’s graph is bufferSource → gain → masterGain. Splice the bitcrusher in between source and gain so volume/rate still apply on the way out.\n  source.disconnect();\n  source.connect(crusher);\n  crusher.connect(sound._node);\n\n  let cleaned = false;\n  const cleanup = () => {\n    if (cleaned) return;\n    cleaned = true;\n    try {\n      crusher.disconnect();\n    } catch {\n      // Howler may already have torn this node down.\n    }\n  };\n\n  howl.once('end', cleanup, soundId);\n  howl.once('stop', cleanup, soundId);\n}\n\n// Route one playing Howl sound through a bitcrusher. If the buffer source isn’t up yet (AudioContext still unlocking), wait for Howler’s play event.\nexport function applyLofi(\n  ctx: AudioContext,\n  howl: Howl,\n  soundId: number,\n  options: Required<LofiOptions>,\n): void {\n  if (getSound(howl, soundId)?._node.bufferSource) {\n    insertBitcrusher(ctx, howl, soundId, options);\n    return;\n  }\n\n  howl.once(\n    'play',\n    () => {\n      insertBitcrusher(ctx, howl, soundId, options);\n    },\n    soundId,\n  );\n}\n","// Resolves the URL a sound’s audio file is loaded from.\n//\n// By default, files are served from the free jsDelivr CDN, pinned to this package's exact published version — so you don't have to host anything, and the audio always matches the installed code. The version is injected at build time (see `define` in tsdown.config.ts); when running unbundled (e.g. tests) it falls back to `latest`.\n//\n// Consumers who prefer to self-host (privacy, offline, or avoiding a runtime third-party request) can pass their own baseUrl — see the copy CLI.\n\ndeclare const __BUTTON_SOUNDS_VERSION__: string | undefined;\n\nconst VERSION =\n  typeof __BUTTON_SOUNDS_VERSION__ !== 'undefined'\n    ? __BUTTON_SOUNDS_VERSION__\n    : 'latest';\n\n// Default location sound files are loaded from: the jsDelivr CDN.\nexport const DEFAULT_BASE_URL = `https://cdn.jsdelivr.net/npm/button-sounds@${VERSION}/assets/`;\n\n// Build the URL for a sound’s .mp3 file. `name` is the sound name (e.g. 'uhk-soft'). `baseUrl` is where sounds are hosted, defaulting to DEFAULT_BASE_URL (jsDelivr); pass your own to self-host — for example '/sounds/' after copying the files into your static dir.\nexport function resolveSoundUrl(\n  name: string,\n  baseUrl: string = DEFAULT_BASE_URL,\n): string {\n  const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;\n  return `${base}${name}.mp3`;\n}\n","// All of the sounds in this project share the same sprite map. The only difference is that different sounds have a different # of included samples.\n// Here’s how to read this map: the first number is the timestamp for the start of the sample, in milliseconds. The second number is the duration, in milliseconds. For example, if I wanted to play the \"up3\" sample, I would need to start playback at 0:03.200 and run it for 790ms.\n\ntype SpriteMap = Record<string, [number, number]>;\n\nconst SHARED_SPRITE_MAP = {\n  down1: [1000, 190],\n  up1: [1200, 790],\n  down2: [2000, 190],\n  up2: [2200, 790],\n  down3: [3000, 190],\n  up3: [3200, 790],\n  down4: [4000, 190],\n  up4: [4200, 790],\n  down5: [5000, 190],\n  up5: [5200, 790],\n  down6: [6000, 190],\n  up6: [6200, 790],\n  down7: [7000, 190],\n  up7: [7200, 790],\n  down8: [8000, 190],\n  up8: [8200, 790],\n} satisfies SpriteMap;\n\n// Each sound has between 4-8 pairs of samples. We’ll pluck the correct number of up/down pairs based on the number provided.\nfunction getSubsetOfData(numOfSamples: number): SpriteMap {\n  return Object.fromEntries(\n    Object.entries(SHARED_SPRITE_MAP).slice(\n      0,\n      // Multiplied by 2 since each sample has both up + down:\n      numOfSamples * 2,\n    ),\n  ) satisfies SpriteMap;\n}\n\nexport const SPRITE_DATA = {\n  'asus-kbd-hard': getSubsetOfData(5),\n  'asus-kbd-medium': getSubsetOfData(6),\n  'asus-kbd-soft': getSubsetOfData(8),\n  'asus-kbd-space': getSubsetOfData(6),\n  'asus-mouse': getSubsetOfData(7),\n  'camera-latch': getSubsetOfData(5),\n  'carson-microflip': getSubsetOfData(5),\n  'ergo-mx': getSubsetOfData(6),\n  'guitar-toggle-off': getSubsetOfData(6),\n  'guitar-toggle-on': getSubsetOfData(6),\n  'halo-hard': getSubsetOfData(6),\n  'halo-shift': getSubsetOfData(7),\n  'halo-soft': getSubsetOfData(6),\n  'halo-space': getSubsetOfData(7),\n  'heated-blanket': getSubsetOfData(7),\n  'hi75-hard': getSubsetOfData(6),\n  'hi75-knob': getSubsetOfData(8),\n  'hi75-medium': getSubsetOfData(8),\n  'hi75-soft': getSubsetOfData(7),\n  'hi75-space': getSubsetOfData(6),\n  iidx: getSubsetOfData(4),\n  'kvm-switch': getSubsetOfData(5),\n  'led-blacklight': getSubsetOfData(4),\n  'lock-closed': getSubsetOfData(5),\n  'lock-open': getSubsetOfData(6),\n  'low-thumps': getSubsetOfData(6),\n  'mx-master-3': getSubsetOfData(4),\n  'popper-dice': getSubsetOfData(5),\n  'popper-empty': getSubsetOfData(5),\n  'ps4-clicky': getSubsetOfData(7),\n  'ps4-double': getSubsetOfData(8),\n  'ps4-dull': getSubsetOfData(7),\n  'ps4-paddle': getSubsetOfData(6),\n  'ps4-snappy': getSubsetOfData(8),\n  'raddy-high': getSubsetOfData(6),\n  'raddy-low': getSubsetOfData(5),\n  'raddy-medium': getSubsetOfData(6),\n  'rival-3': getSubsetOfData(7),\n  'rival-3-middle': getSubsetOfData(6),\n  'sd-clicky': getSubsetOfData(4),\n  'sd-distorted': getSubsetOfData(5),\n  'sd-metallic': getSubsetOfData(7),\n  'sd-resonant': getSubsetOfData(6),\n  'sd-squelchy': getSubsetOfData(6),\n  'sd-standard': getSubsetOfData(7),\n  'synth-off': getSubsetOfData(8),\n  'synth-on': getSubsetOfData(8),\n  'tonal-off': getSubsetOfData(4),\n  'tonal-on': getSubsetOfData(4),\n  'treadmill-flinty': getSubsetOfData(4),\n  'treadmill-pitched': getSubsetOfData(4),\n  'treadmill-sharp': getSubsetOfData(4),\n  'uhk-medium': getSubsetOfData(7),\n  'uhk-soft': getSubsetOfData(6),\n  'uhk-space': getSubsetOfData(4),\n} satisfies Record<string, SpriteMap>;\n\n// The name of a sound that has authored sprite data.\nexport type SoundName = keyof typeof SPRITE_DATA;\n\n// Every selectable sound name.\nexport const SOUND_NAMES = Object.keys(SPRITE_DATA) as Array<SoundName>;\n// The name used when none is specified.\nexport const DEFAULT_NAME: SoundName = 'uhk-soft';\n","export const range = (start: number, end?: number, step = 1) => {\n  const output = [];\n  if (typeof end === 'undefined') {\n    end = start;\n    start = 0;\n  }\n  for (let i = start; i < end; i += step) {\n    output.push(i);\n  }\n  return output;\n};\n\nexport function sampleOne<T>(arr: ReadonlyArray<T>): T {\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- The index is always within bounds.\n  return arr[Math.floor(Math.random() * arr.length)]!;\n}\n\nexport function sample<T>(arr: Array<T>, len = 1): Array<T> {\n  const output = [];\n\n  for (let i = 0; i < len; i++) {\n    output.push(sampleOne(arr));\n  }\n\n  return output;\n}\n\nexport const random = (\n  min: number,\n  max: number,\n  { rounded }: { rounded: boolean } = { rounded: true },\n) => {\n  const partialVal = Math.random() * (max - min);\n\n  if (rounded) {\n    return Math.floor(partialVal) + min;\n  } else {\n    return partialVal + min;\n  }\n};\n","import type { SoundVariant } from './types';\nimport { sampleOne } from '../utils';\n\ntype SpriteMap = Record<string, [number, number]>;\n\nconst trailingNumber = (id: string): number =>\n  Number(/\\d+$/.exec(id)?.[0] ?? 0);\n\n// The sprite sample ids for a given variant, ordered by their trailing number (down1, down2, … for a press; up1, up2, … for a release).\nexport function getVariantIds(\n  spriteMap: SpriteMap,\n  variant: SoundVariant,\n): Array<string> {\n  const prefix = variant === 'press' ? 'down' : 'up';\n  return Object.keys(spriteMap)\n    .filter((id) => id.startsWith(prefix))\n    .sort((a, b) => trailingNumber(a) - trailingNumber(b));\n}\n\n// Choose which sample to play. Random by default; pass sampleIndex to pick a specific one (0-based, wraps around). Returns undefined if the sound has no samples for the variant.\nexport function pickSampleId(\n  spriteMap: SpriteMap,\n  variant: SoundVariant,\n  sampleIndex?: number,\n): string | undefined {\n  const ids = getVariantIds(spriteMap, variant);\n  if (ids.length === 0) return undefined;\n\n  if (typeof sampleIndex === 'number') {\n    // Wrap so any integer maps to a valid sample.\n    const wrapped = ((sampleIndex % ids.length) + ids.length) % ids.length;\n    return ids[wrapped];\n  }\n\n  return sampleOne(ids);\n}\n","import type { Howl } from 'howler';\nimport { applyLofi, prepareLofi, resolveLofiOptions } from './lofi';\nimport { resolveSoundUrl } from './resolve-url';\nimport { SPRITE_DATA } from './sprite-data';\nimport type { SoundName } from './sprite-data';\nimport type { SoundVariant, TriggerOptions } from './types';\nimport { pickSampleId } from './variants';\n\n// Playback engine, built on howler (loaded lazily on first use — load(), wireUp(), or playback — so this module is safe to import during SSR). Shared by the vanilla API and the React hooks.\n\nlet currentPath: string | undefined;\n\n// `name` is typed, but plain-JS callers can pass anything.\nfunction isKnownSound(name: string): boolean {\n  return Object.hasOwn(SPRITE_DATA, name);\n}\n\n// Override where sound files load from (defaults to the jsDelivr CDN).\nexport function setPath(path: string): void {\n  currentPath = path;\n}\n\n// The current base path, or undefined when using the default CDN.\nexport function getPath(): string | undefined {\n  return currentPath;\n}\n\n// Start downloading a sound’s audio file so the first press or release isn’t waiting on the network. Safe to call more than once; each name is only fetched once for the current setPath.\n// Example: load('uhk-soft');\nexport function load(name: SoundName): void {\n  if (!isKnownSound(name)) {\n    console.warn(`[button-sounds] Unknown sound name: \"${name}\"`);\n    return;\n  }\n\n  void loadHowl(name).catch(() => {\n    // Sound is progressive enhancement — a failed fetch (offline, CDN hiccup) should not surface as an unhandled rejection.\n  });\n}\n\nconst howlCache = new Map<string, Promise<Howl>>();\n\nfunction loadHowl(name: SoundName): Promise<Howl> {\n  const key = `${name}::${currentPath ?? ''}`;\n  let howl = howlCache.get(key);\n\n  if (!howl) {\n    howl = import('howler').then(\n      ({ Howl }) =>\n        new Howl({\n          src: [resolveSoundUrl(name, currentPath)],\n          sprite: SPRITE_DATA[name],\n          format: ['mp3'],\n          html5: false,\n        }),\n    );\n    howlCache.set(key, howl);\n  }\n  return howl;\n}\n\n// Play a sample of the given variant from a named sound.\nexport function trigger(\n  variant: SoundVariant,\n  name: SoundName,\n  options: TriggerOptions = {},\n): void {\n  if (!isKnownSound(name)) {\n    console.warn(`[button-sounds] Unknown sound name: \"${name}\"`);\n    return;\n  }\n\n  const spriteMap = SPRITE_DATA[name];\n\n  const {\n    sampleIndex,\n    volume = 0.5,\n    playbackRate,\n    lofi,\n    lofiOptions,\n  } = options;\n  const id = pickSampleId(spriteMap, variant, sampleIndex);\n  if (!id) return;\n\n  const resolvedLofi = lofi ? resolveLofiOptions(lofiOptions) : null;\n\n  void loadHowl(name)\n    .then(async (howl) => {\n      // The bitcrusher is an AudioWorklet, so it has to be registered on Howler.ctx before we start playback — otherwise the first few milliseconds of a click would play clean.\n      let ctx: AudioContext | undefined;\n      if (resolvedLofi) {\n        const { Howler } = await import('howler');\n        ctx = Howler.ctx;\n        await prepareLofi(ctx);\n      }\n\n      const soundId = howl.play(id);\n      if (typeof volume === 'number') {\n        howl.volume(volume, soundId);\n      }\n      if (typeof playbackRate === 'number') {\n        howl.rate(playbackRate, soundId);\n      }\n      if (resolvedLofi && ctx) {\n        applyLofi(ctx, howl, soundId, resolvedLofi);\n      }\n    })\n    .catch(() => {\n      // Sound is progressive enhancement — never let a load/playback failure (offline, CDN hiccup, autoplay policy) surface as an unhandled rejection.\n    });\n}\n","import { load, setPath, trigger } from './core/player';\nimport type { SoundName } from './core/sprite-data';\nimport type { TriggerOptions, WireUpOptions } from './core/types';\nimport { random } from './utils';\n\nexport type {\n  SoundName,\n  SoundVariant,\n  TriggerOptions,\n  WireUpOptions,\n  LofiOptions,\n} from './core';\nexport {\n  SOUND_NAMES,\n  SPRITE_DATA,\n  DEFAULT_NAME,\n  DEFAULT_LOFI_OPTIONS,\n  resolveSoundUrl,\n  DEFAULT_BASE_URL,\n} from './core';\n\n// Play a “press” sound. Call from a pointerdown handler.\n// Example: button.addEventListener('pointerdown', () => press('uhk-soft'));\nexport function press(name: SoundName, options?: TriggerOptions): void {\n  trigger('press', name, options);\n}\n\n// Play a “release” sound. Call from a pointerup handler.\n// Example: button.addEventListener('pointerup', () => release('uhk-soft'));\nexport function release(name: SoundName, options?: TriggerOptions): void {\n  trigger('release', name, options);\n}\n\n// Resolve a pitchVariation setting into a concrete playbackRate.\nfunction pitchToRate(\n  pitchVariation: WireUpOptions['pitchVariation'],\n): number | undefined {\n  if (pitchVariation == null) return undefined;\n  const [min, max] = Array.isArray(pitchVariation)\n    ? pitchVariation\n    : [1 - pitchVariation, 1 + pitchVariation];\n  return random(min, max, { rounded: false });\n}\n\n// Wire press/release sounds onto an element. Plays a press sound on pointerdown, then plays a release sound on the next pointerup — listening on window (via { once: true }) so the release still fires even if the pointer has moved off the element.\n// The sound’s audio file starts loading immediately, so the first click isn’t waiting on the network.\n// Returns a cleanup function that removes the listeners.\n// Example:\n// const unwire = wireUp(button, 'uhk-soft', { pitchVariation: 0.3 });\n// later: unwire();\nexport function wireUp(\n  element: HTMLElement,\n  name: SoundName,\n  options: WireUpOptions = {},\n): () => void {\n  load(name);\n\n  const { volume, pitchVariation, lofi, lofiOptions } = options;\n  // lofi = true;\n\n  const pendingReleases = new Set<() => void>();\n\n  const handlePointerDown = (): void => {\n    press(name, {\n      volume,\n      playbackRate: pitchToRate(pitchVariation),\n      lofi,\n      lofiOptions,\n    });\n\n    const handlePointerUp = (): void => {\n      pendingReleases.delete(handlePointerUp);\n      release(name, {\n        volume,\n        playbackRate: pitchToRate(pitchVariation),\n        lofi,\n        lofiOptions,\n      });\n    };\n    pendingReleases.add(handlePointerUp);\n    window.addEventListener('pointerup', handlePointerUp, { once: true });\n  };\n\n  element.addEventListener('pointerdown', handlePointerDown);\n\n  return () => {\n    element.removeEventListener('pointerdown', handlePointerDown);\n    for (const handler of pendingReleases) {\n      window.removeEventListener('pointerup', handler);\n    }\n    pendingReleases.clear();\n  };\n}\n\n// The vanilla API, as a single namespace object.\nconst ButtonSounds = { setPath, load, press, release, wireUp };\n\n// press, release, and wireUp are already exported inline above; load and setPath are re-exported here from ./core/player.\nexport { load, setPath };\nexport default ButtonSounds;\n"],"mappings":";AAGA,MAAa,uBAA8C;CACzD,MAAM;CACN,YAAY;AACd;AAEA,MAAM,iBAAiB;AAGvB,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgDJ,eAAe;;AAGpC,MAAM,+BAAe,IAAI,QAAqC;AAc9D,SAAS,MAAM,OAAe,KAAa,KAAqB;C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