{"version":3,"sources":["jsdelivr-header.js","/npm/node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js","/npm/node_modules/.pnpm/@rgba-image+copy@0.1.3/node_modules/@rgba-image/copy/src/index.ts","/npm/node_modules/.pnpm/@rgba-image+create-image@0.1.1/node_modules/@rgba-image/create-image/src/index.ts","/npm/node_modules/.pnpm/@rgba-image+lanczos@0.1.1/node_modules/@rgba-image/lanczos/src/filters.ts","/npm/node_modules/.pnpm/@rgba-image+lanczos@0.1.1/node_modules/@rgba-image/lanczos/src/convolve.ts","/npm/node_modules/.pnpm/@rgba-image+lanczos@0.1.1/node_modules/@rgba-image/lanczos/src/index.ts","/npm/node_modules/.pnpm/token-types@6.0.0/node_modules/token-types/lib/index.js","/npm/node_modules/.pnpm/peek-readable@5.3.1/node_modules/peek-readable/lib/EndOfStreamError.js","/npm/node_modules/.pnpm/peek-readable@5.3.1/node_modules/peek-readable/lib/AbstractStreamReader.js","/npm/node_modules/.pnpm/peek-readable@5.3.1/node_modules/peek-readable/lib/WebStreamReader.js","/npm/node_modules/.pnpm/strtok3@9.0.1/node_modules/strtok3/lib/AbstractTokenizer.js","/npm/node_modules/.pnpm/strtok3@9.0.1/node_modules/strtok3/lib/ReadStreamTokenizer.js","/npm/node_modules/.pnpm/strtok3@9.0.1/node_modules/strtok3/lib/BufferTokenizer.js","/npm/node_modules/.pnpm/strtok3@9.0.1/node_modules/strtok3/lib/core.js","/npm/node_modules/.pnpm/uint8array-extras@1.4.0/node_modules/uint8array-extras/index.js","/npm/node_modules/.pnpm/file-type@19.6.0/node_modules/file-type/util.js","/npm/node_modules/.pnpm/file-type@19.6.0/node_modules/file-type/supported.js","/npm/node_modules/.pnpm/file-type@19.6.0/node_modules/file-type/core.js","/npm/@dotlottie/dotlottie-js@1.0.2/src/utils.ts","/npm/@dotlottie/dotlottie-js@1.0.2/package.json","/npm/@dotlottie/dotlottie-js@1.0.2/src/constants.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/schemas/manifest.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/schemas/state-machine.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/schemas/theme.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/state-machine.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/theme.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/dotlottie.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/animation.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/image.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/audio.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/audio.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/image.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/animation.ts","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/HashableImageSourceConverter/DifferenceHash/VanilaConverter.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/HashSource.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/HashableImageSourceConverter/Resizer/LanczosResizer.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/Hash.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/HashGenerator.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/HashableImageSourceConverter/GlayScaleCalculator/ITU_R601_2Method.js","/npm/node_modules/.pnpm/browser-image-hash@0.0.5/node_modules/browser-image-hash/dist/DifferenceHashBuilder.js","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/plugin.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/common/plugins/duplicate-image-detector.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/plugins/duplicate-image-detector.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/dotlottie.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/theme.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v2/browser/state-machine.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/dotlottie.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/schemas/manifest.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/animation.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/image.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/audio.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/browser/audio.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/browser/image.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/browser/animation.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/plugin.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/common/plugins/duplicate-image-detector.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/browser/plugins/duplicate-image-detector.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/v1/browser/dotlottie.ts","/npm/@dotlottie/dotlottie-js@1.0.2/src/index.browser.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,+hCCNA,gBAAA,WAAA,wEAAA,GACA,EAAQ,KAAO,SAAU,EAAQ,EAAQ,EAAM,EAAM,GACnD,IAAI,EAAG,EACH,EAAiB,EAAT,EAAc,EAAO,EAC7B,GAAQ,GAAK,GAAQ,EACrB,EAAQ,GAAQ,EAChB,GAAQ,EACR,EAAI,EAAQ,EAAS,EAAK,EAC1B,EAAI,GAAY,IAChB,EAAI,EAAO,EAAS,GAOxB,IALK,GAAA,EAED,EAAA,GAAM,IAAO,GAAU,EAC3B,KAAQ,EACC,GAAA,EACF,EAAQ,EAAG,EAAS,IAAJ,EAAW,EAAO,EAAS,GAAI,GAAK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M,EAAU,OAAO,SAAS,IAAI,WAAW,GAAG,IAAI,EAAa,KAAK,QAAQ,QAAS,IAAI,OAAQ,GACjG,GAAA,OAAO,MAAM,GACT,SAGR,IAAI,EAAM,IAEV,QAAS,EAAQ,EAAQ,EAAQ,EAAS,IAAK,IAC9C,GAAO,EAAY,GAGpB,QAAS,EAAQ,EAAS,IAAK,EAAQ,EAAS,IAAK,IACpD,GAAO,EAAY,GAGpB,OAAO,IAAY,CACpB,CDkFO,IAAI,WAAW,YAAY,QAeZ,IAAI,WAAW,YAqDR,MAAM,KAAK,CAAC,OAAQ,MAAM,CAAC,EAAG,IAAU,EAAM,SAAS,IAAI,SAAS,EAAG,OChJ7F,IAAM,oBAAsB,CAClC,IAAK,CAAC,EAAQ,IAAiC,IAArB,EAAO,EAAS,GAAe,EAAO,EAAS,IAAO,EAAO,EAAO,EAAS,IAAO,GAAQ,EAAO,IAAY,GACzI,IAAK,GCtCO,WAAa,CACzB,MACA,MACA,OACA,MACA,OACA,OACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,OACA,MACA,MACA,OACA,MACA,MACA,MACA,KACA,MACA,KACA,MACA,MACA,MACA,MACA,OACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,OACA,OACA,MACA,MACA,MACA,MACA,OACA,MACA,QACA,MACA,MACA,MACA,OACA,OACA,QACA,MACA,MACA,MACA,MACA,MACA,KACA,KACA,SACA,MACA,MACA,MACA,MACA,MACA,KACA,MACA,IACA,KACA,MACA,MACA,MACA,QACA,MACA,OACA,OACA,OACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,OACA,OACA,MACA,MACA,MACA,KACA,MACA,MACA,MACA,OACA,MACA,MACA,QACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,QACA,MACA,MACA,MACA,KACA,MACA,KACA,KACA,MACA,OACA,MACA,MACA,MACA,OACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,UACA,QACA,MACA,OACA,MACA,OACA,MACA,MACA,OACA,MACA,OAGY,UAAY,CACxB,aACA,YACA,YACA,aACA,aACA,cACA,oBACA,oBACA,aACA,YACA,qBACA,4BACA,yBACA,uBACA,0BACA,0CACA,iDACA,kDACA,0EACA,4EACA,oEACA,kBACA,oBACA,+BACA,mBACA,sBACA,8BACA,gCACA,6BACA,YACA,aACA,mBACA,aACA,kBACA,gBACA,YACA,cACA,iBACA,iBACA,yBACA,aACA,aACA,aACA,YACA,YACA,YACA,yBACA,kBACA,eACA,YACA,gBACA,YACA,kBACA,oBACA,4BACA,2BACA,gCACA,kBACA,mBACA,YACA,aACA,gCACA,WACA,WACA,eACA,cACA,yBACA,kBACA,mBACA,wBACA,iCACA,wCACA,oCACA,oBACA,6BACA,oBACA,yBACA,qBACA,oBACA,oBACA,kBACA,aACA,wBACA,YACA,YACA,YACA,YACA,YACA,YACA,aACA,kBACA,iCACA,aACA,sBACA,aACA,sBACA,aACA,YACA,oBACA,mBACA,gBACA,aACA,WACA,oBACA,+BACA,cACA,4BACA,4BACA,cACA,yBACA,cACA,aACA,sBACA,mBACA,oBACA,oBACA,wBACA,uBACA,cACA,cACA,2BACA,YACA,aACA,cACA,aACA,aACA,aACA,+BACA,aACA,+BACA,4BACA,qBACA,YACA,8BACA,YACA,YACA,mBACA,YACA,6BACA,gBACA,wBACA,sBACA,oBACA,qBACA,+BACA,mBACA,6BACA,6BACA,wBACA,2CCtSY,+BAAiC,KAM9C,eAAsB,mBAAmB,GACxC,OAAO,IAAI,gBAAiB,WAAW,EACxC,CAMA,SAAS,OAAO,EAAQ,EAAS,GACtB,EAAA,CACT,OAAQ,KACL,GAGJ,UAAY,EAAO,KAAW,EAAQ,UAErC,GAAI,EAAQ,MAEP,GAAA,KAAY,EAAQ,KAAK,GAAS,EAAO,EAAQ,EAAQ,SACrD,cACR,GACU,IAAW,EAAO,EAAQ,EAA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ACP,GAAI,aAAe,MACjB,MAAM,IAAI,eAAe,mCAAmC,EAAI,UAClE,CAKJ,OACO,GACP,GAAI,aAAe,MACX,UAAI,eAAe,EAAI,QAC/B,CAGK,OAAA,CAAA,GC3UJ,SAAS,cACd,EACA,GAEA,MAAgB,OAAZ,EACK,IAAI,YAAY,GAGlB,IAAI,UAAU,EACvB","file":"/npm/@dotlottie/dotlottie-js@1.0.2/dist/index.browser.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/@dotlottie/dotlottie-js@1.0.2/dist/index.browser.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n  var e, m\n  var eLen = (nBytes * 8) - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var nBits = -7\n  var i = isLE ? (nBytes - 1) : 0\n  var d = isLE ? -1 : 1\n  var s = buffer[offset + i]\n\n  i += d\n\n  e = s & ((1 << (-nBits)) - 1)\n  s >>= (-nBits)\n  nBits += eLen\n  for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n  m = e & ((1 << (-nBits)) - 1)\n  e >>= (-nBits)\n  nBits += mLen\n  for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n  if (e === 0) {\n    e = 1 - eBias\n  } else if (e === eMax) {\n    return m ? NaN : ((s ? -1 : 1) * Infinity)\n  } else {\n    m = m + Math.pow(2, mLen)\n    e = e - eBias\n  }\n  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n  var e, m, c\n  var eLen = (nBytes * 8) - mLen - 1\n  var eMax = (1 << eLen) - 1\n  var eBias = eMax >> 1\n  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n  var i = isLE ? 0 : (nBytes - 1)\n  var d = isLE ? 1 : -1\n  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n  value = Math.abs(value)\n\n  if (isNaN(value) || value === Infinity) {\n    m = isNaN(value) ? 1 : 0\n    e = eMax\n  } else {\n    e = Math.floor(Math.log(value) / Math.LN2)\n    if (value * (c = Math.pow(2, -e)) < 1) {\n      e--\n      c *= 2\n    }\n    if (e + eBias >= 1) {\n      value += rt / c\n    } else {\n      value += rt * Math.pow(2, 1 - eBias)\n    }\n    if (value * c >= 2) {\n      e++\n      c /= 2\n    }\n\n    if (e + eBias >= eMax) {\n      m = 0\n      e = eMax\n    } else if (e + eBias >= 1) {\n      m = ((value * c) - 1) * Math.pow(2, mLen)\n      e = e + eBias\n    } else {\n      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n      e = 0\n    }\n  }\n\n  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n  e = (e << mLen) | m\n  eLen += mLen\n  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n  buffer[offset + i - d] |= s * 128\n}\n","import { SourceToDest } from '@rgba-image/common'\r\n\r\nexport const copy: SourceToDest = ( \r\n  source: ImageData, dest: ImageData, \r\n  sx = 0, sy = 0, sw = source.width - sx, sh = source.height - sy, \r\n  dx = 0, dy = 0 \r\n) => {\r\n  sx = sx | 0\r\n  sy = sy | 0\r\n  sw = sw | 0\r\n  sh = sh | 0\r\n  dx = dx | 0\r\n  dy = dy | 0\r\n\r\n  if( sw <= 0 || sh <= 0 ) return\r\n\r\n  const sourceData = new Uint32Array( source.data.buffer )\r\n  const destData = new Uint32Array( dest.data.buffer )\r\n\r\n  for ( let y = 0; y < sh; y++ ) {\r\n    const sourceY = sy + y\r\n\r\n    if( sourceY < 0 || sourceY >= source.height ) continue\r\n\r\n    const destY = dy + y\r\n\r\n    if( destY < 0 || destY >= dest.height ) continue\r\n\r\n    for ( let x = 0; x < sw; x++ ) {\r\n      const sourceX = sx + x\r\n\r\n      if( sourceX < 0 || sourceX >= source.width ) continue\r\n\r\n      const destX = dx + x\r\n\r\n      if ( destX < 0 || destX >= dest.width ) continue\r\n\r\n      const sourceIndex = sourceY * source.width + sourceX\r\n      const destIndex = destY * dest.width + destX\r\n\r\n      destData[ destIndex ] = sourceData[ sourceIndex ]\r\n    }\r\n  }\r\n}\r\n","import { CreateImage } from '@rgba-image/common'\n\nexport const CreateImageFactory = ( fill: number[] | Uint8ClampedArray = [ 0, 0, 0, 0 ], channels = 4 ) => {\n  channels = Math.floor( channels )\n\n  if( isNaN( channels ) || channels < 1 ){\n    throw TypeError( 'channels should be a positive non-zero number' )\n  }\n\n  if ( !( 'length' in fill ) || fill.length < channels ){\n    throw TypeError( `fill should be iterable with at least ${ channels } members` )\n  }\n\n  fill = ( new Uint8ClampedArray( fill ) ).slice( 0, channels )\n\n  const allZero = fill.every( v => v === 0 )\n\n  const createImage: CreateImage = ( width: number, height: number, data?: Uint8ClampedArray ) => {\n    if ( width === undefined || height === undefined ) {\n      throw TypeError( 'Not enough arguments' )\n    }\n\n    width = Math.floor( width )\n    height = Math.floor( height )\n\n    if ( isNaN( width ) || width < 1 || isNaN( height ) || height < 1 ) {\n      throw TypeError( 'Index or size is negative or greater than the allowed amount' )\n    }\n\n    const length = width * height * channels\n\n    if ( data === undefined ) {\n      data = new Uint8ClampedArray( length )\n    }\n\n    if ( data instanceof Uint8ClampedArray ) {\n      if ( data.length !== length ) {\n        throw TypeError( 'Index or size is negative or greater than the allowed amount' )\n      }\n\n      if ( !allZero ) {\n        for ( let y = 0; y < height; y++ ) {\n          for ( let x = 0; x < width; x++ ) {\n            const index = ( y * width + x ) * channels\n\n            for ( let c = 0; c < channels; c++ ) {\n              data[ index + c ] = fill[ c ]\n            }\n          }\n        }\n      }\n\n      return <ImageData>{\n        get width() { return width },\n        get height() { return height },\n        get data() { return data }\n      }\n    }\n\n    throw TypeError( 'Expected data to be Uint8ClampedArray or undefined' )\n  }\n\n  return createImage\n}\n\nexport const createImage = CreateImageFactory()\n","const fixedFracBits = 14\r\n\r\nconst filterValue = ( x: number, a: 2 | 3 ) => {\r\n  if ( x <= -a || x >= a ) return 0\r\n  if ( x == 0 ) return 0\r\n\r\n  // appears to do nothing?\r\n  // if ( x > -1.19209290e-07 && x < 1.19209290e-07 ) return 1\r\n\r\n  const xPi = x * Math.PI\r\n\r\n  return ( Math.sin( xPi ) / xPi ) * Math.sin( xPi / a ) / ( xPi / a )\r\n}\r\n\r\nconst toFixedPoint = ( value: number ) =>\r\n  Math.round( value * ( ( 1 << fixedFracBits ) - 1 ) )\r\n\r\nexport const filters = ( \r\n  srcSize: number, destSize: number, \r\n  scale: number, offset: number, \r\n  use2: boolean \r\n) => {\r\n  const a = use2 ? 2 : 3\r\n  const scaleInverted = 1 / scale\r\n  const scaleClamped = Math.min( 1, scale ) // For upscale\r\n\r\n  // Filter window (averaging interval), scaled to src image\r\n  const srcWindow = a / scaleClamped\r\n\r\n  const maxFilterElementSize = Math.floor( ( srcWindow + 1 ) * 2 )\r\n  const packedFilter = new Int16Array( ( maxFilterElementSize + 2 ) * destSize )\r\n  \r\n  let packedFilterPtr = 0\r\n\r\n  // For each destination pixel calculate source range and built filter values\r\n  for ( let destPixel = 0; destPixel < destSize; destPixel++ ) {\r\n\r\n    // Scaling should be done relative to central pixel point\r\n    const sourcePixel = ( destPixel + 0.5 ) * scaleInverted + offset\r\n    const sourceFirst = Math.max( 0, Math.floor( sourcePixel - srcWindow ) )\r\n    const sourceLast = Math.min( srcSize - 1, Math.ceil( sourcePixel + srcWindow ) )\r\n\r\n    const filterElementSize = sourceLast - sourceFirst + 1\r\n    const floatFilter = new Float32Array( filterElementSize )\r\n    const fxpFilter = new Int16Array( filterElementSize )\r\n\r\n    let total = 0\r\n\r\n    // Fill filter values for calculated range\r\n    let index = 0\r\n    for ( let pixel = sourceFirst; pixel <= sourceLast; pixel++ ) {\r\n      const floatValue = filterValue( ( ( pixel + 0.5 ) - sourcePixel ) * scaleClamped, a )\r\n\r\n      total += floatValue\r\n      floatFilter[ index ] = floatValue\r\n\r\n      index++\r\n    }\r\n\r\n    // Normalize filter, convert to fixed point and accumulate conversion error\r\n    let filterTotal = 0\r\n\r\n    for ( let index = 0; index < floatFilter.length; index++ ) {\r\n      const filterValue = floatFilter[ index ] / total\r\n\r\n      filterTotal += filterValue\r\n      fxpFilter[ index ] = toFixedPoint( filterValue )\r\n    }\r\n\r\n    // Compensate normalization error, to minimize brightness drift\r\n    fxpFilter[ destSize >> 1 ] += toFixedPoint( 1 - filterTotal )\r\n\r\n    //\r\n    // Now pack filter to useable form\r\n    //\r\n    // 1. Trim heading and tailing zero values, and compensate shitf/length\r\n    // 2. Put all to single array in this format:\r\n    //\r\n    //    [ pos shift, data length, value1, value2, value3, ... ]\r\n    //\r\n    let leftNotEmpty = 0\r\n    while ( leftNotEmpty < fxpFilter.length && fxpFilter[ leftNotEmpty ] === 0 ) {\r\n      leftNotEmpty++\r\n    }\r\n\r\n    let rightNotEmpty = fxpFilter.length - 1\r\n    while ( rightNotEmpty > 0 && fxpFilter[ rightNotEmpty ] === 0 ) {\r\n      rightNotEmpty--\r\n    }\r\n\r\n    const filterShift = sourceFirst + leftNotEmpty\r\n    const filterSize = rightNotEmpty - leftNotEmpty + 1\r\n\r\n    packedFilter[ packedFilterPtr++ ] = filterShift // shift\r\n    packedFilter[ packedFilterPtr++ ] = filterSize // size\r\n\r\n    packedFilter.set( fxpFilter.subarray( leftNotEmpty, rightNotEmpty + 1 ), packedFilterPtr )\r\n    packedFilterPtr += filterSize\r\n  }\r\n\r\n  return packedFilter\r\n}\r\n\r\n/*\r\n  Adapted to typescript from pica: https://github.com/nodeca/pica\r\n\r\n  (The MIT License)\r\n\r\n  Copyright (C) 2014-2017 by Vitaly Puzrin\r\n\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n  of this software and associated documentation files (the \"Software\"), to deal\r\n  in the Software without restriction, including without limitation the rights\r\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n  copies of the Software, and to permit persons to whom the Software is\r\n  furnished to do so, subject to the following conditions:\r\n\r\n  The above copyright notice and this permission notice shall be included in\r\n  all copies or substantial portions of the Software.\r\n\r\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n  THE SOFTWARE.\r\n*/\r\n","const fixedFracBits = 14\r\n\r\nexport const convolve = ( \r\n  source: Uint8ClampedArray, dest: Uint8ClampedArray, \r\n  sw: number, sh: number, dw: number, \r\n  filters: Int16Array \r\n) => {\r\n  let srcOffset = 0\r\n  let destOffset = 0\r\n\r\n  // For each row\r\n  for ( let sourceY = 0; sourceY < sh; sourceY++ ) {\r\n    let filterPtr = 0\r\n\r\n    // Apply precomputed filters to each destination row point\r\n    for ( let destX = 0; destX < dw; destX++ ) {\r\n      // Get the filter that determines the current output pixel.\r\n      const filterShift = filters[ filterPtr++ ]\r\n\r\n      let srcPtr = ( srcOffset + ( filterShift * 4 ) ) | 0\r\n\r\n      let r = 0\r\n      let g = 0\r\n      let b = 0\r\n      let a = 0\r\n\r\n      // Apply the filter to the row to get the destination pixel r, g, b, a\r\n      for ( \r\n        let filterSize = filters[ filterPtr++ ]; filterSize > 0; filterSize-- \r\n      ) {\r\n        const filterValue = filters[ filterPtr++ ]\r\n\r\n        r = ( r + filterValue * source[ srcPtr ] ) | 0\r\n        g = ( g + filterValue * source[ srcPtr + 1 ] ) | 0\r\n        b = ( b + filterValue * source[ srcPtr + 2 ] ) | 0\r\n        a = ( a + filterValue * source[ srcPtr + 3 ] ) | 0\r\n\r\n        srcPtr = ( srcPtr + 4 ) | 0\r\n      }\r\n\r\n      // Bring this value back in range. All of the filter scaling factors\r\n      // are in fixed point with fixedFracBits bits of fractional part.\r\n      //\r\n      // (!) Add 1/2 of value before clamping to get proper rounding. In other\r\n      // case brightness loss will be noticeable if you resize image with white\r\n      // border and place it on white background.\r\n      //\r\n      dest[ destOffset ] = ( r + ( 1 << 13 ) ) >> fixedFracBits\r\n      dest[ destOffset + 1 ] = ( g + ( 1 << 13 ) ) >> fixedFracBits\r\n      dest[ destOffset + 2 ] = ( b + ( 1 << 13 ) ) >> fixedFracBits\r\n      dest[ destOffset + 3 ] = ( a + ( 1 << 13 ) ) >> fixedFracBits\r\n\r\n      destOffset = ( destOffset + sh * 4 ) | 0\r\n    }\r\n\r\n    destOffset = ( ( sourceY + 1 ) * 4 ) | 0\r\n    srcOffset = ( ( sourceY + 1 ) * sw * 4 ) | 0\r\n  }\r\n}\r\n\r\n/*\r\n  Adapted to typescript from pica: https://github.com/nodeca/pica\r\n\r\n  (The MIT License)\r\n\r\n  Copyright (C) 2014-2017 by Vitaly Puzrin\r\n\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy\r\n  of this software and associated documentation files (the \"Software\"), to deal\r\n  in the Software without restriction, including without limitation the rights\r\n  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n  copies of the Software, and to permit persons to whom the Software is\r\n  furnished to do so, subject to the following conditions:\r\n\r\n  The above copyright notice and this permission notice shall be included in\r\n  all copies or substantial portions of the Software.\r\n\r\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\n  THE SOFTWARE.\r\n*/\r\n","import { SourceToDest } from '@rgba-image/common'\r\nimport { copy } from '@rgba-image/copy'\r\nimport { createImage } from '@rgba-image/create-image'\r\nimport { filters } from './filters'\r\nimport { convolve } from './convolve'\r\n\r\nconst resize = ( source: ImageData, dest: ImageData, use2 = false ) => {\r\n  const xRatio = dest.width / source.width\r\n  const yRatio = dest.height / source.height\r\n\r\n  const filtersX = filters( source.width, dest.width, xRatio, 0, use2 )\r\n  const filtersY = filters( source.height, dest.height, yRatio, 0, use2 )\r\n\r\n  const tmp = new Uint8ClampedArray( dest.width * source.height * 4 )\r\n\r\n  convolve( source.data, tmp, source.width, source.height, dest.width, filtersX )\r\n  convolve( tmp, dest.data, source.height, dest.width, dest.height, filtersY )\r\n}\r\n\r\nexport const lanczos: SourceToDest = ( source: ImageData, dest: ImageData, sx = 0, sy = 0, sw = source.width - sx, sh = source.height - sy, dx = 0, dy = 0, dw = dest.width - dx, dh = dest.height - dy ) => {\r\n  sx = sx | 0\r\n  sy = sy | 0\r\n  sw = sw | 0\r\n  sh = sh | 0\r\n  dx = dx | 0\r\n  dy = dy | 0\r\n  dw = dw | 0\r\n  dh = dh | 0\r\n\r\n  if ( sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0 ) return\r\n\r\n  if( sx === 0 && sy === 0 && sw === source.width && sh === source.height && dx === 0 && dy === 0 && dw === dest.width && dh === dest.height ){\r\n    resize( source, dest )\r\n\r\n    return\r\n  }\r\n\r\n  /*\r\n    this is more expensive than the way we do in other rgba-lib functions, but\r\n    I don't understand the pica code that I based this on well enough to work\r\n    out how to use regions without doing crops first\r\n\r\n    however copy is pretty fast compared to lanczos, so the difference is slight\r\n  */\r\n  const croppedSource = createImage( sw, sh )\r\n  const croppedDest = createImage( dw, dh )\r\n  copy( source, croppedSource, sx, sy )\r\n  resize( croppedSource, croppedDest )\r\n  copy( croppedDest, dest, 0, 0, croppedDest.width, croppedDest.height, dx, dy )\r\n}\r\n\r\nexport const lanczos2: SourceToDest = ( source: ImageData, dest: ImageData, sx = 0, sy = 0, sw = source.width - sx, sh = source.height - sy, dx = 0, dy = 0, dw = dest.width - dx, dh = dest.height - dy ) => {\r\n  sx = sx | 0\r\n  sy = sy | 0\r\n  sw = sw | 0\r\n  sh = sh | 0\r\n  dx = dx | 0\r\n  dy = dy | 0\r\n  dw = dw | 0\r\n  dh = dh | 0\r\n\r\n  if ( sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0 ) return\r\n\r\n  if ( sx === 0 && sy === 0 && sw === source.width && sh === source.height && dx === 0 && dy === 0 && dw === dest.width && dh === dest.height ) {\r\n    resize( source, dest, true )\r\n\r\n    return\r\n  }\r\n\r\n  /*\r\n    this is more expensive than the way we do in other rgba-lib functions, but\r\n    I don't understand the pica code that I based this on well enough to work\r\n    out how to use regions without doing crops first\r\n\r\n    however copy is pretty fast compared to lanczos, so the difference is slight\r\n  */\r\n  const croppedSource = createImage( sw, sh )\r\n  const croppedDest = createImage( dw, dh )\r\n  copy( source, croppedSource, sx, sy )\r\n  resize( croppedSource, croppedDest, true )\r\n  copy( croppedDest, dest, 0, 0, croppedDest.width, croppedDest.height, dx, dy )\r\n}\r\n","import * as ieee754 from 'ieee754';\n// Primitive types\nfunction dv(array) {\n    return new DataView(array.buffer, array.byteOffset);\n}\n/**\n * 8-bit unsigned integer\n */\nexport const UINT8 = {\n    len: 1,\n    get(array, offset) {\n        return dv(array).getUint8(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setUint8(offset, value);\n        return offset + 1;\n    }\n};\n/**\n * 16-bit unsigned integer, Little Endian byte order\n */\nexport const UINT16_LE = {\n    len: 2,\n    get(array, offset) {\n        return dv(array).getUint16(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setUint16(offset, value, true);\n        return offset + 2;\n    }\n};\n/**\n * 16-bit unsigned integer, Big Endian byte order\n */\nexport const UINT16_BE = {\n    len: 2,\n    get(array, offset) {\n        return dv(array).getUint16(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setUint16(offset, value);\n        return offset + 2;\n    }\n};\n/**\n * 24-bit unsigned integer, Little Endian byte order\n */\nexport const UINT24_LE = {\n    len: 3,\n    get(array, offset) {\n        const dataView = dv(array);\n        return dataView.getUint8(offset) + (dataView.getUint16(offset + 1, true) << 8);\n    },\n    put(array, offset, value) {\n        const dataView = dv(array);\n        dataView.setUint8(offset, value & 0xff);\n        dataView.setUint16(offset + 1, value >> 8, true);\n        return offset + 3;\n    }\n};\n/**\n * 24-bit unsigned integer, Big Endian byte order\n */\nexport const UINT24_BE = {\n    len: 3,\n    get(array, offset) {\n        const dataView = dv(array);\n        return (dataView.getUint16(offset) << 8) + dataView.getUint8(offset + 2);\n    },\n    put(array, offset, value) {\n        const dataView = dv(array);\n        dataView.setUint16(offset, value >> 8);\n        dataView.setUint8(offset + 2, value & 0xff);\n        return offset + 3;\n    }\n};\n/**\n * 32-bit unsigned integer, Little Endian byte order\n */\nexport const UINT32_LE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getUint32(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setUint32(offset, value, true);\n        return offset + 4;\n    }\n};\n/**\n * 32-bit unsigned integer, Big Endian byte order\n */\nexport const UINT32_BE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getUint32(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setUint32(offset, value);\n        return offset + 4;\n    }\n};\n/**\n * 8-bit signed integer\n */\nexport const INT8 = {\n    len: 1,\n    get(array, offset) {\n        return dv(array).getInt8(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setInt8(offset, value);\n        return offset + 1;\n    }\n};\n/**\n * 16-bit signed integer, Big Endian byte order\n */\nexport const INT16_BE = {\n    len: 2,\n    get(array, offset) {\n        return dv(array).getInt16(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setInt16(offset, value);\n        return offset + 2;\n    }\n};\n/**\n * 16-bit signed integer, Little Endian byte order\n */\nexport const INT16_LE = {\n    len: 2,\n    get(array, offset) {\n        return dv(array).getInt16(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setInt16(offset, value, true);\n        return offset + 2;\n    }\n};\n/**\n * 24-bit signed integer, Little Endian byte order\n */\nexport const INT24_LE = {\n    len: 3,\n    get(array, offset) {\n        const unsigned = UINT24_LE.get(array, offset);\n        return unsigned > 0x7fffff ? unsigned - 0x1000000 : unsigned;\n    },\n    put(array, offset, value) {\n        const dataView = dv(array);\n        dataView.setUint8(offset, value & 0xff);\n        dataView.setUint16(offset + 1, value >> 8, true);\n        return offset + 3;\n    }\n};\n/**\n * 24-bit signed integer, Big Endian byte order\n */\nexport const INT24_BE = {\n    len: 3,\n    get(array, offset) {\n        const unsigned = UINT24_BE.get(array, offset);\n        return unsigned > 0x7fffff ? unsigned - 0x1000000 : unsigned;\n    },\n    put(array, offset, value) {\n        const dataView = dv(array);\n        dataView.setUint16(offset, value >> 8);\n        dataView.setUint8(offset + 2, value & 0xff);\n        return offset + 3;\n    }\n};\n/**\n * 32-bit signed integer, Big Endian byte order\n */\nexport const INT32_BE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getInt32(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setInt32(offset, value);\n        return offset + 4;\n    }\n};\n/**\n * 32-bit signed integer, Big Endian byte order\n */\nexport const INT32_LE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getInt32(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setInt32(offset, value, true);\n        return offset + 4;\n    }\n};\n/**\n * 64-bit unsigned integer, Little Endian byte order\n */\nexport const UINT64_LE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getBigUint64(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setBigUint64(offset, value, true);\n        return offset + 8;\n    }\n};\n/**\n * 64-bit signed integer, Little Endian byte order\n */\nexport const INT64_LE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getBigInt64(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setBigInt64(offset, value, true);\n        return offset + 8;\n    }\n};\n/**\n * 64-bit unsigned integer, Big Endian byte order\n */\nexport const UINT64_BE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getBigUint64(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setBigUint64(offset, value);\n        return offset + 8;\n    }\n};\n/**\n * 64-bit signed integer, Big Endian byte order\n */\nexport const INT64_BE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getBigInt64(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setBigInt64(offset, value);\n        return offset + 8;\n    }\n};\n/**\n * IEEE 754 16-bit (half precision) float, big endian\n */\nexport const Float16_BE = {\n    len: 2,\n    get(dataView, offset) {\n        return ieee754.read(dataView, offset, false, 10, this.len);\n    },\n    put(dataView, offset, value) {\n        ieee754.write(dataView, value, offset, false, 10, this.len);\n        return offset + this.len;\n    }\n};\n/**\n * IEEE 754 16-bit (half precision) float, little endian\n */\nexport const Float16_LE = {\n    len: 2,\n    get(array, offset) {\n        return ieee754.read(array, offset, true, 10, this.len);\n    },\n    put(array, offset, value) {\n        ieee754.write(array, value, offset, true, 10, this.len);\n        return offset + this.len;\n    }\n};\n/**\n * IEEE 754 32-bit (single precision) float, big endian\n */\nexport const Float32_BE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getFloat32(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setFloat32(offset, value);\n        return offset + 4;\n    }\n};\n/**\n * IEEE 754 32-bit (single precision) float, little endian\n */\nexport const Float32_LE = {\n    len: 4,\n    get(array, offset) {\n        return dv(array).getFloat32(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setFloat32(offset, value, true);\n        return offset + 4;\n    }\n};\n/**\n * IEEE 754 64-bit (double precision) float, big endian\n */\nexport const Float64_BE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getFloat64(offset);\n    },\n    put(array, offset, value) {\n        dv(array).setFloat64(offset, value);\n        return offset + 8;\n    }\n};\n/**\n * IEEE 754 64-bit (double precision) float, little endian\n */\nexport const Float64_LE = {\n    len: 8,\n    get(array, offset) {\n        return dv(array).getFloat64(offset, true);\n    },\n    put(array, offset, value) {\n        dv(array).setFloat64(offset, value, true);\n        return offset + 8;\n    }\n};\n/**\n * IEEE 754 80-bit (extended precision) float, big endian\n */\nexport const Float80_BE = {\n    len: 10,\n    get(array, offset) {\n        return ieee754.read(array, offset, false, 63, this.len);\n    },\n    put(array, offset, value) {\n        ieee754.write(array, value, offset, false, 63, this.len);\n        return offset + this.len;\n    }\n};\n/**\n * IEEE 754 80-bit (extended precision) float, little endian\n */\nexport const Float80_LE = {\n    len: 10,\n    get(array, offset) {\n        return ieee754.read(array, offset, true, 63, this.len);\n    },\n    put(array, offset, value) {\n        ieee754.write(array, value, offset, true, 63, this.len);\n        return offset + this.len;\n    }\n};\n/**\n * Ignore a given number of bytes\n */\nexport class IgnoreType {\n    /**\n     * @param len number of bytes to ignore\n     */\n    constructor(len) {\n        this.len = len;\n    }\n    // ToDo: don't read, but skip data\n    // eslint-disable-next-line @typescript-eslint/no-empty-function\n    get(array, off) {\n    }\n}\nexport class Uint8ArrayType {\n    constructor(len) {\n        this.len = len;\n    }\n    get(array, offset) {\n        return array.subarray(offset, offset + this.len);\n    }\n}\n/**\n * Consume a fixed number of bytes from the stream and return a string with a specified encoding.\n */\nexport class StringType {\n    constructor(len, encoding) {\n        this.len = len;\n        this.encoding = encoding;\n        this.textDecoder = new TextDecoder(encoding);\n    }\n    get(uint8Array, offset) {\n        return this.textDecoder.decode(uint8Array.subarray(offset, offset + this.len));\n    }\n}\n/**\n * ANSI Latin 1 String\n * Using windows-1252 / ISO 8859-1 decoding\n */\nexport class AnsiStringType {\n    constructor(len) {\n        this.len = len;\n        this.textDecoder = new TextDecoder('windows-1252');\n    }\n    get(uint8Array, offset = 0) {\n        return this.textDecoder.decode(uint8Array.subarray(offset, offset + this.len));\n    }\n}\n","export const defaultMessages = 'End-Of-Stream';\n/**\n * Thrown on read operation of the end of file or stream has been reached\n */\nexport class EndOfStreamError extends Error {\n    constructor() {\n        super(defaultMessages);\n    }\n}\n","import { EndOfStreamError } from \"./EndOfStreamError.js\";\nexport class AbstractStreamReader {\n    constructor() {\n        /**\n         * Maximum request length on read-stream operation\n         */\n        this.maxStreamReadSize = 1 * 1024 * 1024;\n        this.endOfStream = false;\n        /**\n         * Store peeked data\n         * @type {Array}\n         */\n        this.peekQueue = [];\n    }\n    async peek(uint8Array, offset, length) {\n        const bytesRead = await this.read(uint8Array, offset, length);\n        this.peekQueue.push(uint8Array.subarray(offset, offset + bytesRead)); // Put read data back to peek buffer\n        return bytesRead;\n    }\n    async read(buffer, offset, length) {\n        if (length === 0) {\n            return 0;\n        }\n        let bytesRead = this.readFromPeekBuffer(buffer, offset, length);\n        bytesRead += await this.readRemainderFromStream(buffer, offset + bytesRead, length - bytesRead);\n        if (bytesRead === 0) {\n            throw new EndOfStreamError();\n        }\n        return bytesRead;\n    }\n    /**\n     * Read chunk from stream\n     * @param buffer - Target Uint8Array (or Buffer) to store data read from stream in\n     * @param offset - Offset target\n     * @param length - Number of bytes to read\n     * @returns Number of bytes read\n     */\n    readFromPeekBuffer(buffer, offset, length) {\n        let remaining = length;\n        let bytesRead = 0;\n        // consume peeked data first\n        while (this.peekQueue.length > 0 && remaining > 0) {\n            const peekData = this.peekQueue.pop(); // Front of queue\n            if (!peekData)\n                throw new Error('peekData should be defined');\n            const lenCopy = Math.min(peekData.length, remaining);\n            buffer.set(peekData.subarray(0, lenCopy), offset + bytesRead);\n            bytesRead += lenCopy;\n            remaining -= lenCopy;\n            if (lenCopy < peekData.length) {\n                // remainder back to queue\n                this.peekQueue.push(peekData.subarray(lenCopy));\n            }\n        }\n        return bytesRead;\n    }\n    async readRemainderFromStream(buffer, offset, initialRemaining) {\n        let remaining = initialRemaining;\n        let bytesRead = 0;\n        // Continue reading from stream if required\n        while (remaining > 0 && !this.endOfStream) {\n            const reqLen = Math.min(remaining, this.maxStreamReadSize);\n            const chunkLen = await this.readFromStream(buffer, offset + bytesRead, reqLen);\n            if (chunkLen === 0)\n                break;\n            bytesRead += chunkLen;\n            remaining -= chunkLen;\n        }\n        return bytesRead;\n    }\n}\n","import { EndOfStreamError } from './EndOfStreamError.js';\nexport { EndOfStreamError } from './EndOfStreamError.js';\nimport { AbstractStreamReader } from \"./AbstractStreamReader.js\";\n/**\n * Read from a WebStream\n * Reference: https://nodejs.org/api/webstreams.html#class-readablestreambyobreader\n */\nexport class WebStreamReader extends AbstractStreamReader {\n    constructor(stream) {\n        super();\n        this.reader = stream.getReader({ mode: 'byob' });\n    }\n    async readFromStream(buffer, offset, length) {\n        if (this.endOfStream) {\n            throw new EndOfStreamError();\n        }\n        const result = await this.reader.read(new Uint8Array(length));\n        if (result.done) {\n            this.endOfStream = result.done;\n        }\n        if (result.value) {\n            buffer.set(result.value, offset);\n            return result.value.byteLength;\n        }\n        return 0;\n    }\n    async abort() {\n        await this.reader.cancel(); // Signals a loss of interest in the stream by a consumer\n        this.reader.releaseLock();\n    }\n}\n","import { EndOfStreamError } from 'peek-readable';\n/**\n * Core tokenizer\n */\nexport class AbstractTokenizer {\n    /**\n     * Constructor\n     * @param options Tokenizer options\n     * @protected\n     */\n    constructor(options) {\n        /**\n         * Tokenizer-stream position\n         */\n        this.position = 0;\n        this.numBuffer = new Uint8Array(8);\n        this.fileInfo = options?.fileInfo ?? {};\n        this.onClose = options?.onClose;\n        if (options?.abortSignal) {\n            options.abortSignal.addEventListener('abort', () => {\n                this.abort();\n            });\n        }\n    }\n    /**\n     * Read a token from the tokenizer-stream\n     * @param token - The token to read\n     * @param position - If provided, the desired position in the tokenizer-stream\n     * @returns Promise with token data\n     */\n    async readToken(token, position = this.position) {\n        const uint8Array = new Uint8Array(token.len);\n        const len = await this.readBuffer(uint8Array, { position });\n        if (len < token.len)\n            throw new EndOfStreamError();\n        return token.get(uint8Array, 0);\n    }\n    /**\n     * Peek a token from the tokenizer-stream.\n     * @param token - Token to peek from the tokenizer-stream.\n     * @param position - Offset where to begin reading within the file. If position is null, data will be read from the current file position.\n     * @returns Promise with token data\n     */\n    async peekToken(token, position = this.position) {\n        const uint8Array = new Uint8Array(token.len);\n        const len = await this.peekBuffer(uint8Array, { position });\n        if (len < token.len)\n            throw new EndOfStreamError();\n        return token.get(uint8Array, 0);\n    }\n    /**\n     * Read a numeric token from the stream\n     * @param token - Numeric token\n     * @returns Promise with number\n     */\n    async readNumber(token) {\n        const len = await this.readBuffer(this.numBuffer, { length: token.len });\n        if (len < token.len)\n            throw new EndOfStreamError();\n        return token.get(this.numBuffer, 0);\n    }\n    /**\n     * Read a numeric token from the stream\n     * @param token - Numeric token\n     * @returns Promise with number\n     */\n    async peekNumber(token) {\n        const len = await this.peekBuffer(this.numBuffer, { length: token.len });\n        if (len < token.len)\n            throw new EndOfStreamError();\n        return token.get(this.numBuffer, 0);\n    }\n    /**\n     * Ignore number of bytes, advances the pointer in under tokenizer-stream.\n     * @param length - Number of bytes to ignore\n     * @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available\n     */\n    async ignore(length) {\n        if (this.fileInfo.size !== undefined) {\n            const bytesLeft = this.fileInfo.size - this.position;\n            if (length > bytesLeft) {\n                this.position += bytesLeft;\n                return bytesLeft;\n            }\n        }\n        this.position += length;\n        return length;\n    }\n    async close() {\n        await this.abort();\n        await this.onClose?.();\n    }\n    normalizeOptions(uint8Array, options) {\n        if (options && options.position !== undefined && options.position < this.position) {\n            throw new Error('`options.position` must be equal or greater than `tokenizer.position`');\n        }\n        if (options) {\n            return {\n                mayBeLess: options.mayBeLess === true,\n                offset: options.offset ? options.offset : 0,\n                length: options.length ? options.length : (uint8Array.length - (options.offset ? options.offset : 0)),\n                position: options.position ? options.position : this.position\n            };\n        }\n        return {\n            mayBeLess: false,\n            offset: 0,\n            length: uint8Array.length,\n            position: this.position\n        };\n    }\n    abort() {\n        return Promise.resolve(); // Ignore abort signal\n    }\n}\n","import { AbstractTokenizer } from './AbstractTokenizer.js';\nimport { EndOfStreamError } from 'peek-readable';\nconst maxBufferSize = 256000;\nexport class ReadStreamTokenizer extends AbstractTokenizer {\n    /**\n     * Constructor\n     * @param streamReader stream-reader to read from\n     * @param options Tokenizer options\n     */\n    constructor(streamReader, options) {\n        super(options);\n        this.streamReader = streamReader;\n    }\n    /**\n     * Read buffer from tokenizer\n     * @param uint8Array - Target Uint8Array to fill with data read from the tokenizer-stream\n     * @param options - Read behaviour options\n     * @returns Promise with number of bytes read\n     */\n    async readBuffer(uint8Array, options) {\n        const normOptions = this.normalizeOptions(uint8Array, options);\n        const skipBytes = normOptions.position - this.position;\n        if (skipBytes > 0) {\n            await this.ignore(skipBytes);\n            return this.readBuffer(uint8Array, options);\n        }\n        if (skipBytes < 0) {\n            throw new Error('`options.position` must be equal or greater than `tokenizer.position`');\n        }\n        if (normOptions.length === 0) {\n            return 0;\n        }\n        const bytesRead = await this.streamReader.read(uint8Array, normOptions.offset, normOptions.length);\n        this.position += bytesRead;\n        if ((!options || !options.mayBeLess) && bytesRead < normOptions.length) {\n            throw new EndOfStreamError();\n        }\n        return bytesRead;\n    }\n    /**\n     * Peek (read ahead) buffer from tokenizer\n     * @param uint8Array - Uint8Array (or Buffer) to write data to\n     * @param options - Read behaviour options\n     * @returns Promise with number of bytes peeked\n     */\n    async peekBuffer(uint8Array, options) {\n        const normOptions = this.normalizeOptions(uint8Array, options);\n        let bytesRead = 0;\n        if (normOptions.position) {\n            const skipBytes = normOptions.position - this.position;\n            if (skipBytes > 0) {\n                const skipBuffer = new Uint8Array(normOptions.length + skipBytes);\n                bytesRead = await this.peekBuffer(skipBuffer, { mayBeLess: normOptions.mayBeLess });\n                uint8Array.set(skipBuffer.subarray(skipBytes), normOptions.offset);\n                return bytesRead - skipBytes;\n            }\n            if (skipBytes < 0) {\n                throw new Error('Cannot peek from a negative offset in a stream');\n            }\n        }\n        if (normOptions.length > 0) {\n            try {\n                bytesRead = await this.streamReader.peek(uint8Array, normOptions.offset, normOptions.length);\n            }\n            catch (err) {\n                if (options?.mayBeLess && err instanceof EndOfStreamError) {\n                    return 0;\n                }\n                throw err;\n            }\n            if ((!normOptions.mayBeLess) && bytesRead < normOptions.length) {\n                throw new EndOfStreamError();\n            }\n        }\n        return bytesRead;\n    }\n    async ignore(length) {\n        // debug(`ignore ${this.position}...${this.position + length - 1}`);\n        const bufSize = Math.min(maxBufferSize, length);\n        const buf = new Uint8Array(bufSize);\n        let totBytesRead = 0;\n        while (totBytesRead < length) {\n            const remaining = length - totBytesRead;\n            const bytesRead = await this.readBuffer(buf, { length: Math.min(bufSize, remaining) });\n            if (bytesRead < 0) {\n                return bytesRead;\n            }\n            totBytesRead += bytesRead;\n        }\n        return totBytesRead;\n    }\n    abort() {\n        return this.streamReader.abort();\n    }\n}\n","import { EndOfStreamError } from 'peek-readable';\nimport { AbstractTokenizer } from './AbstractTokenizer.js';\nexport class BufferTokenizer extends AbstractTokenizer {\n    /**\n     * Construct BufferTokenizer\n     * @param uint8Array - Uint8Array to tokenize\n     * @param options Tokenizer options\n     */\n    constructor(uint8Array, options) {\n        super(options);\n        this.uint8Array = uint8Array;\n        this.fileInfo.size = this.fileInfo.size ? this.fileInfo.size : uint8Array.length;\n    }\n    /**\n     * Read buffer from tokenizer\n     * @param uint8Array - Uint8Array to tokenize\n     * @param options - Read behaviour options\n     * @returns {Promise<number>}\n     */\n    async readBuffer(uint8Array, options) {\n        if (options?.position) {\n            if (options.position < this.position) {\n                throw new Error('`options.position` must be equal or greater than `tokenizer.position`');\n            }\n            this.position = options.position;\n        }\n        const bytesRead = await this.peekBuffer(uint8Array, options);\n        this.position += bytesRead;\n        return bytesRead;\n    }\n    /**\n     * Peek (read ahead) buffer from tokenizer\n     * @param uint8Array\n     * @param options - Read behaviour options\n     * @returns {Promise<number>}\n     */\n    async peekBuffer(uint8Array, options) {\n        const normOptions = this.normalizeOptions(uint8Array, options);\n        const bytes2read = Math.min(this.uint8Array.length - normOptions.position, normOptions.length);\n        if ((!normOptions.mayBeLess) && bytes2read < normOptions.length) {\n            throw new EndOfStreamError();\n        }\n        uint8Array.set(this.uint8Array.subarray(normOptions.position, normOptions.position + bytes2read), normOptions.offset);\n        return bytes2read;\n    }\n    close() {\n        return super.close();\n    }\n}\n","import { StreamReader, WebStreamReader } from 'peek-readable';\nimport { ReadStreamTokenizer } from './ReadStreamTokenizer.js';\nimport { BufferTokenizer } from './BufferTokenizer.js';\nexport { EndOfStreamError } from 'peek-readable';\nexport { AbstractTokenizer } from './AbstractTokenizer.js';\n/**\n * Construct ReadStreamTokenizer from given Stream.\n * Will set fileSize, if provided given Stream has set the .path property/\n * @param stream - Read from Node.js Stream.Readable\n * @param options - Tokenizer options\n * @returns ReadStreamTokenizer\n */\nexport function fromStream(stream, options) {\n    return new ReadStreamTokenizer(new StreamReader(stream), options);\n}\n/**\n * Construct ReadStreamTokenizer from given ReadableStream (WebStream API).\n * Will set fileSize, if provided given Stream has set the .path property/\n * @param webStream - Read from Node.js Stream.Readable (must be a byte stream)\n * @param options - Tokenizer options\n * @returns ReadStreamTokenizer\n */\nexport function fromWebStream(webStream, options) {\n    return new ReadStreamTokenizer(new WebStreamReader(webStream), options);\n}\n/**\n * Construct ReadStreamTokenizer from given Buffer.\n * @param uint8Array - Uint8Array to tokenize\n * @param options - Tokenizer options\n * @returns BufferTokenizer\n */\nexport function fromBuffer(uint8Array, options) {\n    return new BufferTokenizer(uint8Array, options);\n}\n","const objectToString = Object.prototype.toString;\nconst uint8ArrayStringified = '[object Uint8Array]';\nconst arrayBufferStringified = '[object ArrayBuffer]';\n\nfunction isType(value, typeConstructor, typeStringified) {\n\tif (!value) {\n\t\treturn false;\n\t}\n\n\tif (value.constructor === typeConstructor) {\n\t\treturn true;\n\t}\n\n\treturn objectToString.call(value) === typeStringified;\n}\n\nexport function isUint8Array(value) {\n\treturn isType(value, Uint8Array, uint8ArrayStringified);\n}\n\nfunction isArrayBuffer(value) {\n\treturn isType(value, ArrayBuffer, arrayBufferStringified);\n}\n\nfunction isUint8ArrayOrArrayBuffer(value) {\n\treturn isUint8Array(value) || isArrayBuffer(value);\n}\n\nexport function assertUint8Array(value) {\n\tif (!isUint8Array(value)) {\n\t\tthrow new TypeError(`Expected \\`Uint8Array\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nexport function assertUint8ArrayOrArrayBuffer(value) {\n\tif (!isUint8ArrayOrArrayBuffer(value)) {\n\t\tthrow new TypeError(`Expected \\`Uint8Array\\` or \\`ArrayBuffer\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nexport function toUint8Array(value) {\n\tif (value instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(value);\n\t}\n\n\tif (ArrayBuffer.isView(value)) {\n\t\treturn new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n\t}\n\n\tthrow new TypeError(`Unsupported value, got \\`${typeof value}\\`.`);\n}\n\nexport function concatUint8Arrays(arrays, totalLength) {\n\tif (arrays.length === 0) {\n\t\treturn new Uint8Array(0);\n\t}\n\n\ttotalLength ??= arrays.reduce((accumulator, currentValue) => accumulator + currentValue.length, 0);\n\n\tconst returnValue = new Uint8Array(totalLength);\n\n\tlet offset = 0;\n\tfor (const array of arrays) {\n\t\tassertUint8Array(array);\n\t\treturnValue.set(array, offset);\n\t\toffset += array.length;\n\t}\n\n\treturn returnValue;\n}\n\nexport function areUint8ArraysEqual(a, b) {\n\tassertUint8Array(a);\n\tassertUint8Array(b);\n\n\tif (a === b) {\n\t\treturn true;\n\t}\n\n\tif (a.length !== b.length) {\n\t\treturn false;\n\t}\n\n\t// eslint-disable-next-line unicorn/no-for-loop\n\tfor (let index = 0; index < a.length; index++) {\n\t\tif (a[index] !== b[index]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nexport function compareUint8Arrays(a, b) {\n\tassertUint8Array(a);\n\tassertUint8Array(b);\n\n\tconst length = Math.min(a.length, b.length);\n\n\tfor (let index = 0; index < length; index++) {\n\t\tconst diff = a[index] - b[index];\n\t\tif (diff !== 0) {\n\t\t\treturn Math.sign(diff);\n\t\t}\n\t}\n\n\t// At this point, all the compared elements are equal.\n\t// The shorter array should come first if the arrays are of different lengths.\n\treturn Math.sign(a.length - b.length);\n}\n\nconst cachedDecoders = {\n\tutf8: new globalThis.TextDecoder('utf8'),\n};\n\nexport function uint8ArrayToString(array, encoding = 'utf8') {\n\tassertUint8ArrayOrArrayBuffer(array);\n\tcachedDecoders[encoding] ??= new globalThis.TextDecoder(encoding);\n\treturn cachedDecoders[encoding].decode(array);\n}\n\nfunction assertString(value) {\n\tif (typeof value !== 'string') {\n\t\tthrow new TypeError(`Expected \\`string\\`, got \\`${typeof value}\\``);\n\t}\n}\n\nconst cachedEncoder = new globalThis.TextEncoder();\n\nexport function stringToUint8Array(string) {\n\tassertString(string);\n\treturn cachedEncoder.encode(string);\n}\n\nfunction base64ToBase64Url(base64) {\n\treturn base64.replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');\n}\n\nfunction base64UrlToBase64(base64url) {\n\treturn base64url.replaceAll('-', '+').replaceAll('_', '/');\n}\n\n// Reference: https://phuoc.ng/collection/this-vs-that/concat-vs-push/\nconst MAX_BLOCK_SIZE = 65_535;\n\nexport function uint8ArrayToBase64(array, {urlSafe = false} = {}) {\n\tassertUint8Array(array);\n\n\tlet base64;\n\n\tif (array.length < MAX_BLOCK_SIZE) {\n\t// Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n\t\tbase64 = globalThis.btoa(String.fromCodePoint.apply(this, array));\n\t} else {\n\t\tbase64 = '';\n\t\tfor (const value of array) {\n\t\t\tbase64 += String.fromCodePoint(value);\n\t\t}\n\n\t\tbase64 = globalThis.btoa(base64);\n\t}\n\n\treturn urlSafe ? base64ToBase64Url(base64) : base64;\n}\n\nexport function base64ToUint8Array(base64String) {\n\tassertString(base64String);\n\treturn Uint8Array.from(globalThis.atob(base64UrlToBase64(base64String)), x => x.codePointAt(0));\n}\n\nexport function stringToBase64(string, {urlSafe = false} = {}) {\n\tassertString(string);\n\treturn uint8ArrayToBase64(stringToUint8Array(string), {urlSafe});\n}\n\nexport function base64ToString(base64String) {\n\tassertString(base64String);\n\treturn uint8ArrayToString(base64ToUint8Array(base64String));\n}\n\nconst byteToHexLookupTable = Array.from({length: 256}, (_, index) => index.toString(16).padStart(2, '0'));\n\nexport function uint8ArrayToHex(array) {\n\tassertUint8Array(array);\n\n\t// Concatenating a string is faster than using an array.\n\tlet hexString = '';\n\n\t// eslint-disable-next-line unicorn/no-for-loop -- Max performance is critical.\n\tfor (let index = 0; index < array.length; index++) {\n\t\thexString += byteToHexLookupTable[array[index]];\n\t}\n\n\treturn hexString;\n}\n\nconst hexToDecimalLookupTable = {\n\t0: 0,\n\t1: 1,\n\t2: 2,\n\t3: 3,\n\t4: 4,\n\t5: 5,\n\t6: 6,\n\t7: 7,\n\t8: 8,\n\t9: 9,\n\ta: 10,\n\tb: 11,\n\tc: 12,\n\td: 13,\n\te: 14,\n\tf: 15,\n\tA: 10,\n\tB: 11,\n\tC: 12,\n\tD: 13,\n\tE: 14,\n\tF: 15,\n};\n\nexport function hexToUint8Array(hexString) {\n\tassertString(hexString);\n\n\tif (hexString.length % 2 !== 0) {\n\t\tthrow new Error('Invalid Hex string length.');\n\t}\n\n\tconst resultLength = hexString.length / 2;\n\tconst bytes = new Uint8Array(resultLength);\n\n\tfor (let index = 0; index < resultLength; index++) {\n\t\tconst highNibble = hexToDecimalLookupTable[hexString[index * 2]];\n\t\tconst lowNibble = hexToDecimalLookupTable[hexString[(index * 2) + 1]];\n\n\t\tif (highNibble === undefined || lowNibble === undefined) {\n\t\t\tthrow new Error(`Invalid Hex character encountered at position ${index * 2}`);\n\t\t}\n\n\t\tbytes[index] = (highNibble << 4) | lowNibble; // eslint-disable-line no-bitwise\n\t}\n\n\treturn bytes;\n}\n\n/**\n@param {DataView} view\n@returns {number}\n*/\nexport function getUintBE(view) {\n\tconst {byteLength} = view;\n\n\tif (byteLength === 6) {\n\t\treturn (view.getUint16(0) * (2 ** 32)) + view.getUint32(2);\n\t}\n\n\tif (byteLength === 5) {\n\t\treturn (view.getUint8(0) * (2 ** 32)) + view.getUint32(1);\n\t}\n\n\tif (byteLength === 4) {\n\t\treturn view.getUint32(0);\n\t}\n\n\tif (byteLength === 3) {\n\t\treturn (view.getUint8(0) * (2 ** 16)) + view.getUint16(1);\n\t}\n\n\tif (byteLength === 2) {\n\t\treturn view.getUint16(0);\n\t}\n\n\tif (byteLength === 1) {\n\t\treturn view.getUint8(0);\n\t}\n}\n\n/**\n@param {Uint8Array} array\n@param {Uint8Array} value\n@returns {number}\n*/\nexport function indexOf(array, value) {\n\tconst arrayLength = array.length;\n\tconst valueLength = value.length;\n\n\tif (valueLength === 0) {\n\t\treturn -1;\n\t}\n\n\tif (valueLength > arrayLength) {\n\t\treturn -1;\n\t}\n\n\tconst validOffsetLength = arrayLength - valueLength;\n\n\tfor (let index = 0; index <= validOffsetLength; index++) {\n\t\tlet isMatch = true;\n\t\tfor (let index2 = 0; index2 < valueLength; index2++) {\n\t\t\tif (array[index + index2] !== value[index2]) {\n\t\t\t\tisMatch = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (isMatch) {\n\t\t\treturn index;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/**\n@param {Uint8Array} array\n@param {Uint8Array} value\n@returns {boolean}\n*/\nexport function includes(array, value) {\n\treturn indexOf(array, value) !== -1;\n}\n","import {StringType} from 'token-types';\n\nexport function stringToBytes(string) {\n\treturn [...string].map(character => character.charCodeAt(0)); // eslint-disable-line unicorn/prefer-code-point\n}\n\n/**\nChecks whether the TAR checksum is valid.\n\n@param {Uint8Array} arrayBuffer - The TAR header `[offset ... offset + 512]`.\n@param {number} offset - TAR header offset.\n@returns {boolean} `true` if the TAR checksum is valid, otherwise `false`.\n*/\nexport function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {\n\tconst readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\\0.*$/, '').trim(), 8); // Read sum in header\n\tif (Number.isNaN(readSum)) {\n\t\treturn false;\n\t}\n\n\tlet sum = 8 * 0x20; // Initialize signed bit sum\n\n\tfor (let index = offset; index < offset + 148; index++) {\n\t\tsum += arrayBuffer[index];\n\t}\n\n\tfor (let index = offset + 156; index < offset + 512; index++) {\n\t\tsum += arrayBuffer[index];\n\t}\n\n\treturn readSum === sum;\n}\n\n/**\nID3 UINT32 sync-safe tokenizer token.\n28 bits (representing up to 256MB) integer, the msb is 0 to avoid \"false syncsignals\".\n*/\nexport const uint32SyncSafeToken = {\n\tget: (buffer, offset) => (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2]) << 7) | ((buffer[offset + 1]) << 14) | ((buffer[offset]) << 21),\n\tlen: 4,\n};\n","export const extensions = [\n\t'jpg',\n\t'png',\n\t'apng',\n\t'gif',\n\t'webp',\n\t'flif',\n\t'xcf',\n\t'cr2',\n\t'cr3',\n\t'orf',\n\t'arw',\n\t'dng',\n\t'nef',\n\t'rw2',\n\t'raf',\n\t'tif',\n\t'bmp',\n\t'icns',\n\t'jxr',\n\t'psd',\n\t'indd',\n\t'zip',\n\t'tar',\n\t'rar',\n\t'gz',\n\t'bz2',\n\t'7z',\n\t'dmg',\n\t'mp4',\n\t'mid',\n\t'mkv',\n\t'webm',\n\t'mov',\n\t'avi',\n\t'mpg',\n\t'mp2',\n\t'mp3',\n\t'm4a',\n\t'oga',\n\t'ogg',\n\t'ogv',\n\t'opus',\n\t'flac',\n\t'wav',\n\t'spx',\n\t'amr',\n\t'pdf',\n\t'epub',\n\t'elf',\n\t'macho',\n\t'exe',\n\t'swf',\n\t'rtf',\n\t'wasm',\n\t'woff',\n\t'woff2',\n\t'eot',\n\t'ttf',\n\t'otf',\n\t'ico',\n\t'flv',\n\t'ps',\n\t'xz',\n\t'sqlite',\n\t'nes',\n\t'crx',\n\t'xpi',\n\t'cab',\n\t'deb',\n\t'ar',\n\t'rpm',\n\t'Z',\n\t'lz',\n\t'cfb',\n\t'mxf',\n\t'mts',\n\t'blend',\n\t'bpg',\n\t'docx',\n\t'pptx',\n\t'xlsx',\n\t'3gp',\n\t'3g2',\n\t'j2c',\n\t'jp2',\n\t'jpm',\n\t'jpx',\n\t'mj2',\n\t'aif',\n\t'qcp',\n\t'odt',\n\t'ods',\n\t'odp',\n\t'xml',\n\t'mobi',\n\t'heic',\n\t'cur',\n\t'ktx',\n\t'ape',\n\t'wv',\n\t'dcm',\n\t'ics',\n\t'glb',\n\t'pcap',\n\t'dsf',\n\t'lnk',\n\t'alias',\n\t'voc',\n\t'ac3',\n\t'm4v',\n\t'm4p',\n\t'm4b',\n\t'f4v',\n\t'f4p',\n\t'f4b',\n\t'f4a',\n\t'mie',\n\t'asf',\n\t'ogm',\n\t'ogx',\n\t'mpc',\n\t'arrow',\n\t'shp',\n\t'aac',\n\t'mp1',\n\t'it',\n\t's3m',\n\t'xm',\n\t'ai',\n\t'skp',\n\t'avif',\n\t'eps',\n\t'lzh',\n\t'pgp',\n\t'asar',\n\t'stl',\n\t'chm',\n\t'3mf',\n\t'zst',\n\t'jxl',\n\t'vcf',\n\t'jls',\n\t'pst',\n\t'dwg',\n\t'parquet',\n\t'class',\n\t'arj',\n\t'cpio',\n\t'ace',\n\t'avro',\n\t'icc',\n\t'fbx',\n\t'vsdx',\n\t'vtt',\n\t'apk',\n];\n\nexport const mimeTypes = [\n\t'image/jpeg',\n\t'image/png',\n\t'image/gif',\n\t'image/webp',\n\t'image/flif',\n\t'image/x-xcf',\n\t'image/x-canon-cr2',\n\t'image/x-canon-cr3',\n\t'image/tiff',\n\t'image/bmp',\n\t'image/vnd.ms-photo',\n\t'image/vnd.adobe.photoshop',\n\t'application/x-indesign',\n\t'application/epub+zip',\n\t'application/x-xpinstall',\n\t'application/vnd.oasis.opendocument.text',\n\t'application/vnd.oasis.opendocument.spreadsheet',\n\t'application/vnd.oasis.opendocument.presentation',\n\t'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n\t'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n\t'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n\t'application/zip',\n\t'application/x-tar',\n\t'application/x-rar-compressed',\n\t'application/gzip',\n\t'application/x-bzip2',\n\t'application/x-7z-compressed',\n\t'application/x-apple-diskimage',\n\t'application/x-apache-arrow',\n\t'video/mp4',\n\t'audio/midi',\n\t'video/x-matroska',\n\t'video/webm',\n\t'video/quicktime',\n\t'video/vnd.avi',\n\t'audio/wav',\n\t'audio/qcelp',\n\t'audio/x-ms-asf',\n\t'video/x-ms-asf',\n\t'application/vnd.ms-asf',\n\t'video/mpeg',\n\t'video/3gpp',\n\t'audio/mpeg',\n\t'audio/mp4', // RFC 4337\n\t'video/ogg',\n\t'audio/ogg',\n\t'audio/ogg; codecs=opus',\n\t'application/ogg',\n\t'audio/x-flac',\n\t'audio/ape',\n\t'audio/wavpack',\n\t'audio/amr',\n\t'application/pdf',\n\t'application/x-elf',\n\t'application/x-mach-binary',\n\t'application/x-msdownload',\n\t'application/x-shockwave-flash',\n\t'application/rtf',\n\t'application/wasm',\n\t'font/woff',\n\t'font/woff2',\n\t'application/vnd.ms-fontobject',\n\t'font/ttf',\n\t'font/otf',\n\t'image/x-icon',\n\t'video/x-flv',\n\t'application/postscript',\n\t'application/eps',\n\t'application/x-xz',\n\t'application/x-sqlite3',\n\t'application/x-nintendo-nes-rom',\n\t'application/x-google-chrome-extension',\n\t'application/vnd.ms-cab-compressed',\n\t'application/x-deb',\n\t'application/x-unix-archive',\n\t'application/x-rpm',\n\t'application/x-compress',\n\t'application/x-lzip',\n\t'application/x-cfb',\n\t'application/x-mie',\n\t'application/mxf',\n\t'video/mp2t',\n\t'application/x-blender',\n\t'image/bpg',\n\t'image/j2c',\n\t'image/jp2',\n\t'image/jpx',\n\t'image/jpm',\n\t'image/mj2',\n\t'audio/aiff',\n\t'application/xml',\n\t'application/x-mobipocket-ebook',\n\t'image/heif',\n\t'image/heif-sequence',\n\t'image/heic',\n\t'image/heic-sequence',\n\t'image/icns',\n\t'image/ktx',\n\t'application/dicom',\n\t'audio/x-musepack',\n\t'text/calendar',\n\t'text/vcard',\n\t'text/vtt',\n\t'model/gltf-binary',\n\t'application/vnd.tcpdump.pcap',\n\t'audio/x-dsf', // Non-standard\n\t'application/x.ms.shortcut', // Invented by us\n\t'application/x.apple.alias', // Invented by us\n\t'audio/x-voc',\n\t'audio/vnd.dolby.dd-raw',\n\t'audio/x-m4a',\n\t'image/apng',\n\t'image/x-olympus-orf',\n\t'image/x-sony-arw',\n\t'image/x-adobe-dng',\n\t'image/x-nikon-nef',\n\t'image/x-panasonic-rw2',\n\t'image/x-fujifilm-raf',\n\t'video/x-m4v',\n\t'video/3gpp2',\n\t'application/x-esri-shape',\n\t'audio/aac',\n\t'audio/x-it',\n\t'audio/x-s3m',\n\t'audio/x-xm',\n\t'video/MP1S',\n\t'video/MP2P',\n\t'application/vnd.sketchup.skp',\n\t'image/avif',\n\t'application/x-lzh-compressed',\n\t'application/pgp-encrypted',\n\t'application/x-asar',\n\t'model/stl',\n\t'application/vnd.ms-htmlhelp',\n\t'model/3mf',\n\t'image/jxl',\n\t'application/zstd',\n\t'image/jls',\n\t'application/vnd.ms-outlook',\n\t'image/vnd.dwg',\n\t'application/x-parquet',\n\t'application/java-vm',\n\t'application/x-arj',\n\t'application/x-cpio',\n\t'application/x-ace-compressed',\n\t'application/avro',\n\t'application/vnd.iccprofile',\n\t'application/x.autodesk.fbx', // Invented by us\n\t'application/vnd.visio',\n\t'application/vnd.android.package-archive',\n];\n","/**\nPrimary entry point, Node.js specific entry point is index.js\n*/\n\nimport * as Token from 'token-types';\nimport * as strtok3 from 'strtok3/core';\nimport {includes, indexOf, getUintBE} from 'uint8array-extras';\nimport {\n\tstringToBytes,\n\ttarHeaderChecksumMatches,\n\tuint32SyncSafeToken,\n} from './util.js';\nimport {extensions, mimeTypes} from './supported.js';\n\nexport const reasonableDetectionSizeInBytes = 4100; // A fair amount of file-types are detectable within this range.\n\nexport async function fileTypeFromStream(stream) {\n\treturn new FileTypeParser().fromStream(stream);\n}\n\nexport async function fileTypeFromBuffer(input) {\n\treturn new FileTypeParser().fromBuffer(input);\n}\n\nexport async function fileTypeFromBlob(blob) {\n\treturn new FileTypeParser().fromBlob(blob);\n}\n\nfunction _check(buffer, headers, options) {\n\toptions = {\n\t\toffset: 0,\n\t\t...options,\n\t};\n\n\tfor (const [index, header] of headers.entries()) {\n\t\t// If a bitmask is set\n\t\tif (options.mask) {\n\t\t\t// If header doesn't equal `buf` with bits masked off\n\t\t\tif (header !== (options.mask[index] & buffer[index + options.offset])) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else if (header !== buffer[index + options.offset]) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nexport async function fileTypeFromTokenizer(tokenizer) {\n\treturn new FileTypeParser().fromTokenizer(tokenizer);\n}\n\nexport async function fileTypeStream(webStream, options) {\n\treturn new FileTypeParser(options).toDetectionStream(webStream, options);\n}\n\nexport class FileTypeParser {\n\tconstructor(options) {\n\t\tthis.detectors = options?.customDetectors;\n\t\tthis.tokenizerOptions = {\n\t\t\tabortSignal: options?.signal,\n\t\t};\n\t\tthis.fromTokenizer = this.fromTokenizer.bind(this);\n\t\tthis.fromBuffer = this.fromBuffer.bind(this);\n\t\tthis.parse = this.parse.bind(this);\n\t}\n\n\tasync fromTokenizer(tokenizer) {\n\t\tconst initialPosition = tokenizer.position;\n\n\t\tfor (const detector of this.detectors || []) {\n\t\t\tconst fileType = await detector(tokenizer);\n\t\t\tif (fileType) {\n\t\t\t\treturn fileType;\n\t\t\t}\n\n\t\t\tif (initialPosition !== tokenizer.position) {\n\t\t\t\treturn undefined; // Cannot proceed scanning of the tokenizer is at an arbitrary position\n\t\t\t}\n\t\t}\n\n\t\treturn this.parse(tokenizer);\n\t}\n\n\tasync fromBuffer(input) {\n\t\tif (!(input instanceof Uint8Array || input instanceof ArrayBuffer)) {\n\t\t\tthrow new TypeError(`Expected the \\`input\\` argument to be of type \\`Uint8Array\\` or \\`ArrayBuffer\\`, got \\`${typeof input}\\``);\n\t\t}\n\n\t\tconst buffer = input instanceof Uint8Array ? input : new Uint8Array(input);\n\n\t\tif (!(buffer?.length > 1)) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.fromTokenizer(strtok3.fromBuffer(buffer, this.tokenizerOptions));\n\t}\n\n\tasync fromBlob(blob) {\n\t\treturn this.fromStream(blob.stream());\n\t}\n\n\tasync fromStream(stream) {\n\t\tconst tokenizer = await strtok3.fromWebStream(stream, this.tokenizerOptions);\n\t\ttry {\n\t\t\treturn await this.fromTokenizer(tokenizer);\n\t\t} finally {\n\t\t\tawait tokenizer.close();\n\t\t}\n\t}\n\n\tasync toDetectionStream(stream, options) {\n\t\tconst {sampleSize = reasonableDetectionSizeInBytes} = options;\n\t\tlet detectedFileType;\n\t\tlet firstChunk;\n\n\t\tconst reader = stream.getReader({mode: 'byob'});\n\t\ttry {\n\t\t\t// Read the first chunk from the stream\n\t\t\tconst {value: chunk, done} = await reader.read(new Uint8Array(sampleSize));\n\t\t\tfirstChunk = chunk;\n\t\t\tif (!done && chunk) {\n\t\t\t\ttry {\n\t\t\t\t\t// Attempt to detect the file type from the chunk\n\t\t\t\t\tdetectedFileType = await this.fromBuffer(chunk.slice(0, sampleSize));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof strtok3.EndOfStreamError)) {\n\t\t\t\t\t\tthrow error; // Re-throw non-EndOfStreamError\n\t\t\t\t\t}\n\n\t\t\t\t\tdetectedFileType = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfirstChunk = chunk;\n\t\t} finally {\n\t\t\treader.releaseLock(); // Ensure the reader is released\n\t\t}\n\n\t\t// Create a new ReadableStream to manage locking issues\n\t\tconst transformStream = new TransformStream({\n\t\t\tasync start(controller) {\n\t\t\t\tcontroller.enqueue(firstChunk); // Enqueue the initial chunk\n\t\t\t},\n\t\t\ttransform(chunk, controller) {\n\t\t\t\t// Pass through the chunks without modification\n\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t},\n\t\t});\n\n\t\tconst newStream = stream.pipeThrough(transformStream);\n\t\tnewStream.fileType = detectedFileType;\n\n\t\treturn newStream;\n\t}\n\n\tcheck(header, options) {\n\t\treturn _check(this.buffer, header, options);\n\t}\n\n\tcheckString(header, options) {\n\t\treturn this.check(stringToBytes(header), options);\n\t}\n\n\tasync parse(tokenizer) {\n\t\tthis.buffer = new Uint8Array(reasonableDetectionSizeInBytes);\n\n\t\t// Keep reading until EOF if the file size is unknown.\n\t\tif (tokenizer.fileInfo.size === undefined) {\n\t\t\ttokenizer.fileInfo.size = Number.MAX_SAFE_INTEGER;\n\t\t}\n\n\t\tthis.tokenizer = tokenizer;\n\n\t\tawait tokenizer.peekBuffer(this.buffer, {length: 12, mayBeLess: true});\n\n\t\t// -- 2-byte signatures --\n\n\t\tif (this.check([0x42, 0x4D])) {\n\t\t\treturn {\n\t\t\t\text: 'bmp',\n\t\t\t\tmime: 'image/bmp',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x0B, 0x77])) {\n\t\t\treturn {\n\t\t\t\text: 'ac3',\n\t\t\t\tmime: 'audio/vnd.dolby.dd-raw',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x78, 0x01])) {\n\t\t\treturn {\n\t\t\t\text: 'dmg',\n\t\t\t\tmime: 'application/x-apple-diskimage',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x4D, 0x5A])) {\n\t\t\treturn {\n\t\t\t\text: 'exe',\n\t\t\t\tmime: 'application/x-msdownload',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x25, 0x21])) {\n\t\t\tawait tokenizer.peekBuffer(this.buffer, {length: 24, mayBeLess: true});\n\n\t\t\tif (\n\t\t\t\tthis.checkString('PS-Adobe-', {offset: 2})\n\t\t\t\t&& this.checkString(' EPSF-', {offset: 14})\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'eps',\n\t\t\t\t\tmime: 'application/eps',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\text: 'ps',\n\t\t\t\tmime: 'application/postscript',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.check([0x1F, 0xA0])\n\t\t\t|| this.check([0x1F, 0x9D])\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'Z',\n\t\t\t\tmime: 'application/x-compress',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xC7, 0x71])) {\n\t\t\treturn {\n\t\t\t\text: 'cpio',\n\t\t\t\tmime: 'application/x-cpio',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x60, 0xEA])) {\n\t\t\treturn {\n\t\t\t\text: 'arj',\n\t\t\t\tmime: 'application/x-arj',\n\t\t\t};\n\t\t}\n\n\t\t// -- 3-byte signatures --\n\n\t\tif (this.check([0xEF, 0xBB, 0xBF])) { // UTF-8-BOM\n\t\t\t// Strip off UTF-8-BOM\n\t\t\tthis.tokenizer.ignore(3);\n\t\t\treturn this.parse(tokenizer);\n\t\t}\n\n\t\tif (this.check([0x47, 0x49, 0x46])) {\n\t\t\treturn {\n\t\t\t\text: 'gif',\n\t\t\t\tmime: 'image/gif',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x49, 0x49, 0xBC])) {\n\t\t\treturn {\n\t\t\t\text: 'jxr',\n\t\t\t\tmime: 'image/vnd.ms-photo',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x1F, 0x8B, 0x8])) {\n\t\t\treturn {\n\t\t\t\text: 'gz',\n\t\t\t\tmime: 'application/gzip',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x42, 0x5A, 0x68])) {\n\t\t\treturn {\n\t\t\t\text: 'bz2',\n\t\t\t\tmime: 'application/x-bzip2',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('ID3')) {\n\t\t\tawait tokenizer.ignore(6); // Skip ID3 header until the header size\n\t\t\tconst id3HeaderLength = await tokenizer.readToken(uint32SyncSafeToken);\n\t\t\tif (tokenizer.position + id3HeaderLength > tokenizer.fileInfo.size) {\n\t\t\t\t// Guess file type based on ID3 header for backward compatibility\n\t\t\t\treturn {\n\t\t\t\t\text: 'mp3',\n\t\t\t\t\tmime: 'audio/mpeg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tawait tokenizer.ignore(id3HeaderLength);\n\t\t\treturn this.fromTokenizer(tokenizer); // Skip ID3 header, recursion\n\t\t}\n\n\t\t// Musepack, SV7\n\t\tif (this.checkString('MP+')) {\n\t\t\treturn {\n\t\t\t\text: 'mpc',\n\t\t\t\tmime: 'audio/x-musepack',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\t(this.buffer[0] === 0x43 || this.buffer[0] === 0x46)\n\t\t\t&& this.check([0x57, 0x53], {offset: 1})\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'swf',\n\t\t\t\tmime: 'application/x-shockwave-flash',\n\t\t\t};\n\t\t}\n\n\t\t// -- 4-byte signatures --\n\n\t\t// Requires a sample size of 4 bytes\n\t\tif (this.check([0xFF, 0xD8, 0xFF])) {\n\t\t\tif (this.check([0xF7], {offset: 3})) { // JPG7/SOF55, indicating a ISO/IEC 14495 / JPEG-LS file\n\t\t\t\treturn {\n\t\t\t\t\text: 'jls',\n\t\t\t\t\tmime: 'image/jls',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\text: 'jpg',\n\t\t\t\tmime: 'image/jpeg',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x4F, 0x62, 0x6A, 0x01])) {\n\t\t\treturn {\n\t\t\t\text: 'avro',\n\t\t\t\tmime: 'application/avro',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('FLIF')) {\n\t\t\treturn {\n\t\t\t\text: 'flif',\n\t\t\t\tmime: 'image/flif',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('8BPS')) {\n\t\t\treturn {\n\t\t\t\text: 'psd',\n\t\t\t\tmime: 'image/vnd.adobe.photoshop',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('WEBP', {offset: 8})) {\n\t\t\treturn {\n\t\t\t\text: 'webp',\n\t\t\t\tmime: 'image/webp',\n\t\t\t};\n\t\t}\n\n\t\t// Musepack, SV8\n\t\tif (this.checkString('MPCK')) {\n\t\t\treturn {\n\t\t\t\text: 'mpc',\n\t\t\t\tmime: 'audio/x-musepack',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('FORM')) {\n\t\t\treturn {\n\t\t\t\text: 'aif',\n\t\t\t\tmime: 'audio/aiff',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('icns', {offset: 0})) {\n\t\t\treturn {\n\t\t\t\text: 'icns',\n\t\t\t\tmime: 'image/icns',\n\t\t\t};\n\t\t}\n\n\t\t// Zip-based file formats\n\t\t// Need to be before the `zip` check\n\t\tif (this.check([0x50, 0x4B, 0x3, 0x4])) { // Local file header signature\n\t\t\ttry {\n\t\t\t\twhile (tokenizer.position + 30 < tokenizer.fileInfo.size) {\n\t\t\t\t\tawait tokenizer.readBuffer(this.buffer, {length: 30});\n\n\t\t\t\t\tconst view = new DataView(this.buffer.buffer);\n\n\t\t\t\t\t// https://en.wikipedia.org/wiki/Zip_(file_format)#File_headers\n\t\t\t\t\tconst zipHeader = {\n\t\t\t\t\t\tcompressedSize: view.getUint32(18, true),\n\t\t\t\t\t\tuncompressedSize: view.getUint32(22, true),\n\t\t\t\t\t\tfilenameLength: view.getUint16(26, true),\n\t\t\t\t\t\textraFieldLength: view.getUint16(28, true),\n\t\t\t\t\t};\n\n\t\t\t\t\tzipHeader.filename = await tokenizer.readToken(new Token.StringType(zipHeader.filenameLength, 'utf-8'));\n\t\t\t\t\tawait tokenizer.ignore(zipHeader.extraFieldLength);\n\n\t\t\t\t\tif (/classes\\d*\\.dex/.test(zipHeader.filename)) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'apk',\n\t\t\t\t\t\t\tmime: 'application/vnd.android.package-archive',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// Assumes signed `.xpi` from addons.mozilla.org\n\t\t\t\t\tif (zipHeader.filename === 'META-INF/mozilla.rsa') {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'xpi',\n\t\t\t\t\t\t\tmime: 'application/x-xpinstall',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (zipHeader.filename.endsWith('.rels') || zipHeader.filename.endsWith('.xml')) {\n\t\t\t\t\t\tconst type = zipHeader.filename.split('/')[0];\n\t\t\t\t\t\tswitch (type) {\n\t\t\t\t\t\t\tcase '_rels':\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\tcase 'word':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'docx',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'ppt':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'pptx',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'xl':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'xlsx',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'visio':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'vsdx',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.visio',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (zipHeader.filename.startsWith('xl/')) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'xlsx',\n\t\t\t\t\t\t\tmime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (zipHeader.filename.startsWith('3D/') && zipHeader.filename.endsWith('.model')) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: '3mf',\n\t\t\t\t\t\t\tmime: 'model/3mf',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// The docx, xlsx and pptx file types extend the Office Open XML file format:\n\t\t\t\t\t// https://en.wikipedia.org/wiki/Office_Open_XML_file_formats\n\t\t\t\t\t// We look for:\n\t\t\t\t\t// - one entry named '[Content_Types].xml' or '_rels/.rels',\n\t\t\t\t\t// - one entry indicating specific type of file.\n\t\t\t\t\t// MS Office, OpenOffice and LibreOffice may put the parts in different order, so the check should not rely on it.\n\t\t\t\t\tif (zipHeader.filename === 'mimetype' && zipHeader.compressedSize === zipHeader.uncompressedSize) {\n\t\t\t\t\t\tlet mimeType = await tokenizer.readToken(new Token.StringType(zipHeader.compressedSize, 'utf-8'));\n\t\t\t\t\t\tmimeType = mimeType.trim();\n\n\t\t\t\t\t\tswitch (mimeType) {\n\t\t\t\t\t\t\tcase 'application/epub+zip':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'epub',\n\t\t\t\t\t\t\t\t\tmime: 'application/epub+zip',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'application/vnd.oasis.opendocument.text':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'odt',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.oasis.opendocument.text',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'application/vnd.oasis.opendocument.spreadsheet':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'ods',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.oasis.opendocument.spreadsheet',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tcase 'application/vnd.oasis.opendocument.presentation':\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\text: 'odp',\n\t\t\t\t\t\t\t\t\tmime: 'application/vnd.oasis.opendocument.presentation',\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Try to find next header manually when current one is corrupted\n\t\t\t\t\tif (zipHeader.compressedSize === 0) {\n\t\t\t\t\t\tlet nextHeaderIndex = -1;\n\n\t\t\t\t\t\twhile (nextHeaderIndex < 0 && (tokenizer.position < tokenizer.fileInfo.size)) {\n\t\t\t\t\t\t\tawait tokenizer.peekBuffer(this.buffer, {mayBeLess: true});\n\n\t\t\t\t\t\t\tnextHeaderIndex = indexOf(this.buffer, new Uint8Array([0x50, 0x4B, 0x03, 0x04]));\n\n\t\t\t\t\t\t\t// Move position to the next header if found, skip the whole buffer otherwise\n\t\t\t\t\t\t\tawait tokenizer.ignore(nextHeaderIndex >= 0 ? nextHeaderIndex : this.buffer.length);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait tokenizer.ignore(zipHeader.compressedSize);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof strtok3.EndOfStreamError)) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\text: 'zip',\n\t\t\t\tmime: 'application/zip',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('OggS')) {\n\t\t\t// This is an OGG container\n\t\t\tawait tokenizer.ignore(28);\n\t\t\tconst type = new Uint8Array(8);\n\t\t\tawait tokenizer.readBuffer(type);\n\n\t\t\t// Needs to be before `ogg` check\n\t\t\tif (_check(type, [0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'opus',\n\t\t\t\t\tmime: 'audio/ogg; codecs=opus',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If ' theora' in header.\n\t\t\tif (_check(type, [0x80, 0x74, 0x68, 0x65, 0x6F, 0x72, 0x61])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'ogv',\n\t\t\t\t\tmime: 'video/ogg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If '\\x01video' in header.\n\t\t\tif (_check(type, [0x01, 0x76, 0x69, 0x64, 0x65, 0x6F, 0x00])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'ogm',\n\t\t\t\t\tmime: 'video/ogg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If ' FLAC' in header  https://xiph.org/flac/faq.html\n\t\t\tif (_check(type, [0x7F, 0x46, 0x4C, 0x41, 0x43])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'oga',\n\t\t\t\t\tmime: 'audio/ogg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// 'Speex  ' in header https://en.wikipedia.org/wiki/Speex\n\t\t\tif (_check(type, [0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'spx',\n\t\t\t\t\tmime: 'audio/ogg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If '\\x01vorbis' in header\n\t\t\tif (_check(type, [0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73])) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'ogg',\n\t\t\t\t\tmime: 'audio/ogg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Default OGG container https://www.iana.org/assignments/media-types/application/ogg\n\t\t\treturn {\n\t\t\t\text: 'ogx',\n\t\t\t\tmime: 'application/ogg',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.check([0x50, 0x4B])\n\t\t\t&& (this.buffer[2] === 0x3 || this.buffer[2] === 0x5 || this.buffer[2] === 0x7)\n\t\t\t&& (this.buffer[3] === 0x4 || this.buffer[3] === 0x6 || this.buffer[3] === 0x8)\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'zip',\n\t\t\t\tmime: 'application/zip',\n\t\t\t};\n\t\t}\n\n\t\t//\n\n\t\t// File Type Box (https://en.wikipedia.org/wiki/ISO_base_media_file_format)\n\t\t// It's not required to be first, but it's recommended to be. Almost all ISO base media files start with `ftyp` box.\n\t\t// `ftyp` box must contain a brand major identifier, which must consist of ISO 8859-1 printable characters.\n\t\t// Here we check for 8859-1 printable characters (for simplicity, it's a mask which also catches one non-printable character).\n\t\tif (\n\t\t\tthis.checkString('ftyp', {offset: 4})\n\t\t\t&& (this.buffer[8] & 0x60) !== 0x00 // Brand major, first character ASCII?\n\t\t) {\n\t\t\t// They all can have MIME `video/mp4` except `application/mp4` special-case which is hard to detect.\n\t\t\t// For some cases, we're specific, everything else falls to `video/mp4` with `mp4` extension.\n\t\t\tconst brandMajor = new Token.StringType(4, 'latin1').get(this.buffer, 8).replace('\\0', ' ').trim();\n\t\t\tswitch (brandMajor) {\n\t\t\t\tcase 'avif':\n\t\t\t\tcase 'avis':\n\t\t\t\t\treturn {ext: 'avif', mime: 'image/avif'};\n\t\t\t\tcase 'mif1':\n\t\t\t\t\treturn {ext: 'heic', mime: 'image/heif'};\n\t\t\t\tcase 'msf1':\n\t\t\t\t\treturn {ext: 'heic', mime: 'image/heif-sequence'};\n\t\t\t\tcase 'heic':\n\t\t\t\tcase 'heix':\n\t\t\t\t\treturn {ext: 'heic', mime: 'image/heic'};\n\t\t\t\tcase 'hevc':\n\t\t\t\tcase 'hevx':\n\t\t\t\t\treturn {ext: 'heic', mime: 'image/heic-sequence'};\n\t\t\t\tcase 'qt':\n\t\t\t\t\treturn {ext: 'mov', mime: 'video/quicktime'};\n\t\t\t\tcase 'M4V':\n\t\t\t\tcase 'M4VH':\n\t\t\t\tcase 'M4VP':\n\t\t\t\t\treturn {ext: 'm4v', mime: 'video/x-m4v'};\n\t\t\t\tcase 'M4P':\n\t\t\t\t\treturn {ext: 'm4p', mime: 'video/mp4'};\n\t\t\t\tcase 'M4B':\n\t\t\t\t\treturn {ext: 'm4b', mime: 'audio/mp4'};\n\t\t\t\tcase 'M4A':\n\t\t\t\t\treturn {ext: 'm4a', mime: 'audio/x-m4a'};\n\t\t\t\tcase 'F4V':\n\t\t\t\t\treturn {ext: 'f4v', mime: 'video/mp4'};\n\t\t\t\tcase 'F4P':\n\t\t\t\t\treturn {ext: 'f4p', mime: 'video/mp4'};\n\t\t\t\tcase 'F4A':\n\t\t\t\t\treturn {ext: 'f4a', mime: 'audio/mp4'};\n\t\t\t\tcase 'F4B':\n\t\t\t\t\treturn {ext: 'f4b', mime: 'audio/mp4'};\n\t\t\t\tcase 'crx':\n\t\t\t\t\treturn {ext: 'cr3', mime: 'image/x-canon-cr3'};\n\t\t\t\tdefault:\n\t\t\t\t\tif (brandMajor.startsWith('3g')) {\n\t\t\t\t\t\tif (brandMajor.startsWith('3g2')) {\n\t\t\t\t\t\t\treturn {ext: '3g2', mime: 'video/3gpp2'};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn {ext: '3gp', mime: 'video/3gpp'};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {ext: 'mp4', mime: 'video/mp4'};\n\t\t\t}\n\t\t}\n\n\t\tif (this.checkString('MThd')) {\n\t\t\treturn {\n\t\t\t\text: 'mid',\n\t\t\t\tmime: 'audio/midi',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.checkString('wOFF')\n\t\t\t&& (\n\t\t\t\tthis.check([0x00, 0x01, 0x00, 0x00], {offset: 4})\n\t\t\t\t|| this.checkString('OTTO', {offset: 4})\n\t\t\t)\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'woff',\n\t\t\t\tmime: 'font/woff',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.checkString('wOF2')\n\t\t\t&& (\n\t\t\t\tthis.check([0x00, 0x01, 0x00, 0x00], {offset: 4})\n\t\t\t\t|| this.checkString('OTTO', {offset: 4})\n\t\t\t)\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'woff2',\n\t\t\t\tmime: 'font/woff2',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xD4, 0xC3, 0xB2, 0xA1]) || this.check([0xA1, 0xB2, 0xC3, 0xD4])) {\n\t\t\treturn {\n\t\t\t\text: 'pcap',\n\t\t\t\tmime: 'application/vnd.tcpdump.pcap',\n\t\t\t};\n\t\t}\n\n\t\t// Sony DSD Stream File (DSF)\n\t\tif (this.checkString('DSD ')) {\n\t\t\treturn {\n\t\t\t\text: 'dsf',\n\t\t\t\tmime: 'audio/x-dsf', // Non-standard\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('LZIP')) {\n\t\t\treturn {\n\t\t\t\text: 'lz',\n\t\t\t\tmime: 'application/x-lzip',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('fLaC')) {\n\t\t\treturn {\n\t\t\t\text: 'flac',\n\t\t\t\tmime: 'audio/x-flac',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x42, 0x50, 0x47, 0xFB])) {\n\t\t\treturn {\n\t\t\t\text: 'bpg',\n\t\t\t\tmime: 'image/bpg',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('wvpk')) {\n\t\t\treturn {\n\t\t\t\text: 'wv',\n\t\t\t\tmime: 'audio/wavpack',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('%PDF')) {\n\t\t\ttry {\n\t\t\t\tawait tokenizer.ignore(1350);\n\t\t\t\tconst maxBufferSize = 10 * 1024 * 1024;\n\t\t\t\tconst buffer = new Uint8Array(Math.min(maxBufferSize, tokenizer.fileInfo.size));\n\t\t\t\tawait tokenizer.readBuffer(buffer, {mayBeLess: true});\n\n\t\t\t\t// Check if this is an Adobe Illustrator file\n\t\t\t\tif (includes(buffer, new TextEncoder().encode('AIPrivateData'))) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'ai',\n\t\t\t\t\t\tmime: 'application/postscript',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Swallow end of stream error if file is too small for the Adobe AI check\n\t\t\t\tif (!(error instanceof strtok3.EndOfStreamError)) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Assume this is just a normal PDF\n\t\t\treturn {\n\t\t\t\text: 'pdf',\n\t\t\t\tmime: 'application/pdf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x00, 0x61, 0x73, 0x6D])) {\n\t\t\treturn {\n\t\t\t\text: 'wasm',\n\t\t\t\tmime: 'application/wasm',\n\t\t\t};\n\t\t}\n\n\t\t// TIFF, little-endian type\n\t\tif (this.check([0x49, 0x49])) {\n\t\t\tconst fileType = await this.readTiffHeader(false);\n\t\t\tif (fileType) {\n\t\t\t\treturn fileType;\n\t\t\t}\n\t\t}\n\n\t\t// TIFF, big-endian type\n\t\tif (this.check([0x4D, 0x4D])) {\n\t\t\tconst fileType = await this.readTiffHeader(true);\n\t\t\tif (fileType) {\n\t\t\t\treturn fileType;\n\t\t\t}\n\t\t}\n\n\t\tif (this.checkString('MAC ')) {\n\t\t\treturn {\n\t\t\t\text: 'ape',\n\t\t\t\tmime: 'audio/ape',\n\t\t\t};\n\t\t}\n\n\t\t// https://github.com/file/file/blob/master/magic/Magdir/matroska\n\t\tif (this.check([0x1A, 0x45, 0xDF, 0xA3])) { // Root element: EBML\n\t\t\tasync function readField() {\n\t\t\t\tconst msb = await tokenizer.peekNumber(Token.UINT8);\n\t\t\t\tlet mask = 0x80;\n\t\t\t\tlet ic = 0; // 0 = A, 1 = B, 2 = C, 3 = D\n\n\t\t\t\twhile ((msb & mask) === 0 && mask !== 0) {\n\t\t\t\t\t++ic;\n\t\t\t\t\tmask >>= 1;\n\t\t\t\t}\n\n\t\t\t\tconst id = new Uint8Array(ic + 1);\n\t\t\t\tawait tokenizer.readBuffer(id);\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tasync function readElement() {\n\t\t\t\tconst idField = await readField();\n\t\t\t\tconst lengthField = await readField();\n\n\t\t\t\tlengthField[0] ^= 0x80 >> (lengthField.length - 1);\n\t\t\t\tconst nrLength = Math.min(6, lengthField.length); // JavaScript can max read 6 bytes integer\n\n\t\t\t\tconst idView = new DataView(idField.buffer);\n\t\t\t\tconst lengthView = new DataView(lengthField.buffer, lengthField.length - nrLength, nrLength);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: getUintBE(idView),\n\t\t\t\t\tlen: getUintBE(lengthView),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tasync function readChildren(children) {\n\t\t\t\twhile (children > 0) {\n\t\t\t\t\tconst element = await readElement();\n\t\t\t\t\tif (element.id === 0x42_82) {\n\t\t\t\t\t\tconst rawValue = await tokenizer.readToken(new Token.StringType(element.len));\n\t\t\t\t\t\treturn rawValue.replaceAll(/\\00.*$/g, ''); // Return DocType\n\t\t\t\t\t}\n\n\t\t\t\t\tawait tokenizer.ignore(element.len); // ignore payload\n\t\t\t\t\t--children;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst re = await readElement();\n\t\t\tconst docType = await readChildren(re.len);\n\n\t\t\tswitch (docType) {\n\t\t\t\tcase 'webm':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'webm',\n\t\t\t\t\t\tmime: 'video/webm',\n\t\t\t\t\t};\n\n\t\t\t\tcase 'matroska':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'mkv',\n\t\t\t\t\t\tmime: 'video/x-matroska',\n\t\t\t\t\t};\n\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// RIFF file format which might be AVI, WAV, QCP, etc\n\t\tif (this.check([0x52, 0x49, 0x46, 0x46])) {\n\t\t\tif (this.check([0x41, 0x56, 0x49], {offset: 8})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'avi',\n\t\t\t\t\tmime: 'video/vnd.avi',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (this.check([0x57, 0x41, 0x56, 0x45], {offset: 8})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'wav',\n\t\t\t\t\tmime: 'audio/wav',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// QLCM, QCP file\n\t\t\tif (this.check([0x51, 0x4C, 0x43, 0x4D], {offset: 8})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'qcp',\n\t\t\t\t\tmime: 'audio/qcelp',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (this.checkString('SQLi')) {\n\t\t\treturn {\n\t\t\t\text: 'sqlite',\n\t\t\t\tmime: 'application/x-sqlite3',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x4E, 0x45, 0x53, 0x1A])) {\n\t\t\treturn {\n\t\t\t\text: 'nes',\n\t\t\t\tmime: 'application/x-nintendo-nes-rom',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('Cr24')) {\n\t\t\treturn {\n\t\t\t\text: 'crx',\n\t\t\t\tmime: 'application/x-google-chrome-extension',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.checkString('MSCF')\n\t\t\t|| this.checkString('ISc(')\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'cab',\n\t\t\t\tmime: 'application/vnd.ms-cab-compressed',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xED, 0xAB, 0xEE, 0xDB])) {\n\t\t\treturn {\n\t\t\t\text: 'rpm',\n\t\t\t\tmime: 'application/x-rpm',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xC5, 0xD0, 0xD3, 0xC6])) {\n\t\t\treturn {\n\t\t\t\text: 'eps',\n\t\t\t\tmime: 'application/eps',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x28, 0xB5, 0x2F, 0xFD])) {\n\t\t\treturn {\n\t\t\t\text: 'zst',\n\t\t\t\tmime: 'application/zstd',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x7F, 0x45, 0x4C, 0x46])) {\n\t\t\treturn {\n\t\t\t\text: 'elf',\n\t\t\t\tmime: 'application/x-elf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x21, 0x42, 0x44, 0x4E])) {\n\t\t\treturn {\n\t\t\t\text: 'pst',\n\t\t\t\tmime: 'application/vnd.ms-outlook',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('PAR1')) {\n\t\t\treturn {\n\t\t\t\text: 'parquet',\n\t\t\t\tmime: 'application/x-parquet',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xCF, 0xFA, 0xED, 0xFE])) {\n\t\t\treturn {\n\t\t\t\text: 'macho',\n\t\t\t\tmime: 'application/x-mach-binary',\n\t\t\t};\n\t\t}\n\n\t\t// -- 5-byte signatures --\n\n\t\tif (this.check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'otf',\n\t\t\t\tmime: 'font/otf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('#!AMR')) {\n\t\t\treturn {\n\t\t\t\text: 'amr',\n\t\t\t\tmime: 'audio/amr',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('{\\\\rtf')) {\n\t\t\treturn {\n\t\t\t\text: 'rtf',\n\t\t\t\tmime: 'application/rtf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x46, 0x4C, 0x56, 0x01])) {\n\t\t\treturn {\n\t\t\t\text: 'flv',\n\t\t\t\tmime: 'video/x-flv',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('IMPM')) {\n\t\t\treturn {\n\t\t\t\text: 'it',\n\t\t\t\tmime: 'audio/x-it',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.checkString('-lh0-', {offset: 2})\n\t\t\t|| this.checkString('-lh1-', {offset: 2})\n\t\t\t|| this.checkString('-lh2-', {offset: 2})\n\t\t\t|| this.checkString('-lh3-', {offset: 2})\n\t\t\t|| this.checkString('-lh4-', {offset: 2})\n\t\t\t|| this.checkString('-lh5-', {offset: 2})\n\t\t\t|| this.checkString('-lh6-', {offset: 2})\n\t\t\t|| this.checkString('-lh7-', {offset: 2})\n\t\t\t|| this.checkString('-lzs-', {offset: 2})\n\t\t\t|| this.checkString('-lz4-', {offset: 2})\n\t\t\t|| this.checkString('-lz5-', {offset: 2})\n\t\t\t|| this.checkString('-lhd-', {offset: 2})\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'lzh',\n\t\t\t\tmime: 'application/x-lzh-compressed',\n\t\t\t};\n\t\t}\n\n\t\t// MPEG program stream (PS or MPEG-PS)\n\t\tif (this.check([0x00, 0x00, 0x01, 0xBA])) {\n\t\t\t//  MPEG-PS, MPEG-1 Part 1\n\t\t\tif (this.check([0x21], {offset: 4, mask: [0xF1]})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'mpg', // May also be .ps, .mpeg\n\t\t\t\t\tmime: 'video/MP1S',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// MPEG-PS, MPEG-2 Part 1\n\t\t\tif (this.check([0x44], {offset: 4, mask: [0xC4]})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'mpg', // May also be .mpg, .m2p, .vob or .sub\n\t\t\t\t\tmime: 'video/MP2P',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (this.checkString('ITSF')) {\n\t\t\treturn {\n\t\t\t\text: 'chm',\n\t\t\t\tmime: 'application/vnd.ms-htmlhelp',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xCA, 0xFE, 0xBA, 0xBE])) {\n\t\t\treturn {\n\t\t\t\text: 'class',\n\t\t\t\tmime: 'application/java-vm',\n\t\t\t};\n\t\t}\n\n\t\t// -- 6-byte signatures --\n\n\t\tif (this.check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'xz',\n\t\t\t\tmime: 'application/x-xz',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('<?xml ')) {\n\t\t\treturn {\n\t\t\t\text: 'xml',\n\t\t\t\tmime: 'application/xml',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {\n\t\t\treturn {\n\t\t\t\text: '7z',\n\t\t\t\tmime: 'application/x-7z-compressed',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7])\n\t\t\t&& (this.buffer[6] === 0x0 || this.buffer[6] === 0x1)\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'rar',\n\t\t\t\tmime: 'application/x-rar-compressed',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('solid ')) {\n\t\t\treturn {\n\t\t\t\text: 'stl',\n\t\t\t\tmime: 'model/stl',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('AC')) {\n\t\t\tconst version = new Token.StringType(4, 'latin1').get(this.buffer, 2);\n\t\t\tif (version.match('^d*') && version >= 1000 && version <= 1050) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'dwg',\n\t\t\t\t\tmime: 'image/vnd.dwg',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (this.checkString('070707')) {\n\t\t\treturn {\n\t\t\t\text: 'cpio',\n\t\t\t\tmime: 'application/x-cpio',\n\t\t\t};\n\t\t}\n\n\t\t// -- 7-byte signatures --\n\n\t\tif (this.checkString('BLENDER')) {\n\t\t\treturn {\n\t\t\t\text: 'blend',\n\t\t\t\tmime: 'application/x-blender',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('!<arch>')) {\n\t\t\tawait tokenizer.ignore(8);\n\t\t\tconst string = await tokenizer.readToken(new Token.StringType(13, 'ascii'));\n\t\t\tif (string === 'debian-binary') {\n\t\t\t\treturn {\n\t\t\t\t\text: 'deb',\n\t\t\t\t\tmime: 'application/x-deb',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\text: 'ar',\n\t\t\t\tmime: 'application/x-unix-archive',\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.checkString('WEBVTT')\n\t\t\t&&\t(\n\t\t\t\t// One of LF, CR, tab, space, or end of file must follow \"WEBVTT\" per the spec (see `fixture/fixture-vtt-*.vtt` for examples). Note that `\\0` is technically the null character (there is no such thing as an EOF character). However, checking for `\\0` gives us the same result as checking for the end of the stream.\n\t\t\t\t(['\\n', '\\r', '\\t', ' ', '\\0'].some(char7 => this.checkString(char7, {offset: 6}))))\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'vtt',\n\t\t\t\tmime: 'text/vtt',\n\t\t\t};\n\t\t}\n\n\t\t// -- 8-byte signatures --\n\n\t\tif (this.check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {\n\t\t\t// APNG format (https://wiki.mozilla.org/APNG_Specification)\n\t\t\t// 1. Find the first IDAT (image data) chunk (49 44 41 54)\n\t\t\t// 2. Check if there is an \"acTL\" chunk before the IDAT one (61 63 54 4C)\n\n\t\t\t// Offset calculated as follows:\n\t\t\t// - 8 bytes: PNG signature\n\t\t\t// - 4 (length) + 4 (chunk type) + 13 (chunk data) + 4 (CRC): IHDR chunk\n\n\t\t\tawait tokenizer.ignore(8); // ignore PNG signature\n\n\t\t\tasync function readChunkHeader() {\n\t\t\t\treturn {\n\t\t\t\t\tlength: await tokenizer.readToken(Token.INT32_BE),\n\t\t\t\t\ttype: await tokenizer.readToken(new Token.StringType(4, 'latin1')),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdo {\n\t\t\t\tconst chunk = await readChunkHeader();\n\t\t\t\tif (chunk.length < 0) {\n\t\t\t\t\treturn; // Invalid chunk length\n\t\t\t\t}\n\n\t\t\t\tswitch (chunk.type) {\n\t\t\t\t\tcase 'IDAT':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'png',\n\t\t\t\t\t\t\tmime: 'image/png',\n\t\t\t\t\t\t};\n\t\t\t\t\tcase 'acTL':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'apng',\n\t\t\t\t\t\t\tmime: 'image/apng',\n\t\t\t\t\t\t};\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tawait tokenizer.ignore(chunk.length + 4); // Ignore chunk-data + CRC\n\t\t\t\t}\n\t\t\t} while (tokenizer.position + 8 < tokenizer.fileInfo.size);\n\n\t\t\treturn {\n\t\t\t\text: 'png',\n\t\t\t\tmime: 'image/png',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x41, 0x52, 0x52, 0x4F, 0x57, 0x31, 0x00, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'arrow',\n\t\t\t\tmime: 'application/x-apache-arrow',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x67, 0x6C, 0x54, 0x46, 0x02, 0x00, 0x00, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'glb',\n\t\t\t\tmime: 'model/gltf-binary',\n\t\t\t};\n\t\t}\n\n\t\t// `mov` format variants\n\t\tif (\n\t\t\tthis.check([0x66, 0x72, 0x65, 0x65], {offset: 4}) // `free`\n\t\t\t|| this.check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) // `mdat` MJPEG\n\t\t\t|| this.check([0x6D, 0x6F, 0x6F, 0x76], {offset: 4}) // `moov`\n\t\t\t|| this.check([0x77, 0x69, 0x64, 0x65], {offset: 4}) // `wide`\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'mov',\n\t\t\t\tmime: 'video/quicktime',\n\t\t\t};\n\t\t}\n\n\t\t// -- 9-byte signatures --\n\n\t\tif (this.check([0x49, 0x49, 0x52, 0x4F, 0x08, 0x00, 0x00, 0x00, 0x18])) {\n\t\t\treturn {\n\t\t\t\text: 'orf',\n\t\t\t\tmime: 'image/x-olympus-orf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('gimp xcf ')) {\n\t\t\treturn {\n\t\t\t\text: 'xcf',\n\t\t\t\tmime: 'image/x-xcf',\n\t\t\t};\n\t\t}\n\n\t\t// -- 12-byte signatures --\n\n\t\tif (this.check([0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8])) {\n\t\t\treturn {\n\t\t\t\text: 'rw2',\n\t\t\t\tmime: 'image/x-panasonic-rw2',\n\t\t\t};\n\t\t}\n\n\t\t// ASF_Header_Object first 80 bytes\n\t\tif (this.check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {\n\t\t\tasync function readHeader() {\n\t\t\t\tconst guid = new Uint8Array(16);\n\t\t\t\tawait tokenizer.readBuffer(guid);\n\t\t\t\treturn {\n\t\t\t\t\tid: guid,\n\t\t\t\t\tsize: Number(await tokenizer.readToken(Token.UINT64_LE)),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tawait tokenizer.ignore(30);\n\t\t\t// Search for header should be in first 1KB of file.\n\t\t\twhile (tokenizer.position + 24 < tokenizer.fileInfo.size) {\n\t\t\t\tconst header = await readHeader();\n\t\t\t\tlet payload = header.size - 24;\n\t\t\t\tif (_check(header.id, [0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65])) {\n\t\t\t\t\t// Sync on Stream-Properties-Object (B7DC0791-A9B7-11CF-8EE6-00C00C205365)\n\t\t\t\t\tconst typeId = new Uint8Array(16);\n\t\t\t\t\tpayload -= await tokenizer.readBuffer(typeId);\n\n\t\t\t\t\tif (_check(typeId, [0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B])) {\n\t\t\t\t\t\t// Found audio:\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'asf',\n\t\t\t\t\t\t\tmime: 'audio/x-ms-asf',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tif (_check(typeId, [0xC0, 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B])) {\n\t\t\t\t\t\t// Found video:\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'asf',\n\t\t\t\t\t\t\tmime: 'video/x-ms-asf',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tawait tokenizer.ignore(payload);\n\t\t\t}\n\n\t\t\t// Default to ASF generic extension\n\t\t\treturn {\n\t\t\t\text: 'asf',\n\t\t\t\tmime: 'application/vnd.ms-asf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A])) {\n\t\t\treturn {\n\t\t\t\text: 'ktx',\n\t\t\t\tmime: 'image/ktx',\n\t\t\t};\n\t\t}\n\n\t\tif ((this.check([0x7E, 0x10, 0x04]) || this.check([0x7E, 0x18, 0x04])) && this.check([0x30, 0x4D, 0x49, 0x45], {offset: 4})) {\n\t\t\treturn {\n\t\t\t\text: 'mie',\n\t\t\t\tmime: 'application/x-mie',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x27, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], {offset: 2})) {\n\t\t\treturn {\n\t\t\t\text: 'shp',\n\t\t\t\tmime: 'application/x-esri-shape',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xFF, 0x4F, 0xFF, 0x51])) {\n\t\t\treturn {\n\t\t\t\text: 'j2c',\n\t\t\t\tmime: 'image/j2c',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A])) {\n\t\t\t// JPEG-2000 family\n\n\t\t\tawait tokenizer.ignore(20);\n\t\t\tconst type = await tokenizer.readToken(new Token.StringType(4, 'ascii'));\n\t\t\tswitch (type) {\n\t\t\t\tcase 'jp2 ':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'jp2',\n\t\t\t\t\t\tmime: 'image/jp2',\n\t\t\t\t\t};\n\t\t\t\tcase 'jpx ':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'jpx',\n\t\t\t\t\t\tmime: 'image/jpx',\n\t\t\t\t\t};\n\t\t\t\tcase 'jpm ':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'jpm',\n\t\t\t\t\t\tmime: 'image/jpm',\n\t\t\t\t\t};\n\t\t\t\tcase 'mjp2':\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'mj2',\n\t\t\t\t\t\tmime: 'image/mj2',\n\t\t\t\t\t};\n\t\t\t\tdefault:\n\t\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tthis.check([0xFF, 0x0A])\n\t\t\t|| this.check([0x00, 0x00, 0x00, 0x0C, 0x4A, 0x58, 0x4C, 0x20, 0x0D, 0x0A, 0x87, 0x0A])\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'jxl',\n\t\t\t\tmime: 'image/jxl',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xFE, 0xFF])) { // UTF-16-BOM-LE\n\t\t\tif (this.check([0, 60, 0, 63, 0, 120, 0, 109, 0, 108], {offset: 2})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'xml',\n\t\t\t\t\tmime: 'application/xml',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn undefined; // Some unknown text based format\n\t\t}\n\n\t\t// -- Unsafe signatures --\n\n\t\tif (\n\t\t\tthis.check([0x0, 0x0, 0x1, 0xBA])\n\t\t\t|| this.check([0x0, 0x0, 0x1, 0xB3])\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'mpg',\n\t\t\t\tmime: 'video/mpeg',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x00, 0x01, 0x00, 0x00, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'ttf',\n\t\t\t\tmime: 'font/ttf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x00, 0x00, 0x01, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'ico',\n\t\t\t\tmime: 'image/x-icon',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x00, 0x00, 0x02, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'cur',\n\t\t\t\tmime: 'image/x-icon',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {\n\t\t\t// Detected Microsoft Compound File Binary File (MS-CFB) Format.\n\t\t\treturn {\n\t\t\t\text: 'cfb',\n\t\t\t\tmime: 'application/x-cfb',\n\t\t\t};\n\t\t}\n\n\t\t// Increase sample size from 12 to 256.\n\t\tawait tokenizer.peekBuffer(this.buffer, {length: Math.min(256, tokenizer.fileInfo.size), mayBeLess: true});\n\n\t\tif (this.check([0x61, 0x63, 0x73, 0x70], {offset: 36})) {\n\t\t\treturn {\n\t\t\t\text: 'icc',\n\t\t\t\tmime: 'application/vnd.iccprofile',\n\t\t\t};\n\t\t}\n\n\t\t// ACE: requires 14 bytes in the buffer\n\t\tif (this.checkString('**ACE', {offset: 7}) && this.checkString('**', {offset: 12})) {\n\t\t\treturn {\n\t\t\t\text: 'ace',\n\t\t\t\tmime: 'application/x-ace-compressed',\n\t\t\t};\n\t\t}\n\n\t\t// -- 15-byte signatures --\n\n\t\tif (this.checkString('BEGIN:')) {\n\t\t\tif (this.checkString('VCARD', {offset: 6})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'vcf',\n\t\t\t\t\tmime: 'text/vcard',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (this.checkString('VCALENDAR', {offset: 6})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'ics',\n\t\t\t\t\tmime: 'text/calendar',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// `raf` is here just to keep all the raw image detectors together.\n\t\tif (this.checkString('FUJIFILMCCD-RAW')) {\n\t\t\treturn {\n\t\t\t\text: 'raf',\n\t\t\t\tmime: 'image/x-fujifilm-raf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('Extended Module:')) {\n\t\t\treturn {\n\t\t\t\text: 'xm',\n\t\t\t\tmime: 'audio/x-xm',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('Creative Voice File')) {\n\t\t\treturn {\n\t\t\t\text: 'voc',\n\t\t\t\tmime: 'audio/x-voc',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x04, 0x00, 0x00, 0x00]) && this.buffer.length >= 16) { // Rough & quick check Pickle/ASAR\n\t\t\tconst jsonSize = new DataView(this.buffer.buffer).getUint32(12, true);\n\n\t\t\tif (jsonSize > 12 && this.buffer.length >= jsonSize + 16) {\n\t\t\t\ttry {\n\t\t\t\t\tconst header = new TextDecoder().decode(this.buffer.slice(16, jsonSize + 16));\n\t\t\t\t\tconst json = JSON.parse(header);\n\t\t\t\t\t// Check if Pickle is ASAR\n\t\t\t\t\tif (json.files) { // Final check, assuring Pickle/ASAR format\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\text: 'asar',\n\t\t\t\t\t\t\tmime: 'application/x-asar',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\n\t\tif (this.check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {\n\t\t\treturn {\n\t\t\t\text: 'mxf',\n\t\t\t\tmime: 'application/mxf',\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('SCRM', {offset: 44})) {\n\t\t\treturn {\n\t\t\t\text: 's3m',\n\t\t\t\tmime: 'audio/x-s3m',\n\t\t\t};\n\t\t}\n\n\t\t// Raw MPEG-2 transport stream (188-byte packets)\n\t\tif (this.check([0x47]) && this.check([0x47], {offset: 188})) {\n\t\t\treturn {\n\t\t\t\text: 'mts',\n\t\t\t\tmime: 'video/mp2t',\n\t\t\t};\n\t\t}\n\n\t\t// Blu-ray Disc Audio-Video (BDAV) MPEG-2 transport stream has 4-byte TP_extra_header before each 188-byte packet\n\t\tif (this.check([0x47], {offset: 4}) && this.check([0x47], {offset: 196})) {\n\t\t\treturn {\n\t\t\t\text: 'mts',\n\t\t\t\tmime: 'video/mp2t',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x42, 0x4F, 0x4F, 0x4B, 0x4D, 0x4F, 0x42, 0x49], {offset: 60})) {\n\t\t\treturn {\n\t\t\t\text: 'mobi',\n\t\t\t\tmime: 'application/x-mobipocket-ebook',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x44, 0x49, 0x43, 0x4D], {offset: 128})) {\n\t\t\treturn {\n\t\t\t\text: 'dcm',\n\t\t\t\tmime: 'application/dicom',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x4C, 0x00, 0x00, 0x00, 0x01, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46])) {\n\t\t\treturn {\n\t\t\t\text: 'lnk',\n\t\t\t\tmime: 'application/x.ms.shortcut', // Invented by us\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x62, 0x6F, 0x6F, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x72, 0x6B, 0x00, 0x00, 0x00, 0x00])) {\n\t\t\treturn {\n\t\t\t\text: 'alias',\n\t\t\t\tmime: 'application/x.apple.alias', // Invented by us\n\t\t\t};\n\t\t}\n\n\t\tif (this.checkString('Kaydara FBX Binary  \\u0000')) {\n\t\t\treturn {\n\t\t\t\text: 'fbx',\n\t\t\t\tmime: 'application/x.autodesk.fbx', // Invented by us\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\tthis.check([0x4C, 0x50], {offset: 34})\n\t\t\t&& (\n\t\t\t\tthis.check([0x00, 0x00, 0x01], {offset: 8})\n\t\t\t\t|| this.check([0x01, 0x00, 0x02], {offset: 8})\n\t\t\t\t|| this.check([0x02, 0x00, 0x02], {offset: 8})\n\t\t\t)\n\t\t) {\n\t\t\treturn {\n\t\t\t\text: 'eot',\n\t\t\t\tmime: 'application/vnd.ms-fontobject',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0x06, 0x06, 0xED, 0xF5, 0xD8, 0x1D, 0x46, 0xE5, 0xBD, 0x31, 0xEF, 0xE7, 0xFE, 0x74, 0xB7, 0x1D])) {\n\t\t\treturn {\n\t\t\t\text: 'indd',\n\t\t\t\tmime: 'application/x-indesign',\n\t\t\t};\n\t\t}\n\n\t\t// Increase sample size from 256 to 512\n\t\tawait tokenizer.peekBuffer(this.buffer, {length: Math.min(512, tokenizer.fileInfo.size), mayBeLess: true});\n\n\t\t// Requires a buffer size of 512 bytes\n\t\tif (tarHeaderChecksumMatches(this.buffer)) {\n\t\t\treturn {\n\t\t\t\text: 'tar',\n\t\t\t\tmime: 'application/x-tar',\n\t\t\t};\n\t\t}\n\n\t\tif (this.check([0xFF, 0xFE])) { // UTF-16-BOM-BE\n\t\t\tif (this.check([60, 0, 63, 0, 120, 0, 109, 0, 108, 0], {offset: 2})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'xml',\n\t\t\t\t\tmime: 'application/xml',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (this.check([0xFF, 0x0E, 0x53, 0x00, 0x6B, 0x00, 0x65, 0x00, 0x74, 0x00, 0x63, 0x00, 0x68, 0x00, 0x55, 0x00, 0x70, 0x00, 0x20, 0x00, 0x4D, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6C, 0x00], {offset: 2})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'skp',\n\t\t\t\t\tmime: 'application/vnd.sketchup.skp',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn undefined; // Some text based format\n\t\t}\n\n\t\tif (this.checkString('-----BEGIN PGP MESSAGE-----')) {\n\t\t\treturn {\n\t\t\t\text: 'pgp',\n\t\t\t\tmime: 'application/pgp-encrypted',\n\t\t\t};\n\t\t}\n\n\t\t// Check MPEG 1 or 2 Layer 3 header, or 'layer 0' for ADTS (MPEG sync-word 0xFFE)\n\t\tif (this.buffer.length >= 2 && this.check([0xFF, 0xE0], {offset: 0, mask: [0xFF, 0xE0]})) {\n\t\t\tif (this.check([0x10], {offset: 1, mask: [0x16]})) {\n\t\t\t\t// Check for (ADTS) MPEG-2\n\t\t\t\tif (this.check([0x08], {offset: 1, mask: [0x08]})) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'aac',\n\t\t\t\t\t\tmime: 'audio/aac',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// Must be (ADTS) MPEG-4\n\t\t\t\treturn {\n\t\t\t\t\text: 'aac',\n\t\t\t\t\tmime: 'audio/aac',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// MPEG 1 or 2 Layer 3 header\n\t\t\t// Check for MPEG layer 3\n\t\t\tif (this.check([0x02], {offset: 1, mask: [0x06]})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'mp3',\n\t\t\t\t\tmime: 'audio/mpeg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check for MPEG layer 2\n\t\t\tif (this.check([0x04], {offset: 1, mask: [0x06]})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'mp2',\n\t\t\t\t\tmime: 'audio/mpeg',\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check for MPEG layer 1\n\t\t\tif (this.check([0x06], {offset: 1, mask: [0x06]})) {\n\t\t\t\treturn {\n\t\t\t\t\text: 'mp1',\n\t\t\t\t\tmime: 'audio/mpeg',\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t}\n\n\tasync readTiffTag(bigEndian) {\n\t\tconst tagId = await this.tokenizer.readToken(bigEndian ? Token.UINT16_BE : Token.UINT16_LE);\n\t\tthis.tokenizer.ignore(10);\n\t\tswitch (tagId) {\n\t\t\tcase 50_341:\n\t\t\t\treturn {\n\t\t\t\t\text: 'arw',\n\t\t\t\t\tmime: 'image/x-sony-arw',\n\t\t\t\t};\n\t\t\tcase 50_706:\n\t\t\t\treturn {\n\t\t\t\t\text: 'dng',\n\t\t\t\t\tmime: 'image/x-adobe-dng',\n\t\t\t\t};\n\t\t\tdefault:\n\t\t}\n\t}\n\n\tasync readTiffIFD(bigEndian) {\n\t\tconst numberOfTags = await this.tokenizer.readToken(bigEndian ? Token.UINT16_BE : Token.UINT16_LE);\n\t\tfor (let n = 0; n < numberOfTags; ++n) {\n\t\t\tconst fileType = await this.readTiffTag(bigEndian);\n\t\t\tif (fileType) {\n\t\t\t\treturn fileType;\n\t\t\t}\n\t\t}\n\t}\n\n\tasync readTiffHeader(bigEndian) {\n\t\tconst version = (bigEndian ? Token.UINT16_BE : Token.UINT16_LE).get(this.buffer, 2);\n\t\tconst ifdOffset = (bigEndian ? Token.UINT32_BE : Token.UINT32_LE).get(this.buffer, 4);\n\n\t\tif (version === 42) {\n\t\t\t// TIFF file header\n\t\t\tif (ifdOffset >= 6) {\n\t\t\t\tif (this.checkString('CR', {offset: 8})) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'cr2',\n\t\t\t\t\t\tmime: 'image/x-canon-cr2',\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (ifdOffset >= 8 && (this.check([0x1C, 0x00, 0xFE, 0x00], {offset: 8}) || this.check([0x1F, 0x00, 0x0B, 0x00], {offset: 8}))) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\text: 'nef',\n\t\t\t\t\t\tmime: 'image/x-nikon-nef',\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait this.tokenizer.ignore(ifdOffset);\n\t\t\tconst fileType = await this.readTiffIFD(bigEndian);\n\t\t\treturn fileType ?? {\n\t\t\t\text: 'tif',\n\t\t\t\tmime: 'image/tiff',\n\t\t\t};\n\t\t}\n\n\t\tif (version === 43) {\t// Big TIFF file header\n\t\t\treturn {\n\t\t\t\text: 'tif',\n\t\t\t\tmime: 'image/tiff',\n\t\t\t};\n\t\t}\n\t}\n}\n\nexport const supportedExtensions = new Set(extensions);\nexport const supportedMimeTypes = new Set(mimeTypes);\n","/**\n * Copyright 2024 Design Barn Inc.\n */\n\n/* eslint-disable guard-for-in */\n\nimport type { Animation as AnimationData, Asset } from '@lottie-animation-community/lottie-types';\nimport type { UnzipFileFilter, Unzipped } from 'fflate';\nimport { unzip as fflateUnzip, strFromU8 } from 'fflate';\nimport { fileTypeFromBuffer } from 'file-type';\n\nimport type { ManifestV1 } from './v1/common/schemas/manifest';\nimport type { LottieStateMachine } from './v2/browser';\nimport type { Manifest as ManifestV2 } from './v2/common/schemas';\n\nexport enum ErrorCodes {\n  ASSET_NOT_FOUND = 'ASSET_NOT_FOUND',\n  INVALID_DOTLOTTIE = 'INVALID_DOTLOTTIE',\n  INVALID_STATEMACHINE = 'INVALID_STATEMACHINE',\n  INVALID_URL = 'INVALID_URL',\n}\n\nexport class DotLottieError extends Error {\n  public code: ErrorCodes | undefined;\n\n  public constructor(message: string, code?: ErrorCodes) {\n    super(message);\n    this.name = '[dotLottie-js]';\n    this.code = code;\n  }\n}\n\n/**\n * Converts a base64 string into a Uint8Array.\n *\n * @remarks\n * This function accepts a base64 string and returns a Uint8Array containing the decoded bytes.\n *\n * @param base64String - The base64-encoded string to decode.\n * @returns A Uint8Array containing the decoded bytes.\n *\n * @example\n * ```typescript\n * const base64 = 'SGVsbG8gd29ybGQ=';\n * const array = base64ToUint8Array(base64);\n * ```\n *\n * @public\n */\nexport const base64ToUint8Array = (base64String: string): Uint8Array => {\n  const withoutMeta = base64String.substring(base64String.indexOf(',') + 1);\n  const binaryString =\n    typeof window === 'undefined' ? Buffer.from(withoutMeta, 'base64').toString('binary') : atob(withoutMeta);\n\n  const uint8Array = new Uint8Array(binaryString.length);\n\n  for (let i = 0; i < binaryString.length; i += 1) {\n    uint8Array[i] = binaryString.charCodeAt(i);\n  }\n\n  return uint8Array;\n};\n\nexport const getMimeTypeFromUint8Data = async (file: Uint8Array): Promise<string | undefined> => {\n  const data = await fileTypeFromBuffer(file);\n\n  return data?.mime.toString();\n};\n\n/**\n * Determines the MIME type from a base64-encoded string.\n *\n * @remarks\n * This function accepts a base64-encoded string and determines its MIME type by looking at the first few bytes.\n *\n * @param base64 - The base64-encoded string to analyze.\n * @returns The MIME type as a string, or null if the type cannot be determined.\n *\n * @example\n * ```typescript\n * const base64 = 'data:image/jpeg;base64,...';\n * const mimeType = getMimeTypeFromBase64(base64);\n * ```\n *\n * @public\n */\nexport const getMimeTypeFromBase64 = async (base64: string): Promise<string | undefined> => {\n  const data = base64ToUint8Array(base64);\n\n  const mime = await fileTypeFromBuffer(data);\n\n  return mime?.mime.toString();\n};\n\n/**\n * Determines the file extension from a base64-encoded string.\n *\n * @remarks\n * This function accepts a base64-encoded string and determines its file extension by examining the MIME type.\n *\n * @param base64 - The base64-encoded string to analyze.\n * @returns The file extension as a string, or 'png' if the extension cannot be determined.\n *\n * @example\n * ```typescript\n * const base64 = 'data:image/jpeg;base64,...';\n * const extension = getExtensionTypeFromBase64(base64);\n * ```\n *\n * @public\n */\nexport const getExtensionTypeFromBase64 = async (base64: string): Promise<string | undefined> => {\n  const data = base64ToUint8Array(base64);\n\n  const mime = await fileTypeFromBuffer(data);\n\n  // To keep mimetype(jpeg) and extension(jpg) consistent\n  if (mime?.ext.toString() === 'jpg') {\n    return 'jpeg';\n  }\n\n  return mime?.ext.toString();\n};\n\n/**\n * Validates a given URL string.\n *\n * @remarks\n * This function accepts a URL string and checks whether it's a valid URL according to the URL constructor.\n * It returns `true` if the URL is valid, `false` otherwise.\n *\n * @param url - The URL string to validate.\n * @returns `true` if the URL is valid, `false` otherwise.\n *\n * @example\n * ```typescript\n * const url = 'https://example.com';\n * const isValid = isValidURL(url); // true\n * ```\n *\n * @public\n */\nexport const isValidURL = (url: string): boolean => {\n  try {\n    // eslint-disable-next-line no-new\n    new URL(url);\n\n    return true;\n  } catch {\n    return false;\n  }\n};\n\n/**\n * Creates a data URL from a Uint8Array.\n *\n * @remarks\n * This function accepts a Uint8Array and a file extension, then converts the Uint8Array into a base64 data URL string.\n * The mimeType is determined based on the provided file extension, or defaults to 'image/png' if the extension is not recognized.\n *\n * @param uint8Data - The Uint8Array containing the binary data.\n * @param fileExtension - The file extension used to determine the mimeType (e.g., 'png', 'jpeg').\n * @returns The data URL string.\n *\n * @example\n * ```typescript\n * const uint8Data = new Uint8Array(...);\n * const fileExtension = 'png';\n * const dataUrl = dataUrlFromU8(uint8Data, fileExtension);\n * ```\n */\nexport async function dataUrlFromU8(uint8Data: Uint8Array): Promise<string> {\n  let base64: string;\n\n  if (typeof window === 'undefined') {\n    // Using Node.js Buffer for non-browser environments\n    base64 = Buffer.from(uint8Data).toString('base64');\n  } else {\n    // Using window.btoa for browser environments\n    const binaryString = Array.prototype.map.call(uint8Data, (byte: number) => String.fromCharCode(byte)).join('');\n\n    base64 = window.btoa(binaryString);\n  }\n\n  const mimeType = await getMimeTypeFromUint8Data(uint8Data);\n\n  return `data:${mimeType};base64,${base64}`;\n}\n\n/**\n * Checks if an asset is an image asset.\n *\n * @remarks\n * This function accepts an asset object and determines whether it represents an image asset.\n * It returns `true` if it's an image asset, `false` otherwise.\n *\n * @param asset - The asset object to check.\n * @returns `true` if it's an image asset, `false` otherwise.\n *\n * @example\n * ```typescript\n * const asset = { w: 100, h: 100, p: 'image.png' };\n * const isImage = isImageAsset(asset); // true\n * ```\n *\n * @public\n */\nexport function isImageAsset(asset: Asset.Value): asset is Asset.Image {\n  return 'w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset;\n}\n\n/**\n * Checks if an asset is an audio asset.\n *\n * @remarks\n * This function accepts an asset object and determines whether it represents an audio asset.\n * It returns `true` if it's an audio asset, `false` otherwise.\n *\n * @param asset - The asset object to check.\n * @returns `true` if it's an audio asset, `false` otherwise.\n *\n * @example\n * ```typescript\n * const asset = { e: 0, u: 'music/', p: 'audio.mp3' };\n * const isAudio = isAudioAsset(asset); // true\n * ```\n *\n * @public\n */\nexport function isAudioAsset(asset: Asset.Value): asset is Asset.Image {\n  return !('h' in asset) && !('w' in asset) && 'p' in asset && 'e' in asset && 'u' in asset && 'id' in asset;\n}\n\n/**\n * Unzips the .lottie file.\n *\n * @remarks\n * This function accepts a .lottie file as a Uint8Array and an optional filter function to refine the unzipping process.\n * It returns a Promise that resolves with the unzipped data.\n *\n * @param dotLottie - The .lottie data as a Uint8Array.\n * @param filter - The filter function to apply to the files. Defaults to a function that always returns true.\n * @returns A Promise that resolves with the unzipped data.\n * @throws {@link dotLottieError} if the .lottie data is not provided or is invalid.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const unzippedData = await unzipDotLottie(dotLottie);\n * ```\n *\n * @public\n */\nexport async function unzipDotLottie(\n  dotLottie: Uint8Array | undefined,\n  filter: UnzipFileFilter = (): boolean => true,\n): Promise<Unzipped> {\n  if (!(dotLottie instanceof Uint8Array)) {\n    throw new DotLottieError('dotLottie not found', ErrorCodes.INVALID_DOTLOTTIE);\n  }\n\n  const unzipped = await new Promise<Unzipped>((resolve, reject) => {\n    fflateUnzip(dotLottie, { filter }, (err, data) => {\n      if (err) {\n        reject(err);\n      }\n      resolve(data);\n    });\n  });\n\n  return unzipped;\n}\n\n/**\n * Unzips a specific file from a `.lottie` archive.\n *\n * @remarks\n * This function accepts a `.lottie` file as a `Uint8Array`, a path string representing the\n * target file to extract, and an optional filter function to further refine the extraction.\n * It returns a `Promise` that resolves to the unzipped `Uint8Array` of the target file.\n *\n * @param dotLottie - The `.lottie` file content as a `Uint8Array`.\n * @param path - The path of the target file within the `.lottie` archive to extract.\n * @param filter - An optional filter function to apply on the unzipping process.\n *                 Accepts a file object and returns a boolean indicating whether the file should be included.\n * @returns A `Promise` that resolves to the `Uint8Array` of the unzipped target file.\n *\n * @throws {@link dotLottieError} if the input is not a valid `.lottie` file or if the target file is not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const targetPath = 'images/image.png';\n * const unzippedFile = await unzipDotLottieFile(dotLottie, targetPath);\n * ```\n *\n * @public\n */\nexport async function unzipDotLottieFile(\n  dotLottie: Uint8Array,\n  path: string,\n  filter?: UnzipFileFilter,\n): Promise<Uint8Array | undefined> {\n  if (!(dotLottie instanceof Uint8Array)) {\n    throw new DotLottieError('Invalid dotLottie', ErrorCodes.INVALID_DOTLOTTIE);\n  }\n\n  const unzipped = await unzipDotLottie(dotLottie, (file) => file.name === path && (!filter || filter(file)));\n\n  return unzipped[path];\n}\n\n/**\n * Retrieves the manifest data from the given dotLottie object.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array and extracts the manifest data from it.\n * The manifest contains metadata information about the .lottie file, such as the list of animations, themes, and image assets.\n * It returns a Promise that resolves to the manifest data or `undefined` if the manifest is not found.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @returns A Promise that resolves with the manifest data or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const manifestData = await getManifest(dotLottie);\n * ```\n *\n * @public\n */\nexport async function getManifest(dotLottie: Uint8Array): Promise<ManifestV1 | ManifestV2 | undefined> {\n  const manifestFileName = 'manifest.json';\n\n  const unzipped = await unzipDotLottie(dotLottie, (file) => file.name === manifestFileName);\n\n  const unzippedManifest = unzipped[manifestFileName];\n\n  if (typeof unzippedManifest === 'undefined') {\n    return undefined;\n  }\n\n  return JSON.parse(strFromU8(unzippedManifest, false)) as ManifestV1 | ManifestV2;\n}\n\nexport async function getDotLottieVersion(dotLottie: Uint8Array): Promise<string> {\n  const manifest = await getManifest(dotLottie);\n\n  return manifest?.version ?? '1.0.0';\n}\n\n/**\n * Validates the provided dotLottie data.\n *\n * @remarks\n * This function accepts a Uint8Array containing .lottie data and validates its structure and content.\n * It returns a Promise that resolves with an object containing a success boolean and an optional error string.\n *\n * @param dotLottie - The dotLottie data as a Uint8Array.\n * @returns A Promise that resolves with an object containing a success boolean and an optional error string.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const validationResult = await validatedotLottie(dotLottie);\n * ```\n *\n * @public\n */\nexport async function validateDotLottie(dotLottie: Uint8Array): Promise<{ error?: string; success: boolean }> {\n  if (!(dotLottie instanceof Uint8Array)) {\n    return { success: false, error: 'dotLottie not found' };\n  }\n\n  const manifest = await getManifest(dotLottie);\n\n  if (typeof manifest === 'undefined') {\n    return { success: false, error: 'manifest.json is missing' };\n  }\n\n  return { success: true };\n}\n\n/**\n * Loads a .lottie file from an ArrayBuffer.\n *\n * @remarks\n * This function takes an ArrayBuffer containing .lottie data and converts it into a Uint8Array.\n * It validates the data and returns a Promise that resolves with the dotLottie data as a Uint8Array.\n *\n * @param arrayBuffer - The ArrayBuffer containing .lottie data.\n * @returns A Promise that resolves with the dotLottie data as a Uint8Array.\n * @throws {@link dotLottieError} if the data is invalid.\n *\n * @example\n * ```typescript\n * const arrayBuffer = new ArrayBuffer(...);\n * const dotLottie = await loadFromArrayBuffer(arrayBuffer);\n * ```\n *\n * @public\n */\nexport async function loadFromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<Uint8Array> {\n  const dotLottie = new Uint8Array(arrayBuffer);\n\n  const validationResult = await validateDotLottie(dotLottie);\n\n  if (validationResult.error) {\n    throw new DotLottieError(validationResult.error, ErrorCodes.INVALID_DOTLOTTIE);\n  }\n\n  return dotLottie;\n}\n\n/**\n * Loads a .lottie file from a given URL.\n *\n * @remarks\n * This function takes a URL string as input and fetches the .lottie file from the provided URL.\n * It returns a Promise that resolves with the dotLottie data as a Uint8Array.\n *\n * @param src - The URL source of the .lottie file.\n * @returns A Promise that resolves with the dotLottie data as a Uint8Array.\n * @throws {@link dotLottieError} if the URL is invalid or if the content type is incorrect.\n *\n * @example\n * ```typescript\n * const url = 'https://example.com/animation.lottie';\n * const dotLottie = await loadFromURL(url);\n * ```\n *\n * @public\n */\nexport async function loadFromURL(src: string): Promise<Uint8Array> {\n  if (!isValidURL(src)) {\n    throw new DotLottieError('Invalid url provided for .lottie file', ErrorCodes.INVALID_URL);\n  }\n\n  const response = await fetch(src);\n\n  const arrayBuffer = await response.arrayBuffer();\n\n  const zipMagicHeader = new Uint8Array([0x50, 0x4b, 0x03, 0x04]);\n\n  const header = new Uint8Array(arrayBuffer.slice(0, 4));\n\n  if (!header.every((value, index) => value === zipMagicHeader[index])) {\n    throw new DotLottieError('Invalid .lottie file', ErrorCodes.INVALID_DOTLOTTIE);\n  }\n\n  const dotLottie = await loadFromArrayBuffer(arrayBuffer);\n\n  return dotLottie;\n}\n\n/**\n * Retrieves an audio from the given dotLottie object by its filename.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array, the filename of the audio to retrieve, and an optional filter function.\n * It returns a Promise that resolves to the audio data URL or `undefined` if not found.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param filename - The filename of the image to get.\n * @param filter - An optional filter function to apply on the unzipping process.\n * @returns A Promise that resolves with the audio data URL or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const filename = 'alarm.mp3';\n * const imageData = await getAudio(dotLottie, filename);\n * ```\n *\n * @public\n */\nexport async function getAudio(\n  dotLottie: Uint8Array,\n  filename: string,\n  filter?: UnzipFileFilter,\n): Promise<string | undefined> {\n  const version = await getDotLottieVersion(dotLottie);\n\n  let audioPath = 'audio/';\n\n  if (version === '2') {\n    audioPath = 'u/';\n  }\n\n  const audioFilename = `${audioPath}${filename}`;\n\n  const unzipped = await unzipDotLottieFile(dotLottie, audioFilename, filter);\n\n  if (typeof unzipped === 'undefined') {\n    return undefined;\n  }\n\n  return dataUrlFromU8(unzipped);\n}\n\n/**\n * Retrieves all audio files from the given dotLottie object.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array and an optional filter function to further refine the extraction.\n * It returns a Promise that resolves to a record containing the audio data URLs mapped by their ID.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param filter - An optional filter function to apply on the unzipping process.\n * @returns A Promise that resolves to a record containing the audio data URLs mapped by their ID.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const allAudio = await getAllAudio(dotLottie);\n * ```\n *\n * @public\n */\nexport async function getAllAudio(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>> {\n  const version = await getDotLottieVersion(dotLottie);\n\n  let audioPath = 'audio/';\n\n  if (version === '2') {\n    audioPath = 'u/';\n  }\n\n  const unzippedAudio = await unzipDotLottie(dotLottie, (file) => {\n    const name = file.name.replace(audioPath, '');\n\n    return file.name.startsWith(audioPath) && (!filter || filter({ ...file, name }));\n  });\n\n  const audio: Record<string, string> = {};\n\n  for (const audioFilename in unzippedAudio) {\n    const unzippedSingleAudio = unzippedAudio[audioFilename];\n\n    if (unzippedSingleAudio instanceof Uint8Array) {\n      const audioId = audioFilename.replace(audioPath, '');\n\n      audio[audioId] = await dataUrlFromU8(unzippedSingleAudio);\n    }\n  }\n\n  return audio;\n}\n\n/**\n * Inlines audio assets for the given animations within a dotLottie object.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array and a record containing the animations to process.\n * It identifies the audio used in the animations and replaces their references with the actual audio data.\n * This operation is performed asynchronously, and the function returns a Promise that resolves when the operation is complete.\n *\n * @param dotLottie - The dotLottie object containing the animations.\n * @param animations - A record containing the animations to process.\n * @returns A Promise that resolves when the operation is complete, returning nothing.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const animations = { animation1: {...}, animation2: {...} };\n * await inlineAudioAssets(dotLottie, animations);\n * ```\n *\n * @public\n */\nexport async function inlineAudioAssets(\n  dotLottie: Uint8Array,\n  animations: Record<string, AnimationData>,\n): Promise<void> {\n  const audioMap = new Map<string, Set<string>>();\n\n  for (const [animationId, animationData] of Object.entries(animations)) {\n    for (const asset of animationData.assets || []) {\n      if (isAudioAsset(asset)) {\n        const audioId = asset.p;\n\n        if (!audioMap.has(audioId)) {\n          audioMap.set(audioId, new Set());\n        }\n        audioMap.get(audioId)?.add(animationId);\n      }\n    }\n  }\n\n  const unzippedAudio = await getAllAudio(dotLottie, (file) => audioMap.has(file.name));\n\n  for (const [audioId, animationIdsSet] of audioMap) {\n    const audioDataURL = unzippedAudio[audioId];\n\n    if (audioDataURL) {\n      for (const animationId of animationIdsSet) {\n        const animationData = animations[animationId];\n\n        for (const asset of animationData?.assets || []) {\n          if (isAudioAsset(asset) && asset.p === audioId) {\n            asset.p = audioDataURL;\n            asset.u = '';\n            asset.e = 1;\n          }\n        }\n      }\n    }\n  }\n}\n\n/**\n * Retrieves an image from the given dotLottie object by its filename.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array, the filename of the image to retrieve, and an optional filter function.\n * It returns a Promise that resolves to the image data URL or `undefined` if not found.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param filename - The filename of the image to get.\n * @param filter - An optional filter function to apply on the unzipping process.\n * @returns A Promise that resolves with the image data URL or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const filename = 'image.png';\n * const imageData = await getImage(dotLottie, filename);\n * ```\n *\n * @public\n */\nexport async function getImage(\n  dotLottie: Uint8Array,\n  filename: string,\n  filter?: UnzipFileFilter,\n): Promise<string | undefined> {\n  const version = await getDotLottieVersion(dotLottie);\n\n  let imagesPath = 'images/';\n\n  if (version === '2') {\n    imagesPath = 'i/';\n  }\n\n  const imageFilename = `${imagesPath}${filename}`;\n\n  const unzipped = await unzipDotLottieFile(dotLottie, imageFilename, filter);\n\n  if (typeof unzipped === 'undefined') {\n    return undefined;\n  }\n\n  return dataUrlFromU8(unzipped);\n}\n\n/**\n * Retrieves all images from the given dotLottie object.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array and an optional filter function to further refine the extraction.\n * It returns a Promise that resolves to a record containing the image data URLs mapped by their ID.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param filter - An optional filter function to apply on the unzipping process.\n * @returns A Promise that resolves to a record containing the image data URLs mapped by their ID.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const images = await getImages(dotLottie);\n * ```\n *\n * @public\n */\nexport async function getImages(dotLottie: Uint8Array, filter?: UnzipFileFilter): Promise<Record<string, string>> {\n  const version = await getDotLottieVersion(dotLottie);\n\n  let imagesPath = 'images/';\n\n  if (version === '2') {\n    imagesPath = 'i/';\n  }\n\n  const unzippedImages = await unzipDotLottie(dotLottie, (file) => {\n    const name = file.name.replace(imagesPath, '');\n\n    return file.name.startsWith(imagesPath) && (!filter || filter({ ...file, name }));\n  });\n\n  const images: Record<string, string> = {};\n\n  for (const imagePath in unzippedImages) {\n    const unzippedImage = unzippedImages[imagePath];\n\n    if (unzippedImage instanceof Uint8Array) {\n      const imageId = imagePath.replace(imagePath, '');\n\n      images[imageId] = await dataUrlFromU8(unzippedImage);\n    }\n  }\n\n  return images;\n}\n\n/**\n * Inlines image assets for the given animations within a dotLottie object.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array and a record containing the animations to process.\n * It identifies the images used in the animations and replaces their references with the actual image data.\n * This operation is performed asynchronously, and the function returns a Promise that resolves when the operation is complete.\n *\n * @param dotLottie - The dotLottie object containing the animations.\n * @param animations - A record containing the animations to process.\n * @returns A Promise that resolves when the operation is complete, returning nothing.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const animations = { animation1: {...}, animation2: {...} };\n * await inlineImageAssets(dotLottie, animations);\n * ```\n *\n * @public\n */\nexport async function inlineImageAssets(\n  dotLottie: Uint8Array,\n  animations: Record<string, AnimationData>,\n): Promise<void> {\n  const imagesMap = new Map<string, Set<string>>();\n\n  for (const [animationId, animationData] of Object.entries(animations)) {\n    for (const asset of animationData.assets || []) {\n      if (isImageAsset(asset)) {\n        const imageId = asset.p;\n\n        if (!imagesMap.has(imageId)) {\n          imagesMap.set(imageId, new Set());\n        }\n        imagesMap.get(imageId)?.add(animationId);\n      }\n    }\n  }\n\n  const unzippedImages = await getImages(dotLottie, (file) => imagesMap.has(file.name));\n\n  for (const [imageId, animationIdsSet] of imagesMap) {\n    const imageDataURL = unzippedImages[imageId];\n\n    if (imageDataURL) {\n      for (const animationId of animationIdsSet) {\n        const animationData = animations[animationId];\n\n        for (const asset of animationData?.assets || []) {\n          if (isImageAsset(asset) && asset.p === imageId) {\n            asset.p = imageDataURL;\n            asset.u = '';\n            asset.e = 1;\n          }\n        }\n      }\n    }\n  }\n}\n\n/**\n * Retrieves an animation from the given dotLottie object by its ID.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array, the animation ID to retrieve, and an optional inlineAssets option.\n * It returns a Promise that resolves to the animation data or `undefined` if not found.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param animationId - The animation ID to get.\n * @param options - An object containing an optional `inlineAssets` boolean to control whether image assets should be inlined.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves with the animation data or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const animationId = 'example';\n * const animationData = await getAnimation(dotLottie, animationId, { inlineAssets: true });\n * ```\n *\n * @public\n */\nexport async function getAnimation(\n  dotLottie: Uint8Array,\n  animationId: string,\n  { inlineAssets }: { inlineAssets?: boolean } = {},\n  filter?: UnzipFileFilter,\n): Promise<AnimationData | undefined> {\n  const animationFilename = `animations/${animationId}.json`;\n\n  const unzippedAnimation = await unzipDotLottieFile(dotLottie, animationFilename, filter);\n\n  if (typeof unzippedAnimation === 'undefined') {\n    return undefined;\n  }\n\n  const animationData = JSON.parse(strFromU8(unzippedAnimation, false)) as AnimationData;\n\n  if (!inlineAssets) {\n    return animationData;\n  }\n\n  const animationsMap = {\n    [animationId]: animationData,\n  };\n\n  await inlineImageAssets(dotLottie, animationsMap);\n\n  await inlineAudioAssets(dotLottie, animationsMap);\n\n  return animationData;\n}\n\n/**\n * Retrieves the animations from the given dotLottie object, with optional filtering and asset inlining.\n *\n * @remarks\n * This function accepts a dotLottie object as a Uint8Array, an optional inlineAssets option, and an optional filter function.\n * It returns a Promise that resolves to a record containing the animation data mapped by their ID.\n *\n * @param dotLottie - The Uint8Array of dotLottie data.\n * @param options - An object containing an optional `inlineAssets` boolean to control whether assets should be inlined.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves to a record containing the animation data mapped by their ID.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const animations = await getAnimations(dotLottie, { inlineAssets: true });\n * ```\n *\n * @public\n */\nexport async function getAnimations(\n  dotLottie: Uint8Array,\n  { inlineAssets }: { inlineAssets?: boolean } = {},\n  filter?: UnzipFileFilter,\n): Promise<Record<string, AnimationData>> {\n  const animationsMap: Record<string, AnimationData> = {};\n\n  const version = await getDotLottieVersion(dotLottie);\n\n  let animationsPath = 'animations/';\n\n  if (version === '2') {\n    animationsPath = 'a/';\n  }\n\n  const unzippedAnimations = await unzipDotLottie(dotLottie, (file) => {\n    const filename = file.name.replace(animationsPath, '').replace('.json', '');\n\n    return file.name.startsWith(animationsPath) && (!filter || filter({ ...file, name: filename }));\n  });\n\n  for (const animationPath in unzippedAnimations) {\n    const data = unzippedAnimations[animationPath];\n\n    if (data instanceof Uint8Array) {\n      const animationId = animationPath.replace(animationsPath, '').replace('.json', '');\n      const animationData = JSON.parse(strFromU8(data, false)) as AnimationData;\n\n      animationsMap[animationId] = animationData;\n    }\n  }\n\n  if (!inlineAssets) {\n    return animationsMap;\n  }\n\n  await inlineImageAssets(dotLottie, animationsMap);\n\n  return animationsMap;\n}\n\n/**\n * Retrieves the themes from the given DotLottie object.\n *\n * @remarks\n * This function accepts a DotLottie object as a Uint8Array and an optional filter function to refine the extraction of themes.\n * It returns a Promise that resolves to a record containing the themes mapped by their ID.\n *\n * @param dotLottie - The DotLottie object containing the themes.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves to a record containing the themes mapped by their ID.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const themes = await getThemes(dotLottie);\n * ```\n */\nexport async function getThemes(\n  dotLottie: Uint8Array,\n  filter?: UnzipFileFilter,\n): Promise<Record<string, Record<string, unknown>>> {\n  const themesMap: Record<string, Record<string, unknown>> = {};\n\n  const unzippedThemes = await unzipDotLottie(dotLottie, (file) => {\n    const name = file.name.replace('t/', '').replace('.json', '');\n\n    return file.name.startsWith('t/') && (!filter || filter({ ...file, name }));\n  });\n\n  for (const themePath in unzippedThemes) {\n    const data = unzippedThemes[themePath];\n\n    if (data instanceof Uint8Array) {\n      const themeId = themePath.replace('t/', '').replace('.json', '');\n\n      themesMap[themeId] = JSON.parse(strFromU8(data, false));\n    }\n  }\n\n  return themesMap;\n}\n\n/**\n * Retrieves a specific theme by ID from the given DotLottie object.\n *\n * @remarks\n * This function accepts a DotLottie object as a Uint8Array, the theme ID to retrieve, and an optional filter function.\n * It returns a Promise that resolves to the theme as a string or `undefined` if not found.\n *\n * @param dotLottie - The DotLottie object containing the theme.\n * @param themeId - The ID of the theme to retrieve.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves to the theme as a string or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const themeId = 'dark';\n * const theme = await getTheme(dotLottie, themeId);\n * ```\n */\nexport async function getTheme(\n  dotLottie: Uint8Array,\n  themeId: string,\n  filter?: UnzipFileFilter,\n): Promise<Record<string, unknown> | undefined> {\n  const themeFilename = `t/${themeId}.json`;\n\n  const unzippedTheme = await unzipDotLottieFile(dotLottie, themeFilename, filter);\n\n  if (typeof unzippedTheme === 'undefined') {\n    return undefined;\n  }\n\n  return JSON.parse(strFromU8(unzippedTheme, false));\n}\n\n/**\n * Retrieves the state machines from the given DotLottie object.\n *\n * @remarks\n * This function accepts a DotLottie object as a Uint8Array and an optional filter function to refine the extraction of state machines.\n * It returns a Promise that resolves to a record containing the state machines mapped by their ID.\n *\n * @param dotLottie - The DotLottie object containing the state machines.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves to a record containing the state machines mapped by their ID.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const machines = await getStateMachines(dotLottie);\n * ```\n */\nexport async function getStateMachines(\n  dotLottie: Uint8Array,\n  filter?: UnzipFileFilter,\n): Promise<Record<string, string>> {\n  const statesMap: Record<string, string> = {};\n\n  const unzippedStates = await unzipDotLottie(dotLottie, (file) => {\n    const name = file.name.replace('s/', '').replace('.json', '');\n\n    return file.name.startsWith('s/') && (!filter || filter({ ...file, name }));\n  });\n\n  for (const statePath in unzippedStates) {\n    const data = unzippedStates[statePath];\n\n    if (data instanceof Uint8Array) {\n      const themeId = statePath.replace('s/', '').replace('.json', '');\n\n      statesMap[themeId] = strFromU8(data, false);\n    }\n  }\n\n  return statesMap;\n}\n\n/**\n * Retrieves a specific state machine by ID from the given DotLottie object.\n *\n * @remarks\n * This function accepts a DotLottie object as a Uint8Array, the state ID to retrieve, and an optional filter function.\n * It returns a Promise that resolves to the state machine as a string or `undefined` if not found.\n *\n * @param dotLottie - The DotLottie object containing the theme.\n * @param stateMachineId - The ID of the state machine to retrieve.\n * @param filter - An optional function to filter the files to be unzipped.\n * @returns A Promise that resolves to the state machine as a string or `undefined` if not found.\n *\n * @example\n * ```typescript\n * const dotLottie = new Uint8Array(...);\n * const stateMachineId = 'walk';\n * const stateMachine = await getState(dotLottie, stateMachineId);\n * ```\n */\nexport async function getStateMachine(\n  dotLottie: Uint8Array,\n  stateMachineId: string,\n  filter?: UnzipFileFilter,\n): Promise<LottieStateMachine | undefined> {\n  const stateMachineFilename = `s/${stateMachineId}.json`;\n\n  const unzippedStateMachine = await unzipDotLottieFile(dotLottie, stateMachineFilename, filter);\n\n  if (typeof unzippedStateMachine === 'undefined') {\n    return undefined;\n  }\n\n  const stateMachine = JSON.parse(strFromU8(unzippedStateMachine, false)) as LottieStateMachine;\n\n  return stateMachine;\n}\n","{\n  \"name\": \"@dotlottie/dotlottie-js\",\n  \"version\": \"1.0.2\",\n  \"type\": \"module\",\n  \"description\": \"This library helps in creating and modifying .lottie files.\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/dotlottie/dotlottie-js.git\",\n    \"directory\": \"packages/dotlottie-js\"\n  },\n  \"homepage\": \"https://github.com/dotlottie/dotlottie-js#readme\",\n  \"bugs\": \"https://github.com/dotlottie/dotlottie-js/issues\",\n  \"author\": \"dotLottie\",\n  \"contributors\": [\n    \"Karam Ali <karam@lottiefiles.com>\",\n    \"Sam Osborne <sam@lottiefiles.com>\",\n    \"Jawish Hameed <jawish@lottiefiles.com>\",\n    \"Abdelrahman Ashraf <a.theashraf@gmail.com>\"\n  ],\n  \"license\": \"MIT\",\n  \"engines\": {\n    \"node\": \">=18.0.0\"\n  },\n  \"main\": \"./dist/index.node.js\",\n  \"exports\": {\n    \".\": {\n      \"node\": \"./dist/index.node.js\",\n      \"default\": \"./dist/index.browser.js\"\n    },\n    \"./*\": \"./dist/*.js\"\n  },\n  \"browser\": \"dist/index.browser.js\",\n  \"types\": \"./dist/index.browser.d.ts\",\n  \"typesVersions\": {\n    \"*\": {\n      \"*\": [\n        \"dist/*\",\n        \"dist/index.browser.d.ts\"\n      ]\n    }\n  },\n  \"files\": [\n    \"dist\"\n  ],\n  \"scripts\": {\n    \"build\": \"tsup\",\n    \"dev\": \"tsup --watch\",\n    \"docs\": \"typedoc src\",\n    \"lint\": \"eslint --fix .\",\n    \"stats:eslint\": \"cross-env TIMING=1 eslint .\",\n    \"stats:ts\": \"tsc -p tsconfig.build.json --extendedDiagnostics\",\n    \"test\": \"pnpm run test:node && pnpm run test:browser\",\n    \"test:browser\": \"vitest --config=vitest.browser.config.js\",\n    \"test:node\": \"vitest --config=vitest.config.js\",\n    \"type-check\": \"tsc --noEmit\"\n  },\n  \"dependencies\": {\n    \"@lottie-animation-community/lottie-types\": \"^1.2.0\",\n    \"browser-image-hash\": \"^0.0.5\",\n    \"fflate\": \"^0.8.1\",\n    \"file-type\": \"^19.6.0\",\n    \"sharp\": \"^0.33.2\",\n    \"sharp-phash\": \"^2.1.0\",\n    \"valibot\": \"^0.13.1\"\n  },\n  \"devDependencies\": {\n    \"@types/jasmine\": \"4.3.5\",\n    \"@types/node\": \"22.8.7\",\n    \"@types/sharp\": \"0.31.1\",\n    \"@vitest/browser\": \"2.1.3\",\n    \"@vitest/coverage-v8\": \"2.1.3\",\n    \"cross-env\": \"7.0.3\",\n    \"js-base64\": \"3.7.5\",\n    \"nodemon\": \"2.0.20\",\n    \"playwright\": \"^1.48.2\",\n    \"tsup\": \"8.3.0\",\n    \"typescript\": \"4.7.4\",\n    \"vite-plugin-arraybuffer\": \"^0.0.8\",\n    \"vitest\": \"^2.1.3\"\n  },\n  \"publishConfig\": {\n    \"access\": \"public\"\n  }\n}\n","/**\n * Copyright 2024 Design Barn Inc.\n */\n\nimport pkg from '../package.json';\n\nexport const PACKAGE_NAME = `${pkg.name}@${pkg.version}`;\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { type Output, string, array, optional, object } from 'valibot';\n\nexport const ManifestAnimationSchema = object({\n  id: string(),\n  name: optional(string()),\n  initialTheme: optional(string()),\n  background: optional(string()),\n  themes: optional(array(string())),\n});\nexport type ManifestAnimation = Output<typeof ManifestAnimationSchema>;\n\nexport const ManifestThemeSchema = object({\n  id: string(),\n  name: optional(string()),\n});\nexport type ManifestTheme = Output<typeof ManifestThemeSchema>;\n\nexport const ManifestStateMachineSchema = object({\n  id: string(),\n  name: optional(string()),\n});\nexport type ManifestStateMachine = Output<typeof ManifestStateMachineSchema>;\n\nexport const InitialObjectSchema = object({\n  animation: optional(string()),\n  stateMachine: optional(string()),\n});\n\nexport const ManifestSchema = object({\n  version: string(),\n  generator: string(),\n  initial: optional(InitialObjectSchema),\n  animations: array(ManifestAnimationSchema),\n  themes: optional(array(ManifestThemeSchema)),\n  stateMachines: optional(array(ManifestStateMachineSchema)),\n});\n\nexport type Manifest = Output<typeof ManifestSchema>;\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { type Output, boolean, number, object, optional, string, array, union } from 'valibot';\n\nexport const NumericGuardSchema = object({\n  type: string('Numeric'),\n  triggerName: string(),\n  conditionType: string(),\n  compareTo: union([string(), number(), boolean()]),\n});\nexport const StringGuardSchema = object({\n  type: string('String'),\n  triggerName: string(),\n  conditionType: string(),\n  compareTo: string(),\n});\nexport const BooleanGuardSchema = object({\n  type: string('Boolean'),\n  triggerName: string(),\n  conditionType: string(),\n  compareTo: union([string(), boolean()]),\n});\nexport const EventGuardSchema = object({\n  type: string('Event'),\n  triggerName: string(),\n});\n\nexport const GuardSchema = union([NumericGuardSchema, StringGuardSchema, BooleanGuardSchema, EventGuardSchema]);\n\n// Event Schemas\nconst NumericEventSchema = object({ value: number() });\nconst BooleanEventSchema = object({ value: boolean() });\nconst StringEventSchema = object({ value: string() });\nconst PointerEventSchema = object({ target: optional(string()) });\n\n// const TransitionType = union([string('Transition')]);\nconst TransitionType = string('Transition');\n\n// Transition Schema\nexport const TransitionSchema = object({\n  type: TransitionType,\n  toState: string(),\n  guards: optional(array(GuardSchema)),\n});\n\nexport const TransitionsSchema = array(TransitionSchema);\n\n// Entry/Exit Action Schema\nconst URLActionSchema = object({ type: string(), url: string() });\nconst ThemeActionSchema = object({ type: string(), themeId: string() });\nconst IncrementSchema = object({\n  type: string(),\n  triggerName: string(),\n  value: optional(union([string(), number()])),\n});\nconst DecrementSchema = object({\n  type: string(),\n  triggerName: string(),\n  value: optional(union([string(), number()])),\n});\nconst ToggleSchema = object({\n  type: string(),\n  triggerName: string(),\n});\nconst SetBooleanSchema = object({\n  type: string(),\n  triggerName: string(),\n  value: optional(boolean()),\n});\nconst SetStringSchema = object({\n  type: string(),\n  triggerName: string(),\n  value: optional(string()),\n});\nconst SetNumericSchema = object({\n  type: string(),\n  triggerName: string(),\n  value: optional(number()),\n});\nconst FireSchema = object({\n  type: string(),\n  triggerName: string(),\n});\nconst ResetSchema = object({\n  type: string(),\n  triggerName: string(),\n});\nconst SetExpressionSchema = object({\n  type: string(),\n  layerName: string(),\n  propertyIndex: number(),\n  varName: string(),\n  value: number(),\n});\nconst SetThemeSchema = object({\n  type: string(),\n  themeId: string(),\n});\nconst SetFrameSchema = object({\n  type: string(),\n  value: union([string(), number()]),\n});\nconst SetProgressSchema = object({\n  type: string(),\n  value: union([string(), number()]),\n});\nconst SetSlotSchema = object({\n  type: string(),\n  value: string(),\n});\nconst FireCustomEventSchema = object({\n  type: string(),\n  value: string(),\n});\n\nconst ActionSchema = union([\n  URLActionSchema,\n  ThemeActionSchema,\n  IncrementSchema,\n  DecrementSchema,\n  ToggleSchema,\n  SetBooleanSchema,\n  SetStringSchema,\n  SetNumericSchema,\n  FireSchema,\n  ResetSchema,\n  SetExpressionSchema,\n  SetThemeSchema,\n  SetFrameSchema,\n  SetProgressSchema,\n  SetSlotSchema,\n  FireCustomEventSchema,\n]);\n\nconst Modes = union([string('Forward'), string('Reverse'), string('Bounce'), string('ReverseBounce')]);\n\nconst StateType = union([string('PlaybackState'), string('GlobalState')]);\n\nexport const PlaybackStateSchema = object({\n  name: string(),\n  type: StateType,\n  animation: string(),\n  loop: optional(boolean()),\n  autoplay: optional(boolean()),\n  final: optional(boolean()),\n  mode: optional(Modes),\n  speed: optional(number()),\n  segment: optional(string()),\n  backgroundColor: optional(number()),\n  useFrameInterpolation: optional(boolean()),\n  entryActions: optional(array(ActionSchema)),\n  exitActions: optional(array(ActionSchema)),\n  transitions: optional(TransitionsSchema),\n});\n\nexport const GlobalStateSchema = object({\n  name: string(),\n  type: StateType,\n  entryActions: optional(array(ActionSchema)),\n  exitActions: optional(array(ActionSchema)),\n  transitions: optional(TransitionsSchema),\n});\n\nexport const StateSchema = union([PlaybackStateSchema, GlobalStateSchema]);\nexport const StatesSchema = array(StateSchema);\n\nexport const PointerUpSchema = object({\n  type: string(),\n  layerName: optional(string()),\n  actions: array(ActionSchema),\n});\n\nexport const PointerDownSchema = object({\n  type: string(),\n  layerName: optional(string()),\n  actions: array(ActionSchema),\n});\n\nexport const PointerEnterSchema = object({\n  type: string(),\n  layerName: optional(string()),\n  actions: array(ActionSchema),\n});\n\nexport const PointerMoveSchema = object({\n  type: string(),\n  actions: array(ActionSchema),\n});\n\nexport const PointerExitSchema = object({\n  type: string(),\n  layerName: optional(string()),\n  actions: array(ActionSchema),\n});\n\nexport const OnCompleteSchema = object({\n  type: string(),\n  stateName: string(),\n  actions: array(ActionSchema),\n});\n\nexport const ListenerSchema = union([\n  PointerUpSchema,\n  PointerDownSchema,\n  PointerEnterSchema,\n  PointerMoveSchema,\n  PointerExitSchema,\n  OnCompleteSchema,\n]);\nexport const ListenersSchema = array(ListenerSchema);\n\nexport const NumericTriggerSchema = object({\n  type: string('Numeric'),\n  name: string(),\n  value: number(),\n});\n\nexport const StringTriggerSchema = object({\n  type: string('String'),\n  name: string(),\n  value: string(),\n});\n\nexport const BooleanTriggerSchema = object({\n  type: string('Boolean'),\n  name: string(),\n  value: boolean(),\n});\n\nexport const EventTriggerSchema = object({\n  type: string('Event'),\n  name: string(),\n});\n\nexport const TriggerSchema = union([\n  NumericTriggerSchema,\n  StringTriggerSchema,\n  BooleanTriggerSchema,\n  EventTriggerSchema,\n]);\n\nexport const TriggersSchema = array(TriggerSchema);\n\nexport type DotLottieStates = Output<typeof StatesSchema>;\nexport type DotLottieState = Output<typeof StateSchema>;\nexport type DotLottieAction = Output<typeof ActionSchema>;\nexport type DotLottieNumericEvent = Output<typeof NumericEventSchema>;\nexport type DotLottieBooleanEvent = Output<typeof BooleanEventSchema>;\nexport type DotLottieStringEvent = Output<typeof StringEventSchema>;\nexport type DotLottiePointerEvent = Output<typeof PointerEventSchema>;\nexport type DotLottieGuard = Output<typeof GuardSchema>;\nexport type DotLottieTrigger = Output<typeof TriggerSchema>;\nexport type DotLottieTriggers = Output<typeof TriggersSchema>;\nexport type DotLottieListener = Output<typeof ListenerSchema>;\nexport type DotLottieListeners = Output<typeof ListenersSchema>;\nexport type DotLottieTransition = Output<typeof TransitionSchema>;\nexport type DotLottieTransitions = Output<typeof TransitionsSchema>;\n\n// DotLottieStateMachine Schema\nexport const DotLottieStateMachineSchema = object({\n  initial: string(),\n  states: StatesSchema,\n  listeners: optional(ListenersSchema),\n  triggers: optional(TriggersSchema),\n});\nexport type DotLottieStateMachine = Output<typeof DotLottieStateMachineSchema>;\n","/**\n * Copyright 2024 Design Barn Inc.\n */\n\nimport type { Output } from 'valibot';\nimport { object, union, number, array, optional, boolean, string, literal } from 'valibot';\n\nconst TangentSchema = object({\n  x: union([number(), array(number())]),\n  y: union([number(), array(number())]),\n});\n\nconst BaseKeyframeSchema = {\n  frame: number(),\n  inTangent: optional(TangentSchema),\n  outTangent: optional(TangentSchema),\n  hold: optional(boolean()),\n};\n\nconst ScalarKeyframeSchema = object({\n  ...BaseKeyframeSchema,\n  value: number(),\n});\n\nconst ColorKeyframeSchema = object({\n  ...BaseKeyframeSchema,\n  value: array(number()),\n});\n\nconst BaseRuleSchema = {\n  animations: optional(array(string())),\n  id: string(),\n};\n\nconst ScalarRuleSchema = object({\n  ...BaseRuleSchema,\n  type: literal('Scalar'),\n  value: optional(number()),\n  keyframes: optional(array(ScalarKeyframeSchema)),\n  expression: optional(string()),\n});\n\nconst PositionKeyframeSchema = object({\n  ...BaseKeyframeSchema,\n  value: array(number()),\n  valueInTangent: optional(number()),\n  valueOutTangent: optional(number()),\n});\n\nconst PositionRuleSchema = object({\n  ...BaseRuleSchema,\n  type: literal('Position'),\n  split: optional(boolean()),\n  keyframes: optional(array(PositionKeyframeSchema)),\n  expression: optional(string()),\n});\n\nconst ColorRuleSchema = object({\n  ...BaseRuleSchema,\n  type: literal('Color'),\n  value: optional(array(number())),\n  keyframes: optional(array(ColorKeyframeSchema)),\n  expression: optional(string()),\n});\n\nconst ImageRuleSchema = object({\n  ...BaseRuleSchema,\n  type: literal('Image'),\n  value: object({\n    id: optional(string()),\n    width: optional(number()),\n    height: optional(number()),\n    url: optional(string()),\n  }),\n});\n\nconst GradientKeyframeSchema = object({\n  ...BaseKeyframeSchema,\n  value: array(\n    object({\n      color: array(number()),\n      offset: number(),\n    }),\n  ),\n});\n\nconst GradientRuleSchema = object({\n  ...BaseRuleSchema,\n  type: literal('Gradient'),\n  value: optional(\n    array(\n      object({\n        color: array(number()),\n        offset: number(),\n      }),\n    ),\n  ),\n  keyframes: optional(array(GradientKeyframeSchema)),\n});\n\nconst RuleSchema = union([ColorRuleSchema, ScalarRuleSchema, PositionRuleSchema, ImageRuleSchema, GradientRuleSchema]);\n\nexport const RulesSchema = array(RuleSchema);\n\nexport const ThemeDataSchema = object({\n  rules: RulesSchema,\n});\n\nexport type ThemeData = Output<typeof ThemeDataSchema>;\nexport type Rules = Output<typeof RulesSchema>;\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\nimport { safeParse, flatten } from 'valibot';\n\nimport { DotLottieError, ErrorCodes } from '../../utils';\n\nimport type {\n  DotLottieListeners,\n  DotLottieStateMachine,\n  DotLottieStates,\n  DotLottieTransitions,\n  DotLottieTriggers,\n  ManifestStateMachine,\n} from './schemas';\nimport { ListenersSchema, StatesSchema, TransitionsSchema, TriggersSchema } from './schemas';\n\nexport interface DotLottieStateMachineCommonOptions extends ManifestStateMachine {\n  data: DotLottieStateMachine;\n  zipOptions?: ZipOptions;\n}\n\nexport class DotLottieStateMachineCommon {\n  protected _name: string | undefined;\n\n  protected _id: string;\n\n  protected _initial: string;\n\n  protected _zipOptions: ZipOptions;\n\n  protected _states: DotLottieStates;\n\n  protected _listeners: DotLottieListeners;\n\n  protected _triggers: DotLottieTriggers;\n\n  public constructor(options: DotLottieStateMachineCommonOptions) {\n    this._requireValidId(options.id);\n    this._requireValidTriggers(options.data.triggers ?? []);\n    this._requireValidListeners(options.data.listeners ?? []);\n    this._requireValidStates(options.data.states);\n    this._requireValidInitial(options.data.initial, options.data.states);\n\n    this._name = options.name;\n\n    this._id = options.id;\n\n    this._initial = options.data.initial;\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    this._states = options.data.states;\n\n    this._listeners = options.data.listeners ?? [];\n\n    this._triggers = options.data.triggers ?? [];\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get name(): string | undefined {\n    return this._name;\n  }\n\n  public set name(name: string | undefined) {\n    this._name = name;\n  }\n\n  public get states(): DotLottieStates {\n    return this._states;\n  }\n\n  public set states(states: DotLottieStates) {\n    this._states = states;\n  }\n\n  public get listeners(): DotLottieListeners {\n    return this._listeners;\n  }\n\n  public set listeners(listeners: DotLottieListeners) {\n    this._listeners = listeners;\n  }\n\n  public get triggers(): DotLottieTriggers {\n    return this._triggers;\n  }\n\n  public set triggers(triggers: DotLottieTriggers) {\n    this._triggers = triggers;\n  }\n\n  public get initial(): string {\n    return this._initial;\n  }\n\n  public set initial(initial: string) {\n    this.initial = initial;\n  }\n\n  public toString(): string {\n    return JSON.stringify({\n      initial: this._initial,\n      states: this._states,\n      triggers: this._triggers,\n      listeners: this._listeners,\n    });\n  }\n\n  protected _requireValidId(id: string | undefined): void {\n    if (!id) {\n      throw new DotLottieError('Invalid id.');\n    }\n  }\n\n  protected _requireValidInitial(initial: string, states: DotLottieStates): void {\n    const result = safeParse(StatesSchema, states);\n\n    if (!result.success) {\n      const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.issues).nested, null, 2)}`;\n\n      throw new DotLottieError(`Invalid initial state: ${error}`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n\n    let found = false;\n\n    for (const state of states) {\n      if (state.name === initial) {\n        found = true;\n      }\n    }\n\n    if (!found) {\n      throw new DotLottieError(`Initial state not found.`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n  }\n\n  protected _requireValidStates(states: DotLottieStates): void {\n    const result = safeParse(StatesSchema, states);\n\n    if (!result.success) {\n      const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.issues).nested, null, 2)}`;\n\n      throw new DotLottieError(`Invalid states: ${error}`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n\n    // loop over every transition and validate it\n    for (const state of states) {\n      if (state.transitions) {\n        this._requireValidTransitions(state.transitions);\n      }\n    }\n  }\n\n  protected _requireValidTriggers(triggers: DotLottieTriggers): void {\n    const result = safeParse(TriggersSchema, triggers);\n\n    if (!result.success) {\n      const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.issues).nested, null, 2)}`;\n\n      throw new DotLottieError(`Invalid context variables: ${error}`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n  }\n\n  protected _requireValidListeners(listeners: DotLottieListeners): void {\n    const result = safeParse(ListenersSchema, listeners);\n\n    if (!result.success) {\n      const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.issues).nested, null, 2)}`;\n\n      throw new DotLottieError(`Invalid listeners: ${error}`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n  }\n\n  protected _requireValidTransitions(transitions: DotLottieTransitions): void {\n    const result = safeParse(TransitionsSchema, transitions);\n\n    if (!result.success) {\n      const error = `Invalid state machine declaration, ${JSON.stringify(flatten(result.issues).nested, null, 2)}`;\n\n      throw new DotLottieError(`Invalid transitions: ${error}`, ErrorCodes.INVALID_STATEMACHINE);\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\nimport { safeParse } from 'valibot';\n\nimport { DotLottieError } from '../../utils';\n\nimport type { ManifestTheme, ThemeData } from './schemas';\nimport { ThemeDataSchema } from './schemas';\n\nexport interface ThemeOptions extends ManifestTheme {\n  data: ThemeData;\n  id: string;\n  zipOptions?: ZipOptions;\n}\n\nexport class LottieThemeCommon {\n  protected _data: ThemeData;\n\n  protected _id: string;\n\n  protected _name: string | undefined;\n\n  protected _zipOptions: ZipOptions;\n\n  public constructor(options: ThemeOptions) {\n    this._requireValidId(options.id);\n    this._requireValidData(options.data);\n\n    this._name = options.name;\n    this._data = options.data;\n    this._id = options.id;\n\n    this._zipOptions = options.zipOptions ?? {};\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get name(): string | undefined {\n    return this._name;\n  }\n\n  public set name(name: string | undefined) {\n    this._name = name;\n  }\n\n  public get data(): ThemeData {\n    return this._data;\n  }\n\n  public set data(data: ThemeData) {\n    this._requireValidData(data);\n\n    this._data = data;\n  }\n\n  public async toString(): Promise<string> {\n    return JSON.stringify(this._data);\n  }\n\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (typeof id !== 'string' || !id) throw new DotLottieError('Invalid theme id');\n  }\n\n  private _requireValidData(data: ThemeData): asserts data is ThemeData {\n    const result = safeParse(ThemeDataSchema, data);\n\n    if (!result.success) {\n      const issues = JSON.stringify(result.issues, null, 2);\n\n      throw new DotLottieError(`Invalid theme data: ${issues}`);\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { PACKAGE_NAME } from '../../constants';\nimport type { ConversionOptions, GetAnimationOptions } from '../../types';\nimport { DotLottieError, isAudioAsset, isImageAsset, isValidURL } from '../../utils';\n\nimport type { AnimationOptions, LottieAnimationCommon } from './animation';\nimport type { LottieAudioCommon } from './audio';\nimport type { LottieImageCommon } from './image';\nimport type { DotLottiePlugin } from './plugin';\nimport type { Manifest } from './schemas';\nimport type { DotLottieStateMachineCommonOptions } from './state-machine';\nimport { DotLottieStateMachineCommon } from './state-machine';\nimport type { ThemeOptions } from './theme';\nimport { LottieThemeCommon } from './theme';\n\nexport interface DotLottieOptions {\n  enableDuplicateImageOptimization?: boolean;\n  generator?: string;\n}\n\nexport class DotLottieCommon {\n  protected readonly _animationsMap: Map<string, LottieAnimationCommon> = new Map();\n\n  protected readonly _plugins: DotLottiePlugin[] = [];\n\n  protected readonly _themesMap: Map<string, LottieThemeCommon> = new Map();\n\n  protected readonly _stateMachinesMap: Map<string, DotLottieStateMachineCommon> = new Map();\n\n  protected _generator: string = PACKAGE_NAME;\n\n  protected _version: string = '2';\n\n  public enableDuplicateImageOptimization?: boolean;\n\n  public constructor(options?: DotLottieOptions) {\n    if (options?.generator) {\n      this._generator = options.generator;\n    }\n\n    this.enableDuplicateImageOptimization = options?.enableDuplicateImageOptimization ?? false;\n  }\n\n  public async toBase64(_options?: ConversionOptions): Promise<string> {\n    throw new DotLottieError('toBase64() method not implemented in concrete class!');\n  }\n\n  public create(_options?: DotLottieOptions): DotLottieCommon {\n    throw new DotLottieError('create() method not implemented in concrete class!');\n  }\n\n  public async download(_fileName: string, _options: ConversionOptions | undefined = undefined): Promise<void> {\n    throw new DotLottieError('download(fileName:string) method not implemented in concrete class!');\n  }\n\n  public addPlugins(..._plugins: DotLottiePlugin[]): DotLottieCommon {\n    throw new DotLottieError('addPlugins(...plugins: DotLottiePlugin[]) not implemented in concrete class!');\n  }\n\n  public addAnimation(_animationOptions: AnimationOptions): DotLottieCommon {\n    throw new DotLottieError('addAnimation(animationOptions: AnimationOptions) not implemented in concrete class!');\n  }\n\n  public async fromArrayBuffer(_arrayBuffer: ArrayBuffer): Promise<DotLottieCommon> {\n    throw new DotLottieError(\n      'fromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<DotLottieCommon> not implemented in concrete class!',\n    );\n  }\n\n  public async toArrayBuffer(_options: ConversionOptions | undefined = undefined): Promise<ArrayBuffer> {\n    throw new DotLottieError('toArrayBuffer(): Promise<ArrayBuffer> is not implemented in concrete class!');\n  }\n\n  public get plugins(): DotLottiePlugin[] {\n    return this._plugins;\n  }\n\n  public get version(): string {\n    return this._version;\n  }\n\n  public get generator(): string {\n    return this._generator;\n  }\n\n  public get animations(): LottieAnimationCommon[] {\n    return Array.from(this._animationsMap.values());\n  }\n\n  public get manifest(): Manifest {\n    return this._buildManifest();\n  }\n\n  public get themes(): LottieThemeCommon[] {\n    return Array.from(this._themesMap.values());\n  }\n\n  public get stateMachines(): DotLottieStateMachineCommon[] {\n    return Array.from(this._stateMachinesMap.values());\n  }\n\n  /**\n   * Renames the underlying LottieImage, as well as updating the image asset path inside the animation data.\n   * @param newName - desired id and fileName,\n   * @param imageId - The id of the LottieImage to rename\n   */\n  private async _renameImage(\n    animation: LottieAnimationCommon,\n    newLottieAssetId: string,\n    lottieAssetId: string,\n  ): Promise<void> {\n    for (const imageAsset of animation.imageAssets) {\n      if (imageAsset.lottieAssetId === lottieAssetId) {\n        const oldPath = imageAsset.fileName;\n\n        // Rename image will change the fileName using the newLottieAssetId and append the detected extension\n        await imageAsset.renameImage(newLottieAssetId);\n\n        if (!animation.data) throw new DotLottieError('No animation data available.');\n\n        const animationAssets = animation.data.assets as AnimationType['assets'];\n\n        if (!animationAssets) throw new DotLottieError('No image assets to rename.');\n\n        // Find the image asset inside the animation data and rename its path\n        for (const asset of animationAssets) {\n          if ('w' in asset && 'h' in asset) {\n            if (asset.p === oldPath) {\n              asset.p = imageAsset.fileName;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Generates a map of duplicate image ids and their count.\n   * @returns Map of duplicate image ids and their count.\n   */\n  private _generateMapOfOccurencesFromImageIds(): Map<string, number> {\n    const dupeMap = new Map<string, number>();\n\n    this.animations.forEach((animation) => {\n      animation.imageAssets.forEach((imageAsset) => {\n        if (dupeMap.has(imageAsset.lottieAssetId)) {\n          const count = dupeMap.get(imageAsset.lottieAssetId) ?? 0;\n\n          dupeMap.set(imageAsset.lottieAssetId, count + 1);\n        } else {\n          dupeMap.set(imageAsset.lottieAssetId, 1);\n        }\n      });\n    });\n\n    return dupeMap;\n  }\n\n  /**\n   * Renames the image assets in all animations to avoid conflicts.\n   *\n   * Steps:\n   *  - Generate how many times across all animations the same image id has been used.\n   *  - Loop through every animation in reverse order\n   *  - Every time an animation uses an image asset that is also used elsewhere, append the count to the image's asset id and then decrement.\n   *\n   * Result of renaming for every animation:\n   *\n   * - Inside the Lottie's data and it's Asset object:\n   *  - The Asset id stays the same, meaning that every reference to the asset is still valid (refId)\n   *  - The path is changed to the new asset id with the format \\{assetId\\}_\\{count\\}\n   *\n   * - On the dotLottie file system scope:\n   *  - The image file name is changed to the new asset id \\{assetId\\}_\\{count\\}.\\{ext\\}\n   */\n  private async _renameImageAssets(): Promise<void> {\n    const occurenceMap = this._generateMapOfOccurencesFromImageIds();\n\n    // Loop over every animation\n    for (let i = this.animations.length - 1; i >= 0; i -= 1) {\n      const animation = this.animations.at(i);\n\n      if (animation) {\n        // Loop over every image asset of the animation\n        for (let j = animation.imageAssets.length - 1; j >= 0; j -= 1) {\n          const image = animation.imageAssets.at(j);\n\n          if (image) {\n            // Get how many times the same image id has been used\n            let count = occurenceMap.get(image.lottieAssetId) ?? 0;\n\n            if (count > 0) {\n              count -= 1;\n            }\n\n            // Decrement the count\n            occurenceMap.set(image.lottieAssetId, count);\n\n            if (count > 0) {\n              // Rename the with n-1 count\n              await this._renameImage(animation, `${image.lottieAssetId}_${count}`, image.lottieAssetId);\n            }\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Renames the underlying LottieAudio, as well as updating the audio asset path inside the animation data.\n   * @param newName - desired id and fileName,\n   * @param audioId - The id of the LottieAudio to rename\n   */\n  private async _renameAudio(animation: LottieAnimationCommon, newName: string, audioId: string): Promise<void> {\n    for (const audioAsset of animation.audioAssets) {\n      if (audioAsset.id === audioId) {\n        // Rename the LottieImage\n        await audioAsset.renameAudio(newName);\n\n        if (!animation.data) throw new DotLottieError('No animation data available.');\n\n        const animationAssets = animation.data.assets as AnimationType['assets'];\n\n        if (!animationAssets) throw new DotLottieError('No audio assets to rename.');\n\n        // Find the audio asset inside the animation data and rename its path\n        for (const asset of animationAssets) {\n          if (isAudioAsset(asset)) {\n            if (asset.id === audioId) {\n              asset.p = audioAsset.fileName;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  private async _renameAudioAssets(): Promise<void> {\n    const audio: Map<string, LottieAudioCommon[]> = new Map();\n\n    this.animations.forEach((animation) => {\n      audio.set(animation.id, animation.audioAssets);\n    });\n\n    let size = 0;\n\n    audio.forEach((value) => {\n      size += value.length;\n    });\n\n    for (let i = this.animations.length - 1; i >= 0; i -= 1) {\n      const animation = this.animations.at(i);\n\n      if (animation) {\n        for (let j = animation.audioAssets.length - 1; j >= 0; j -= 1) {\n          const audioAsset = animation.audioAssets.at(j);\n\n          if (audioAsset) {\n            await this._renameAudio(animation, `audio_${size}`, audioAsset.id);\n            size -= 1;\n          }\n        }\n      }\n    }\n  }\n\n  protected _addLottieAnimation(animation: LottieAnimationCommon): DotLottieCommon {\n    if (this._animationsMap.get(animation.id)) {\n      throw new DotLottieError('Duplicate animation id detected, aborting.');\n    }\n\n    this._animationsMap.set(animation.id, animation);\n\n    return this;\n  }\n\n  /**\n   * Inlines all assets of the passed animation\n   * @param animation - Animation whose asset are to be inlined\n   * @returns LottieAnimationCommon with inlined assets\n   */\n  private async _findAssetsAndInline(animation: LottieAnimationCommon): Promise<LottieAnimationCommon> {\n    const animationAssets = animation.data?.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError(\"Failed to inline assets, the animation's assets are undefined.\");\n\n    const images = this.getImages();\n    const audios = this.getAudio();\n\n    for (const asset of animationAssets) {\n      if (isImageAsset(asset)) {\n        for (const image of images) {\n          if (image.fileName === asset.p) {\n            // encoded is true\n            asset.e = 1;\n            asset.u = '';\n            asset.p = await image.toDataURL();\n          }\n        }\n      } else if (isAudioAsset(asset)) {\n        for (const audio of audios) {\n          if (audio.fileName === asset.p) {\n            // encoded is true\n            asset.e = 1;\n            asset.u = '';\n            asset.p = await audio.toDataURL();\n          }\n        }\n      }\n    }\n\n    return animation;\n  }\n\n  /**\n   * Returns the desired animation\n   * @param animationId - desired animation id\n   * @param inlineAssets - if true will inline the assets inside the data of the LottieAnimationV1\n   * @returns\n   */\n  public async getAnimation(\n    animationId: string,\n    options?: GetAnimationOptions,\n  ): Promise<LottieAnimationCommon | undefined> {\n    if (!options?.inlineAssets) return this._animationsMap.get(animationId);\n\n    let dataWithInlinedImages = this._animationsMap.get(animationId);\n\n    if (!dataWithInlinedImages) throw new DotLottieError('Failed to find animation.');\n\n    dataWithInlinedImages = await this._findAssetsAndInline(dataWithInlinedImages);\n\n    return dataWithInlinedImages;\n  }\n\n  public getAnimations(): Array<[string, LottieAnimationCommon]> | undefined {\n    return Array.from(this._animationsMap);\n  }\n\n  public removeAnimation(animationId: string): DotLottieCommon {\n    const targetAnimation = this._animationsMap.get(animationId);\n\n    if (targetAnimation) {\n      const assignedThemes = targetAnimation.themes;\n\n      for (const assignedTheme of assignedThemes) {\n        this.unscopeTheme({\n          animationId: targetAnimation.id,\n          themeId: assignedTheme.id,\n        });\n      }\n\n      this._animationsMap.delete(targetAnimation.id);\n    }\n\n    return this;\n  }\n\n  public getImages(): LottieImageCommon[] {\n    const images: LottieImageCommon[] = [];\n\n    this.animations.map((animation) => {\n      return images.push(...animation.imageAssets);\n    });\n\n    return images;\n  }\n\n  public getAudio(): LottieAudioCommon[] {\n    const audio: LottieAudioCommon[] = [];\n\n    this.animations.map((animation) => {\n      return audio.push(...animation.audioAssets);\n    });\n\n    return audio;\n  }\n\n  public getTheme(themeId: string): LottieThemeCommon | undefined {\n    return this._themesMap.get(themeId);\n  }\n\n  protected _buildManifest(): Manifest {\n    const animationsList = Array.from(this._animationsMap.values());\n    const themesList = Array.from(this._themesMap.values());\n    const stateMachinesList = Array.from(this._stateMachinesMap.values());\n    const activeAnimationId = animationsList.find((value) => value.defaultActiveAnimation)?.id ?? '';\n\n    const manifest: Manifest = {\n      version: this.version,\n      generator: this.generator,\n      animations: animationsList.map((animation) => ({\n        id: animation.id,\n        ...(animation.name ? { name: animation.name } : {}),\n        ...(animation.initialTheme ? { initialTheme: animation.initialTheme } : {}),\n        ...(animation.background ? { background: animation.background } : {}),\n        ...(animation.themes.length > 0 ? { themes: animation.themes.map((theme) => theme.id) } : {}),\n      })),\n    };\n\n    if (themesList.length > 0) {\n      manifest.themes = themesList.map((theme) => ({\n        id: theme.id,\n        ...(theme.name ? { name: theme.name } : {}),\n      }));\n    }\n\n    if (stateMachinesList.length > 0) {\n      manifest.stateMachines = stateMachinesList.map((stateMachine) => ({\n        id: stateMachine.id,\n        ...(stateMachine.name ? { name: stateMachine.name } : {}),\n      }));\n    }\n\n    if (activeAnimationId) {\n      manifest.initial = {\n        animation: activeAnimationId,\n      };\n    }\n\n    return manifest;\n  }\n\n  /**\n   * Constructs the manifest and calls toJSON on the animations\n   * so the data is fetched for every animation.\n   *\n   * @returns DotLottie context\n   */\n  public async build(): Promise<DotLottieCommon> {\n    this._buildManifest();\n\n    for (const animation of this.animations) {\n      await animation.toJSON();\n    }\n\n    if (this.animations.length > 1) {\n      // Rename assets incrementally if there are multiple animations\n      await this._renameImageAssets();\n      await this._renameAudioAssets();\n    }\n\n    const parallelPlugins = [];\n    const sequentialPlugins = [];\n\n    for (const plugin of this.plugins) {\n      if (plugin.parallel) {\n        parallelPlugins.push(plugin);\n      } else {\n        sequentialPlugins.push(plugin);\n      }\n    }\n\n    // Run parallel plugins\n    await Promise.all(parallelPlugins.map(async (plugin) => plugin.onBuild()));\n\n    // Run sequential plugins\n    for (const plugin of sequentialPlugins) {\n      await plugin.onBuild();\n    }\n\n    return this;\n  }\n\n  public async toBlob(options: ConversionOptions | undefined = undefined): Promise<Blob> {\n    const arrayBuffer = await this.toArrayBuffer(options);\n\n    return new Blob([arrayBuffer], { type: 'application/zip' });\n  }\n\n  /**\n   * Creates a DotLottie instance from a url to a dotlottie file\n   * @param url - url to the dotlottie file\n   * @returns DotLottie instance\n   */\n  public async fromURL(url: string): Promise<DotLottieCommon> {\n    if (!isValidURL(url)) throw new DotLottieError('Invalid URL');\n\n    try {\n      const response = await fetch(url);\n\n      if (!response.ok) {\n        throw new DotLottieError(response.statusText);\n      }\n\n      const arrayBuffer = await response.arrayBuffer();\n\n      return this.fromArrayBuffer(arrayBuffer);\n    } catch (err) {\n      if (err instanceof Error) {\n        throw new DotLottieError(err.message);\n      }\n    }\n\n    throw new DotLottieError('Unknown error');\n  }\n\n  public merge(...dotlotties: DotLottieCommon[]): DotLottieCommon {\n    const mergedDotlottie = this.create();\n\n    for (const dotlottie of dotlotties) {\n      dotlottie.themes.forEach((theme) => {\n        mergedDotlottie.addTheme({\n          id: theme.id,\n          name: theme.name,\n          data: theme.data,\n        });\n      });\n\n      dotlottie.animations.forEach((animation) => {\n        if (animation.data) {\n          mergedDotlottie.addAnimation({\n            id: animation.id,\n            name: animation.name,\n            data: animation.data,\n          });\n        } else if (animation.url) {\n          mergedDotlottie.addAnimation({\n            id: animation.id,\n            name: animation.name,\n            url: animation.url,\n          });\n        }\n\n        animation.themes.forEach((theme) => {\n          mergedDotlottie.scopeTheme({\n            animationId: animation.id,\n            themeId: theme.id,\n          });\n        });\n      });\n\n      dotlottie.stateMachines.forEach((stateMachine) => {\n        const stateOption = {\n          id: stateMachine.id,\n          name: stateMachine.name,\n          data: {\n            states: stateMachine.states,\n            initial: stateMachine.initial,\n            listeners: stateMachine.listeners,\n            triggers: stateMachine.triggers,\n          },\n          zipOptions: stateMachine.zipOptions,\n        };\n\n        mergedDotlottie.addStateMachine(stateOption);\n      });\n    }\n\n    return mergedDotlottie;\n  }\n\n  public addTheme(themeOptions: ThemeOptions): DotLottieCommon {\n    const theme = new LottieThemeCommon(themeOptions);\n\n    this._themesMap.set(theme.id, theme);\n\n    return this;\n  }\n\n  public removeTheme(id: string): DotLottieCommon {\n    const targetTheme = this._themesMap.get(id);\n\n    if (targetTheme) {\n      for (const animation of this.animations) {\n        if (animation.themes.includes(targetTheme)) {\n          animation.unscopeTheme(targetTheme.id);\n        }\n      }\n\n      this._themesMap.delete(targetTheme.id);\n    }\n\n    return this;\n  }\n\n  public scopeTheme({ animationId, themeId }: { animationId: string; themeId: string }): DotLottieCommon {\n    const theme = this._themesMap.get(themeId);\n\n    if (!theme) throw new DotLottieError(`Failed to find theme with id ${themeId}`);\n\n    const animation = this._animationsMap.get(animationId);\n\n    if (!animation) throw new DotLottieError(`Failed to find animation with id ${animationId}`);\n\n    animation.scopeTheme(theme);\n\n    return this;\n  }\n\n  public unscopeTheme({ animationId, themeId }: { animationId: string; themeId: string }): DotLottieCommon {\n    const theme = this._themesMap.get(themeId);\n\n    if (!theme) throw new DotLottieError(`Failed to find theme with id ${themeId}`);\n\n    const animation = this._animationsMap.get(animationId);\n\n    if (!animation) throw new DotLottieError(`Failed to find animation with id ${animationId}`);\n\n    animation.unscopeTheme(theme.id);\n\n    return this;\n  }\n\n  public addStateMachine(stateMachineOptions: DotLottieStateMachineCommonOptions): DotLottieCommon {\n    const newState = new DotLottieStateMachineCommon(stateMachineOptions);\n\n    this._stateMachinesMap.set(stateMachineOptions.id, newState);\n\n    return this;\n  }\n\n  public getStateMachine(stateId: string): DotLottieStateMachineCommon | undefined {\n    return this._stateMachinesMap.get(stateId);\n  }\n\n  public removeStateMachine(stateMachineId: string): DotLottieCommon {\n    this._stateMachinesMap.delete(stateMachineId);\n\n    return this;\n  }\n\n  protected _requireValidDescription(description: string | undefined): asserts description is string {\n    if (typeof description !== 'string') throw new DotLottieError('Invalid description');\n  }\n\n  protected _requireValidGenerator(generator: string | undefined): asserts generator is string {\n    if (typeof generator !== 'string') throw new DotLottieError('Invalid generator');\n  }\n\n  protected _requireValidKeywords(keywords: string | undefined): asserts keywords is string {\n    if (typeof keywords !== 'string') throw new DotLottieError('Invalid keywords');\n  }\n\n  protected _requireValidVersion(version: string | undefined): asserts version is string {\n    if (typeof version !== 'string') throw new DotLottieError('Invalid version');\n  }\n\n  protected _requireValidCustomData(\n    customData: Record<string, unknown> | undefined,\n  ): asserts customData is Record<string, unknown> {\n    if (!customData) throw new DotLottieError('Invalid customData');\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\nimport type { ZipOptions } from 'fflate';\n\nimport type { AnimationData, ExportOptions } from '../../types';\nimport { DotLottieError, isAudioAsset } from '../../utils';\n\nimport type { LottieAudioCommon } from './audio';\nimport type { LottieImageCommon } from './image';\nimport type { ManifestAnimation } from './schemas';\nimport type { LottieThemeCommon } from './theme';\n\nexport interface AnimationOptions extends ManifestAnimation {\n  data?: AnimationData | undefined;\n  defaultActiveAnimation?: boolean | undefined;\n  url?: string | undefined;\n  zipOptions?: ZipOptions | undefined;\n}\n\nexport class LottieAnimationCommon {\n  protected _name: string | undefined;\n\n  protected _data?: AnimationData;\n\n  protected _id: string = '';\n\n  protected _url?: string;\n\n  private _zipOptions: ZipOptions;\n\n  // This indicates if the player should play this animation by default rather than the first in the list.\n  protected _defaultActiveAnimation: boolean;\n\n  protected _imageAssets: LottieImageCommon[] = [];\n\n  protected _audioAssets: LottieAudioCommon[] = [];\n\n  protected _themesMap: Map<string, LottieThemeCommon> = new Map();\n\n  protected _initialTheme: string | null = null;\n\n  protected _background: string | null = null;\n\n  public constructor(options: AnimationOptions) {\n    this._requireValidOptions(options);\n\n    this._id = options.id;\n    this._name = options.name;\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) this._data = options.data;\n    if (options.url) this._url = options.url;\n\n    this._background = options.background ?? null;\n    this._initialTheme = options.initialTheme ?? null;\n\n    this._defaultActiveAnimation = options.defaultActiveAnimation ?? false;\n  }\n\n  public async toBase64(): Promise<string> {\n    throw new DotLottieError('lottie animation controls tobase64 not implemented!');\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get name(): string | undefined {\n    return this._name;\n  }\n\n  public set name(name: string | undefined) {\n    this._name = name;\n  }\n\n  public get background(): string | null {\n    return this._background;\n  }\n\n  public set background(background: string | null) {\n    this._background = background;\n  }\n\n  public get initialTheme(): string | null {\n    return this._initialTheme;\n  }\n\n  public set initialTheme(initialTheme: string | null) {\n    this._initialTheme = initialTheme;\n  }\n\n  public get themes(): LottieThemeCommon[] {\n    return Array.from(this._themesMap.values());\n  }\n\n  public set themes(themes: LottieThemeCommon[]) {\n    this._themesMap = new Map();\n    themes.forEach((theme) => {\n      this._themesMap.set(theme.id, theme);\n    });\n  }\n\n  public get imageAssets(): LottieImageCommon[] {\n    return this._imageAssets;\n  }\n\n  public set imageAssets(imageAssets: LottieImageCommon[]) {\n    this._imageAssets = imageAssets;\n  }\n\n  public get audioAssets(): LottieAudioCommon[] {\n    return this._audioAssets;\n  }\n\n  public set audioAssets(audioAssets: LottieAudioCommon[]) {\n    this._audioAssets = audioAssets;\n  }\n\n  public get data(): AnimationData | undefined {\n    return this._data;\n  }\n\n  public set data(data: AnimationData | undefined) {\n    this._requireValidLottieData(data);\n\n    this._data = data;\n  }\n\n  public get url(): string | undefined {\n    return this._url;\n  }\n\n  public set url(url: string | undefined) {\n    this._requireValidUrl(url);\n\n    this._url = url;\n  }\n\n  public get defaultActiveAnimation(): boolean {\n    return this._defaultActiveAnimation;\n  }\n\n  public set defaultActiveAnimation(defaultActiveAnimation: boolean) {\n    this._defaultActiveAnimation = defaultActiveAnimation;\n  }\n\n  public scopeTheme(theme: LottieThemeCommon): void {\n    this._themesMap.set(theme.id, theme);\n  }\n\n  public unscopeTheme(themeId: string): void {\n    this._themesMap.delete(themeId);\n  }\n\n  /**\n   * Return the animation data as an array buffer.\n   * @returns data - The animation data as an ArrayBuffer.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toArrayBuffer(options?: ExportOptions): Promise<ArrayBuffer> {\n    const dataJson = await this.toJSON(options);\n\n    return new TextEncoder().encode(JSON.stringify(dataJson)).buffer;\n  }\n\n  protected async _extractImageAssets(): Promise<boolean> {\n    throw new DotLottieError('_extractImageAssets(): Promise<boolean> method not implemented in concrete class');\n  }\n\n  protected async _extractAudioAssets(): Promise<boolean> {\n    throw new DotLottieError('_extractAudioAssets(): Promise<boolean> method not implemented in concrete class');\n  }\n\n  /**\n   * Return the animation data as a blob.\n   * @returns blob - The animation data as a Blob.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toBlob(options?: ExportOptions): Promise<Blob> {\n    const dataJson = await this.toJSON(options);\n\n    return new Blob([JSON.stringify(dataJson)], { type: 'application/json' });\n  }\n\n  /**\n   * Return the animation data as a JSON object.\n   * If the animation data is not already set, it will be fetched from the provided url.\n   * @returns data - The animation data.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toJSON(options?: ExportOptions): Promise<AnimationType> {\n    if (this._url && !this._data) {\n      this._data = await this._fromUrl(this._url);\n    }\n\n    this._requireValidLottieData(this._data);\n\n    if (this._data.assets?.length) {\n      // Even if the user wants to inline the assets, we still need to extract them\n      await this._extractImageAssets();\n      await this._extractAudioAssets();\n\n      if (options?.inlineAssets) {\n        const animationAssets = this.data?.assets as AnimationType['assets'];\n\n        if (!animationAssets)\n          throw new DotLottieError(\"Failed to inline assets, the animation's assets are undefined.\");\n\n        const images = this.imageAssets;\n        const audios = this.audioAssets;\n\n        for (const asset of animationAssets) {\n          if ('w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset) {\n            for (const image of images) {\n              if (image.fileName === asset.p) {\n                // encoded is true\n                asset.e = 1;\n                asset.u = '';\n                asset.p = await image.toDataURL();\n              }\n            }\n          } else if (isAudioAsset(asset)) {\n            // Audio asset\n            for (const audio of audios) {\n              if (audio.fileName === asset.p) {\n                // encoded is true\n                asset.e = 1;\n                asset.u = '';\n                asset.p = await audio.toDataURL();\n              }\n            }\n          }\n        }\n      }\n    }\n\n    return this._data;\n  }\n\n  /**\n   * Fetch the animation data from the provided url.\n   * @param url - The url to fetch the animation data from.\n   * @returns animationData - The animation data.\n   * @throws Error - if the fetch request fails.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   */\n  private async _fromUrl(url: string): Promise<AnimationType> {\n    const response = await fetch(url);\n\n    const text = await response.text();\n\n    let json;\n\n    try {\n      json = JSON.parse(text);\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new DotLottieError(`${error.message}: Invalid json returned from url`);\n      }\n    }\n\n    this._requireValidLottieData(json as AnimationData);\n\n    return json;\n  }\n\n  /**\n   * Ensure that the provided url is a valid string.\n   * The url must be a non-empty string, otherwise an error will be thrown.\n   * @param url - The url to validate.\n   * @throws Error - if the url is not a valid string.\n   *\n   */\n  private _requireValidUrl(url: string | undefined): asserts url is string {\n    try {\n      // eslint-disable-next-line no-new\n      new URL(url || '');\n    } catch (_err) {\n      throw new DotLottieError('Invalid animation url');\n    }\n  }\n\n  /**\n   * Ensure that the provided data object is a valid Lottie animation data object.\n   * The data object must contain the following mandatory properties: v, ip, op, layers, fr, w, h.\n   * If the data object does not contain all mandatory properties, an error will be thrown.\n   * @param data - The data object to validate.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   */\n  private _requireValidLottieData(data: AnimationData | undefined): asserts data is AnimationData {\n    const mandatoryLottieProperties = ['v', 'ip', 'op', 'layers', 'fr', 'w', 'h'];\n\n    const hasAllMandatoryProperties = mandatoryLottieProperties.every((field) =>\n      Object.prototype.hasOwnProperty.call(data, field),\n    );\n\n    if (!hasAllMandatoryProperties) {\n      throw new DotLottieError('Received invalid Lottie data.');\n    }\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid animation id');\n  }\n\n  /**\n   * Ensure that the provided options object is a valid AnimationOptions object.\n   * The options object must contain the following mandatory properties: id, data or url.\n   * If the options object does not contain all mandatory properties, an error will be thrown.\n   * @param options - The options object to validate.\n   * @throws Error - if the options object is not a valid AnimationOptions object.\n   * @throws Error - if the id is not a valid string.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   * @throws Error - if the url is not a valid url string.\n   * @throws Error - if the data object is not set and the url is not provided.\n   */\n  private _requireValidOptions(options: AnimationOptions): asserts options is AnimationOptions {\n    this._requireValidId(options.id);\n\n    if (!options.data && !options.url) {\n      throw new DotLottieError('No data or url provided.');\n    }\n\n    if (options.data) {\n      this._requireValidLottieData(options.data);\n    }\n\n    if (options.url) {\n      this._requireValidUrl(options.url);\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\n\nimport type { ImageData } from '../../types';\nimport { dataUrlFromU8, DotLottieError, getExtensionTypeFromBase64 } from '../../utils';\n\nimport type { LottieAnimationCommon } from './animation';\n\nexport interface ImageOptions {\n  data?: ImageData;\n  fileName: string;\n  id: string;\n  lottieAssetId: string;\n  parentAnimations?: LottieAnimationCommon[];\n  zipOptions?: ZipOptions;\n}\n\nexport class LottieImageCommon {\n  protected _data?: ImageData;\n\n  /**\n   * Unique id for the LottieImageCommon object. This is never modified.\n   */\n  protected _id: string = '';\n\n  /**\n   * Asset id representing the image asset inside the Lottie animation. This can be modified.\n   */\n  protected _lottieAssetId: string = '';\n\n  protected _fileName: string = '';\n\n  protected _parentAnimations: LottieAnimationCommon[];\n\n  protected _zipOptions: ZipOptions;\n\n  public constructor(options: ImageOptions) {\n    this._requireValidId(options.id);\n    this._requireValidLottieAssetId(options.lottieAssetId);\n    this._requireValidFileName(options.fileName);\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) {\n      this._data = options.data;\n    }\n\n    if (options.id) {\n      this._id = options.id;\n    }\n\n    if (options.lottieAssetId) {\n      this._lottieAssetId = options.lottieAssetId;\n    }\n\n    if (options.fileName) {\n      this._fileName = options.fileName;\n    }\n\n    this._parentAnimations = options.parentAnimations || [];\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid image id');\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidLottieAssetId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid Lottie Image Asset Id');\n  }\n\n  /**\n   * Ensure that the provided fileName is a valid string.\n   * The fileName must be a non-empty string, otherwise an error will be thrown.\n   * @param fileName - The fileName to validate.\n   * @throws Error - if the fileName is not a valid string.\n   */\n  private _requireValidFileName(fileName: string | undefined): asserts fileName is string {\n    if (!fileName) throw new DotLottieError('Invalid image fileName');\n  }\n\n  public get fileName(): string {\n    return this._fileName;\n  }\n\n  public set fileName(fileName: string) {\n    this._requireValidFileName(fileName);\n\n    this._fileName = fileName;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get lottieAssetId(): string {\n    return this._lottieAssetId;\n  }\n\n  public set lottieAssetId(id: string) {\n    this._requireValidLottieAssetId(id);\n    this._lottieAssetId = id;\n  }\n\n  public get data(): ImageData | undefined {\n    return this._data;\n  }\n\n  public set data(data: ImageData | undefined) {\n    if (!data) {\n      throw new DotLottieError('Invalid data');\n    }\n\n    this._data = data;\n  }\n\n  public get parentAnimations(): LottieAnimationCommon[] {\n    return this._parentAnimations;\n  }\n\n  public set parentAnimations(parentAnimations: LottieAnimationCommon[]) {\n    this._parentAnimations = parentAnimations;\n  }\n\n  public async toDataURL(): Promise<string> {\n    if (this._data && this._isDataURL(this._data)) return this.data as string;\n\n    const arrayBuffer = await this.toArrayBuffer();\n\n    return dataUrlFromU8(new Uint8Array(arrayBuffer));\n  }\n\n  /**\n   * Renames the id and fileName to newName.\n   * @param newName - A new id and filename for the image.\n   */\n  public async renameImage(newLottieAssetId: string): Promise<void> {\n    this._lottieAssetId = newLottieAssetId;\n\n    const data = await this.toDataURL();\n\n    const ext = await getExtensionTypeFromBase64(data);\n\n    if (!ext) {\n      throw new DotLottieError('File extension type could not be detected from asset file.');\n    }\n\n    this.fileName = `${newLottieAssetId}.${ext}`;\n  }\n\n  public async toArrayBuffer(): Promise<ArrayBuffer> {\n    const blob = await (await this.toBlob()).arrayBuffer();\n\n    return blob;\n  }\n\n  public async toBlob(): Promise<Blob> {\n    if (!this._data) {\n      throw new DotLottieError('Invalid image data.');\n    }\n\n    if (this._isDataURL(this._data)) {\n      const data = this._data as string;\n\n      const [header, base64] = data.split(',');\n\n      // If the data doesnt contain the encoding URL, return it\n      if ((!header || !base64) && data.length) {\n        return new Blob([data]);\n      }\n\n      if (!header || !base64) {\n        throw new DotLottieError('Invalid image data.');\n      }\n\n      // eslint-disable-next-line require-unicode-regexp\n      const type = header.replace('data:', '').replace(/;base64$/, '');\n\n      return new Blob([base64], { type });\n    }\n\n    if (this._isArrayBuffer(this._data)) {\n      return new Blob([this._data]);\n    }\n\n    if (this._isBlob(this._data)) {\n      return this._data as Blob;\n    }\n\n    throw new DotLottieError('Invalid image data.');\n  }\n\n  protected async _fromUrlToBlob(url: string): Promise<Blob> {\n    const response = await fetch(url);\n\n    return response.blob();\n  }\n\n  protected _isArrayBuffer(data: ImageData): boolean {\n    return data instanceof ArrayBuffer;\n  }\n\n  protected _isDataURL(data: ImageData): boolean {\n    return typeof data === 'string' && data.startsWith('data:');\n  }\n\n  protected _isBlob(data: ImageData): boolean {\n    return data instanceof Blob;\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\n\nimport type { AudioData } from '../../types';\nimport { dataUrlFromU8, DotLottieError, ErrorCodes, getExtensionTypeFromBase64 } from '../../utils';\n\nimport type { LottieAnimationCommon } from './animation';\n\nexport interface AudioOptions {\n  data?: AudioData;\n  fileName: string;\n  id: string;\n  parentAnimations?: LottieAnimationCommon[];\n  url?: string;\n  zipOptions?: ZipOptions;\n}\n\nexport class LottieAudioCommon {\n  protected _data?: AudioData;\n\n  protected _id: string = '';\n\n  protected _url?: string;\n\n  protected _fileName: string = '';\n\n  protected _parentAnimations: LottieAnimationCommon[];\n\n  protected _zipOptions: ZipOptions;\n\n  public constructor(options: AudioOptions) {\n    this._requireValidId(options.id);\n    this._requireValidFileName(options.fileName);\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) {\n      this._data = options.data;\n    }\n\n    if (options.id) {\n      this._id = options.id;\n    }\n\n    if (options.url) {\n      this._url = options.url;\n    }\n\n    if (options.fileName) {\n      this._fileName = options.fileName;\n    }\n\n    this._parentAnimations = options.parentAnimations || [];\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get fileName(): string {\n    return this._fileName;\n  }\n\n  public set fileName(fileName: string) {\n    if (!fileName) throw new DotLottieError('Invalid audio file name', ErrorCodes.ASSET_NOT_FOUND);\n    this._fileName = fileName;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    if (!id) throw new DotLottieError('Invalid audio id', ErrorCodes.ASSET_NOT_FOUND);\n    this._id = id;\n  }\n\n  public get data(): AudioData | undefined {\n    return this._data;\n  }\n\n  public set data(data: AudioData | undefined) {\n    if (!data) {\n      throw new DotLottieError('Invalid data');\n    }\n\n    this._data = data;\n  }\n\n  public get parentAnimations(): LottieAnimationCommon[] {\n    return this._parentAnimations;\n  }\n\n  public set parentAnimations(parentAnimations: LottieAnimationCommon[]) {\n    this._parentAnimations = parentAnimations;\n  }\n\n  public async toDataURL(): Promise<string> {\n    if (this._data && this._isDataURL(this._data)) return this.data as string;\n\n    const arrayBuffer = await this.toArrayBuffer();\n\n    return dataUrlFromU8(new Uint8Array(arrayBuffer));\n  }\n\n  /**\n   * Renames the id and fileName to newName.\n   * @param newName - A new id and filename for the audio.\n   */\n  public async renameAudio(newName: string): Promise<void> {\n    this.id = newName;\n\n    const data = await this.toDataURL();\n\n    const ext = await getExtensionTypeFromBase64(data);\n\n    if (!ext) {\n      throw new DotLottieError('File extension type could not be detected from asset file.');\n    }\n\n    this.fileName = `${newName}.${ext}`;\n  }\n\n  public async toArrayBuffer(): Promise<ArrayBuffer> {\n    const blob = await (await this.toBlob()).arrayBuffer();\n\n    return blob;\n  }\n\n  public async toBlob(): Promise<Blob> {\n    if (!this._data && this._url) {\n      this._data = await this._fromUrlToBlob(this._url);\n    }\n\n    if (!this._data) {\n      throw new Error('Invalid data');\n    }\n\n    if (this._isDataURL(this._data)) {\n      const data = this._data as string;\n\n      const [header, base64] = data.split(',');\n\n      // If the data doesnt contain the encoding URL, return it\n      if ((!header || !base64) && data.length) {\n        return new Blob([data]);\n      }\n\n      if (!header || !base64) {\n        throw new Error('Invalid data');\n      }\n\n      // eslint-disable-next-line require-unicode-regexp\n      const type = header.replace('data:', '').replace(/;base64$/, '');\n\n      return new Blob([base64], { type });\n    }\n\n    if (this._isArrayBuffer(this._data)) {\n      return new Blob([this._data]);\n    }\n\n    if (this._isBlob(this._data)) {\n      return this._data as Blob;\n    }\n\n    throw new Error('Invalid data');\n  }\n\n  protected async _fromUrlToBlob(url: string): Promise<Blob> {\n    const response = await fetch(url);\n\n    return response.blob();\n  }\n\n  protected _isArrayBuffer(data: AudioData): boolean {\n    return data instanceof ArrayBuffer;\n  }\n\n  protected _isDataURL(data: AudioData): boolean {\n    return typeof data === 'string' && data.startsWith('data:');\n  }\n\n  protected _isBlob(data: AudioData): boolean {\n    return data instanceof Blob;\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid audio id');\n  }\n\n  /**\n   * Ensure that the provided fileName is a valid string.\n   * The fileName must be a non-empty string, otherwise an error will be thrown.\n   * @param fileName - The fileName to validate.\n   * @throws Error - if the fileName is not a valid string.\n   */\n  private _requireValidFileName(fileName: string | undefined): asserts fileName is string {\n    if (!fileName) throw new DotLottieError('Invalid audio fileName');\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { AudioOptions } from '../common';\nimport { LottieAudioCommon } from '../common';\n\nexport class LottieAudio extends LottieAudioCommon {\n  public constructor(options: AudioOptions) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ImageOptions } from '../common';\nimport { LottieImageCommon } from '../common';\n\nexport class LottieImage extends LottieImageCommon {\n  public constructor(options: ImageOptions) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { DotLottieError, getExtensionTypeFromBase64, isAudioAsset } from '../../utils';\nimport type { AnimationOptions } from '../common';\nimport { LottieAnimationCommon } from '../common';\n\nimport { LottieAudio } from './audio';\nimport { LottieImage } from './image';\n\nexport class LottieAnimation extends LottieAnimationCommon {\n  public constructor(options: AnimationOptions) {\n    super(options);\n  }\n\n  /**\n   * Return the animation data as a base64 encoded string.\n   *\n   * @returns data - The animation data as a base64 encoded string.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public override async toBase64(): Promise<string> {\n    const data = await this.toArrayBuffer();\n\n    if (typeof window === 'undefined') return Buffer.from(data).toString('base64');\n\n    const uint8Array = new Uint8Array(data);\n    const binaryString = uint8Array.reduce((acc, val) => acc + String.fromCharCode(val), '');\n\n    return window.btoa(binaryString);\n  }\n\n  /**\n   *\n   * Extract image assets from the animation.\n   *\n   * @returns boolean - true on error otherwise false on success\n   */\n  protected override async _extractImageAssets(): Promise<boolean> {\n    if (!this._data) throw new DotLottieError('Failed to extract image assets: Animation data does not exist');\n\n    const animationAssets = this._data.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError('Failed to extract image assets: No assets found inside animation');\n\n    for (const asset of animationAssets) {\n      if ('w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset) {\n        const imageData = asset.p.split(',');\n\n        // Image data is invalid\n        if (!imageData.length || !imageData[0] || !imageData[1]) {\n          break;\n        }\n\n        let extType = null;\n        const fileType = await getExtensionTypeFromBase64(asset.p);\n\n        // If we don't recognize the file type, we leave it inside the animation as is.\n        if (fileType) {\n          extType = fileType;\n\n          const fileName = `${asset.id}.${extType}`;\n\n          this._imageAssets.push(\n            new LottieImage({\n              data: asset.p,\n              id: asset.id,\n              lottieAssetId: asset.id,\n              fileName,\n              parentAnimations: [this],\n            }),\n          );\n\n          asset.p = fileName;\n          asset.u = '/i/';\n          asset.e = 0;\n        }\n      }\n    }\n\n    return false;\n  }\n\n  /**\n   *\n   * Extract audio assets from the animation.\n   *\n   * @returns boolean - true on error otherwise false on success\n   */\n  protected override async _extractAudioAssets(): Promise<boolean> {\n    if (!this._data) throw new DotLottieError('Failed to extract audio assets: Animation data does not exist');\n\n    const animationAssets = this._data.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError('Failed to extract image assets: No assets found inside animation');\n\n    for (const asset of animationAssets) {\n      if (isAudioAsset(asset)) {\n        const audioData = asset.p.split(',');\n\n        // Audio data is invalid\n        if (!audioData.length || !audioData[0] || !audioData[1]) {\n          break;\n        }\n\n        let extType = null;\n        const fileType = await getExtensionTypeFromBase64(asset.p);\n\n        extType = fileType;\n\n        const fileName = `${asset.id}.${extType}`;\n\n        this._audioAssets.push(\n          new LottieAudio({\n            data: asset.p,\n            id: asset.id,\n            fileName,\n            parentAnimations: [this],\n          }),\n        );\n\n        asset.p = fileName;\n        asset.u = '/u/';\n        asset.e = 0;\n      }\n    }\n\n    return false;\n  }\n}\n","var __read = (this && this.__read) || function (o, n) {\n    var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n    if (!m) return o;\n    var i = m.call(o), r, ar = [], e;\n    try {\n        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n    }\n    catch (error) { e = { error: error }; }\n    finally {\n        try {\n            if (r && !r.done && (m = i[\"return\"])) m.call(i);\n        }\n        finally { if (e) throw e.error; }\n    }\n    return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from) {\n    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n        to[j] = from[i];\n    return to;\n};\nvar VanilaConverter = /** @class */ (function () {\n    function VanilaConverter(document, glayScaleCalculator, resizer) {\n        this.document = document;\n        this.glayScaleCalculator = glayScaleCalculator;\n        this.resizer = resizer;\n    }\n    VanilaConverter.prototype.createCanvasRenderingContext2D = function (width, height) {\n        var canvas = this.document.createElement('canvas');\n        canvas.width = width;\n        canvas.height = height;\n        canvas.setAttribute('style', 'image-rendering: -webkit-optimize-contrast; image-rendering: crisp-edges;');\n        var ctx = canvas.getContext('2d');\n        if (ctx === null) {\n            throw new ReferenceError('undefined CanvasRenderingContext2D');\n        }\n        ctx.mozImageSmoothingEnabled = true;\n        ctx.webkitImageSmoothingEnabled = true;\n        ctx.msImageSmoothingEnabled = true;\n        ctx.imageSmoothingEnabled = true;\n        return ctx;\n    };\n    VanilaConverter.prototype.convert = function (source) {\n        var _this = this;\n        var img = new Image();\n        var result = (new Promise(function (resolve) {\n            img.onload = function () {\n                var ctx = _this.createCanvasRenderingContext2D(img.width, img.height);\n                ctx.drawImage(img, 0, 0, img.width, img.height);\n                var colorMap = ctx.getImageData(0, 0, img.width, img.height).data;\n                resolve(colorMap);\n            };\n        }))\n            .then(function (colorMap) {\n            return _this.resizer.resize(colorMap, img.width, img.height, source.width, source.height);\n        }).then(function (resizedColorMap) {\n            var glayArraySouce = __spreadArray([], __read(Array(resizedColorMap.length / 4).keys())).map(function (i) {\n                var index = i * 4;\n                var _a = __read([\n                    resizedColorMap[index],\n                    resizedColorMap[index + 1],\n                    resizedColorMap[index + 2]\n                ], 3), r = _a[0], g = _a[1], b = _a[2];\n                return _this.glayScaleCalculator(r, g, b);\n            });\n            return new Uint8ClampedArray(glayArraySouce);\n        });\n        img.src = source.url.toString();\n        return result;\n    };\n    return VanilaConverter;\n}());\nexport default VanilaConverter;\n","var HashSource = /** @class */ (function () {\n    function HashSource(url, hashSize) {\n        if (hashSize === void 0) { hashSize = 8; }\n        this.url = url;\n        this.hashSize = hashSize;\n        this.width = hashSize + 1;\n        this.height = hashSize;\n    }\n    HashSource.prototype.calculateArea = function () {\n        return this.width * this.height;\n    };\n    return HashSource;\n}());\nexport default HashSource;\n","import { lanczos } from '@rgba-image/lanczos';\nvar LanczosResizer = /** @class */ (function () {\n    function LanczosResizer() {\n    }\n    LanczosResizer.prototype.resize = function (source, nativeWidth, nativeHeight, expectedWidth, expectedHeight) {\n        var sourceImageData = (new ImageDataSouce(nativeWidth, nativeHeight, source));\n        var destImageData = (new ImageDataSouce(expectedWidth, expectedHeight, new Uint8ClampedArray(expectedWidth * expectedHeight * 4)));\n        lanczos(sourceImageData, destImageData);\n        return destImageData.data;\n    };\n    return LanczosResizer;\n}());\nexport default LanczosResizer;\nvar ImageDataSouce = /** @class */ (function () {\n    function ImageDataSouce(width, height, source) {\n        this.width = width;\n        this.height = height;\n        this.data = source;\n    }\n    return ImageDataSouce;\n}());\n","var __read = (this && this.__read) || function (o, n) {\n    var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n    if (!m) return o;\n    var i = m.call(o), r, ar = [], e;\n    try {\n        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n    }\n    catch (error) { e = { error: error }; }\n    finally {\n        try {\n            if (r && !r.done && (m = i[\"return\"])) m.call(i);\n        }\n        finally { if (e) throw e.error; }\n    }\n    return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from) {\n    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n        to[j] = from[i];\n    return to;\n};\nvar Hash = /** @class */ (function () {\n    function Hash(rawHash) {\n        if (rawHash.split('').find(function (row) { return (row !== '1' && row !== '0'); })) {\n            throw new TypeError('Not bits.');\n        }\n        this.rawHash = rawHash;\n    }\n    Hash.prototype.getHammingDistance = function (hash) {\n        if (this.rawHash.length !== hash.rawHash.length) {\n            throw new TypeError('Not equal to hash length.');\n        }\n        var target = hash.rawHash.split('');\n        var diff = this.rawHash.split('').filter(function (row, index) { return row !== (target[index] || '0'); });\n        return diff.length;\n    };\n    Hash.prototype.toString = function () {\n        return this.calcuateHexadecimal(this.rawHash.split('').map(function (row) { return (row === '1') ? 1 : 0; }));\n    };\n    Hash.prototype.arrayChunk = function (array, chunk) {\n        return __spreadArray([], __read(Array(Math.ceil(array.length / chunk)).keys())).map(function (index) { return array.slice(index * chunk, (index * chunk) + chunk); });\n    };\n    Hash.prototype.calcuateHexadecimal = function (binalyNumbers) {\n        return this.arrayChunk(binalyNumbers, 4)\n            .map(function (row) { return parseInt(row.join(''), 2).toString(16); }).join('');\n    };\n    return Hash;\n}());\nexport default Hash;\n","var __read = (this && this.__read) || function (o, n) {\n    var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n    if (!m) return o;\n    var i = m.call(o), r, ar = [], e;\n    try {\n        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n    }\n    catch (error) { e = { error: error }; }\n    finally {\n        try {\n            if (r && !r.done && (m = i[\"return\"])) m.call(i);\n        }\n        finally { if (e) throw e.error; }\n    }\n    return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from) {\n    for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n        to[j] = from[i];\n    return to;\n};\nimport Hash from \"./Hash\";\nvar HashGenerator = /** @class */ (function () {\n    function HashGenerator(document) {\n        this.document = document;\n    }\n    HashGenerator.prototype.generateByImage = function (source, glayImage) {\n        glayImage.width = source.width;\n        glayImage.height = source.height;\n        var canvas = this.document.createElement('canvas');\n        var context = canvas.getContext('2d');\n        if (context === null) {\n            throw new ReferenceError('undefined CanvasRenderingContext2D');\n        }\n        context.drawImage(glayImage, 0, 0, source.width, source.height);\n        return this.generate(source, context);\n    };\n    HashGenerator.prototype.generateByCanvasRenderingContext2D = function (source, glayImageDrawingCanvasContext) {\n        var imageData = glayImageDrawingCanvasContext.getImageData(0, 0, source.width, source.height).data;\n        var glayArray = new Uint8ClampedArray(__spreadArray([], __read(Array(imageData.length / 4).keys())).map(function (i) {\n            var index = i * 4;\n            return imageData[index];\n        }));\n        return this.generate(source, glayArray);\n    };\n    HashGenerator.prototype.generateByUint8ClampedArray = function (source, glayArray) {\n        if (glayArray.length !== source.calculateArea()) {\n            throw new Error(\"Not convertable grayArray, convertable grayArray length is \" + source.calculateArea());\n        }\n        var binaryNumbers = Array.from(glayArray)\n            .map(function (row, index, colors) { return ((row <= colors[index + 1]) ? 1 : 0); })\n            .filter(function (_, index) { return (index + 1) % source.width !== 0; }).join('');\n        return new Hash(binaryNumbers);\n    };\n    HashGenerator.prototype.generate = function (source, glayImageSource) {\n        if (glayImageSource instanceof HTMLImageElement) {\n            return this.generateByImage(source, glayImageSource);\n        }\n        else if (glayImageSource instanceof CanvasRenderingContext2D) {\n            return this.generateByCanvasRenderingContext2D(source, glayImageSource);\n        }\n        else if (glayImageSource instanceof Uint8ClampedArray) {\n            return this.generateByUint8ClampedArray(source, glayImageSource);\n        }\n        throw new TypeError('Not generatable glay image source.');\n    };\n    return HashGenerator;\n}());\nexport default HashGenerator;\n","export default function ITU_R601_2Method(r, g, b) {\n    return Math.round((r * 299 / 1000 + g * 587 / 1000 + b * 114 / 1000));\n}\n;\n","var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n    return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n    function verb(n) { return function (v) { return step([n, v]); }; }\n    function step(op) {\n        if (f) throw new TypeError(\"Generator is already executing.\");\n        while (_) try {\n            if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n            if (y = 0, t) op = [op[0] & 2, t.value];\n            switch (op[0]) {\n                case 0: case 1: t = op; break;\n                case 4: _.label++; return { value: op[1], done: false };\n                case 5: _.label++; y = op[1]; op = [0]; continue;\n                case 7: op = _.ops.pop(); _.trys.pop(); continue;\n                default:\n                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                    if (t[2]) _.ops.pop();\n                    _.trys.pop(); continue;\n            }\n            op = body.call(thisArg, _);\n        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n    }\n};\nimport VanilaConverter from \"./HashableImageSourceConverter/DifferenceHash/VanilaConverter\";\nimport HashSource from \"./HashSource\";\nimport LanczosResizer from \"./HashableImageSourceConverter/Resizer/LanczosResizer\";\nimport HashGenerator from \"./HashGenerator\";\nimport ITU_R601_2Method from \"./HashableImageSourceConverter/GlayScaleCalculator/ITU_R601_2Method\";\nvar DifferenceHashBuilder = /** @class */ (function () {\n    function DifferenceHashBuilder(dHashConverter, document) {\n        if (dHashConverter === void 0) { dHashConverter = null; }\n        if (document === void 0) { document = window.document; }\n        if (dHashConverter === null) {\n            dHashConverter = new VanilaConverter(document, ITU_R601_2Method, new LanczosResizer());\n        }\n        this.dHashConverter = dHashConverter;\n        this.generator = new HashGenerator(document);\n    }\n    DifferenceHashBuilder.prototype.build = function (url, hashSize) {\n        if (hashSize === void 0) { hashSize = 8; }\n        return __awaiter(this, void 0, void 0, function () {\n            var source, hashableImageSouce;\n            return __generator(this, function (_a) {\n                switch (_a.label) {\n                    case 0:\n                        source = new HashSource(url, hashSize);\n                        return [4 /*yield*/, this.dHashConverter.convert(source)];\n                    case 1:\n                        hashableImageSouce = _a.sent();\n                        return [2 /*return*/, this.generator.generate(source, hashableImageSouce)];\n                }\n            });\n        });\n    };\n    return DifferenceHashBuilder;\n}());\nexport default DifferenceHashBuilder;\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { DotLottieError } from '../../utils';\n\nimport type { DotLottieCommon } from './dotlottie';\n\ninterface DotLottiePluginOptions {\n  parallel?: boolean;\n}\n\nexport class DotLottiePlugin {\n  protected dotlottie: DotLottieCommon | undefined;\n\n  protected _parallel: boolean = false;\n\n  public constructor(options?: DotLottiePluginOptions) {\n    this.dotlottie = undefined;\n\n    if (options?.parallel) {\n      this._parallel = options.parallel;\n    }\n  }\n\n  public install(dotlottie: DotLottieCommon): void {\n    this.dotlottie = dotlottie;\n  }\n\n  public uninstall(): void {\n    this.dotlottie = undefined;\n  }\n\n  public get parallel(): boolean {\n    return this._parallel;\n  }\n\n  public set parallel(value: boolean) {\n    this._parallel = value;\n  }\n\n  public async onBuild(): Promise<void> {\n    throw new DotLottieError('dotlottie-plugin build Not implemented!');\n  }\n\n  protected _requireDotLottie(dotLottie: DotLottieCommon | undefined): asserts dotLottie {\n    if (!dotLottie) throw new DotLottieError('dotLottie context is null inside of duplicate image detector plugin.');\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { DotLottieError } from '../../../utils';\nimport { LottieImage } from '../../browser/image';\nimport type { LottieAnimationCommon } from '../animation';\nimport type { LottieImageCommon } from '../image';\nimport { DotLottiePlugin } from '../plugin';\n\ninterface LottieImageCompare {\n  excludeFromExport: boolean;\n  hash: string | undefined;\n  image: LottieImageCommon;\n}\n\nexport class DuplicateImageDetectorCommon extends DotLottiePlugin {\n  public async generatePhash(_image: LottieImageCommon): Promise<string> {\n    throw new DotLottieError(\n      'generatePhash(image: LottieImageCommon): Promise<Hash> is not implemented in concrete class.',\n    );\n  }\n\n  public distanceTo(_imageHash: string, _targetImageHash: string): number {\n    throw new DotLottieError(\n      'distanceTo(_imageHash: string, _targetImageHash: string): Promise<number> is not implemented in concrete class.',\n    );\n  }\n\n  private async _createRecordOfDuplicates(): Promise<Record<string, LottieImageCommon[]>> {\n    this._requireDotLottie(this.dotlottie);\n\n    const images: LottieImageCompare[] = [];\n    const recordOfDuplicates: Record<string, LottieImageCommon[]> = {};\n\n    // push all of the animation image assets in to the images array\n    for (const animation of this.dotlottie.animations) {\n      for (const image of animation.imageAssets) {\n        images.push({\n          excludeFromExport: false,\n          image,\n          hash: await this.generatePhash(image),\n        });\n      }\n    }\n\n    // For every array of images\n    // Loop over the images of the array\n    for (const image of images) {\n      // Now that we have a single image of the image array, compare it to every other image in the arry\n      for (const compareImage of images) {\n        if (\n          image.image.lottieAssetId !== compareImage.image.lottieAssetId &&\n          !image.excludeFromExport &&\n          !compareImage.excludeFromExport &&\n          image.hash &&\n          compareImage.hash &&\n          this.distanceTo(image.hash, compareImage.hash) < 5\n          // image.hash.getHammingDistance(compareImage.hash) < 5\n        ) {\n          // Check if key is already in use\n          if (!recordOfDuplicates[image.image.fileName] && !recordOfDuplicates[compareImage.image.fileName]) {\n            compareImage.excludeFromExport = true;\n\n            recordOfDuplicates[image.image.fileName] = [compareImage.image];\n          } else if (recordOfDuplicates[compareImage.image.fileName]) {\n            // Check for duplicates, otherwise push the duplicate image\n            if (\n              !recordOfDuplicates[compareImage.image.fileName]?.find((item) => item.id === image.image.lottieAssetId)\n            ) {\n              image.excludeFromExport = true;\n              recordOfDuplicates[compareImage.image.fileName]?.push(image.image);\n            }\n          }\n        }\n      }\n    }\n\n    return recordOfDuplicates;\n  }\n\n  /**\n   * Apply the image path to all duplicate images.\n   *\n   * @param recordOfDuplicates - A record of duplicate images, the key being a fileName,\n   * the value being the identical LottieImageCommon object.\n   */\n  public adjustDuplicateImageAssetPath(\n    animation: LottieAnimationCommon,\n    recordOfDuplicates: Record<string, LottieImageCommon[]>,\n  ): void {\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        recordOfDuplicates[key]?.forEach((item) => {\n          // Check if this animation has the image before loop over data to save time ?\n\n          if (animation.data) {\n            const animationAssets = animation.data.assets as AnimationType['assets'];\n\n            if (animationAssets) {\n              animationAssets.forEach((asset) => {\n                if ('w' in asset && 'h' in asset) {\n                  // we've found an asset id thats equal to the id of a duplicate image\n                  // Or we found the fileName of a duplicate inside the asset, so we need to change it\n\n                  if (asset.p === item.fileName) {\n                    const fileName = key;\n\n                    asset.p = fileName;\n                  }\n                }\n              });\n            }\n          }\n        });\n      }\n    }\n  }\n\n  public override async onBuild(): Promise<void> {\n    this._requireDotLottie(this.dotlottie);\n\n    // Create a record of duplicates\n    const recordOfDuplicates: Record<string, LottieImageCommon[]> = await this._createRecordOfDuplicates();\n\n    // Check the record of duplicates and repath the duplicate images\n    this.dotlottie.animations.forEach((animation) => {\n      this.adjustDuplicateImageAssetPath(animation, recordOfDuplicates);\n    });\n\n    // Create an array of duplicates by looping over the recordOfDuplicates and using the key as the image to use\n    const clonedImages: Record<string, LottieImage> = {};\n    const images = this.dotlottie.getImages();\n\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        for (const image of images) {\n          if (image.fileName === key && image.data !== undefined) {\n            clonedImages[key] = new LottieImage({\n              data: image.data,\n              id: image.id,\n              lottieAssetId: image.lottieAssetId,\n              fileName: image.fileName,\n            });\n          }\n        }\n      }\n    }\n\n    if (Object.keys(clonedImages).length !== Object.keys(recordOfDuplicates).length)\n      throw new DotLottieError('The number of cloned images does not match the number of duplicate keys.');\n\n    // For each image of recordOfDuplicates, remove itself from all the parent animations and push the clone\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        recordOfDuplicates[key]?.forEach((image) => {\n          if (image.parentAnimations.length) {\n            for (const parentAnimation of image.parentAnimations) {\n              parentAnimation.imageAssets.splice(parentAnimation.imageAssets.indexOf(image), 1);\n\n              const clonedImage = clonedImages[key];\n\n              if (clonedImage !== undefined) {\n                parentAnimation.imageAssets.push(clonedImage);\n\n                clonedImage.parentAnimations.push(parentAnimation);\n              }\n            }\n          }\n        });\n      }\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { Hash, DifferenceHashBuilder } from 'browser-image-hash';\n\nimport type { LottieImageCommon } from '../../common';\nimport { DuplicateImageDetectorCommon } from '../../common/plugins/duplicate-image-detector';\n\nexport class DuplicateImageDetector extends DuplicateImageDetectorCommon {\n  public override async generatePhash(image: LottieImageCommon): Promise<string> {\n    const builder = new DifferenceHashBuilder();\n    const targetURL = new URL(await image.toDataURL());\n\n    const destHash = await builder.build(targetURL);\n\n    return destHash.rawHash;\n  }\n\n  public override distanceTo(imageHash: string, targetImageHash: string): number {\n    const srcHash = new Hash(imageHash);\n    const targetHash = new Hash(targetImageHash);\n\n    return srcHash.getHammingDistance(targetHash);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\nimport type { Zippable } from 'fflate';\nimport { strToU8, zip, strFromU8, unzip } from 'fflate';\n\nimport type { ConversionOptions } from '../../types';\nimport {\n  base64ToUint8Array,\n  DotLottieError,\n  getDotLottieVersion,\n  getExtensionTypeFromBase64,\n  isAudioAsset,\n} from '../../utils';\nimport { DotLottieV1 } from '../../v1/browser';\nimport type { AnimationOptions, DotLottieOptions } from '../common';\nimport { DotLottieCommon } from '../common';\nimport type { Manifest } from '../common/schemas';\n\nimport { LottieAnimation } from './animation';\nimport { LottieAudio } from './audio';\nimport { LottieImage } from './image';\nimport { DuplicateImageDetector } from './plugins/duplicate-image-detector';\n\nexport async function toDotLottieV2(arrayBuffer: ArrayBuffer): Promise<DotLottie> {\n  const version = await getDotLottieVersion(new Uint8Array(arrayBuffer));\n\n  if (version !== '2') {\n    const dotLottieV2 = new DotLottie();\n    const dotLottieV1 = await new DotLottieV1().fromArrayBuffer(arrayBuffer);\n\n    const animationIds = dotLottieV1.animations.map((animation) => animation.id);\n\n    for (const animationId of animationIds) {\n      const animation = await dotLottieV1.getAnimation(animationId, { inlineAssets: true });\n\n      if (animation && animation.data) {\n        dotLottieV2.addAnimation({\n          data: animation.data,\n          id: animationId,\n        });\n      }\n    }\n\n    await dotLottieV2.build();\n\n    return dotLottieV2;\n  }\n\n  return new DotLottie().fromArrayBuffer(arrayBuffer);\n}\n\nexport class DotLottie extends DotLottieCommon {\n  public constructor(options?: DotLottieOptions) {\n    super(options);\n\n    if (this.enableDuplicateImageOptimization) {\n      const plugin = new DuplicateImageDetector();\n\n      plugin.install(this);\n\n      this._plugins.push(plugin);\n    }\n  }\n\n  public override addAnimation(animationOptions: AnimationOptions): DotLottie {\n    const animation = new LottieAnimation(animationOptions);\n\n    if (this._animationsMap.get(animationOptions.id)) {\n      throw new DotLottieError('Duplicate animation id detected, aborting.');\n    }\n\n    this._animationsMap.set(animation.id, animation);\n\n    return this;\n  }\n\n  public override async toBase64(options?: ConversionOptions): Promise<string> {\n    const data = await this.toArrayBuffer(options);\n\n    const uint8Array = new Uint8Array(data);\n    const binaryString = uint8Array.reduce((acc, val) => acc + String.fromCharCode(val), '');\n\n    return window.btoa(binaryString);\n  }\n\n  public override async download(fileName: string, options?: ConversionOptions): Promise<void> {\n    const blob = await this.toBlob(options);\n\n    const dataURL = URL.createObjectURL(blob);\n\n    const link = document.createElement('a');\n\n    link.href = dataURL;\n\n    link.download = fileName;\n\n    link.style.display = 'none';\n\n    document.body.append(link);\n\n    link.click();\n\n    setTimeout(() => {\n      URL.revokeObjectURL(dataURL);\n      link.remove();\n    }, 1000);\n  }\n\n  public override create(options?: DotLottieOptions): DotLottieCommon {\n    return new DotLottie(options);\n  }\n\n  public override async toArrayBuffer(options?: ConversionOptions): Promise<ArrayBuffer> {\n    const manifest = this._buildManifest();\n\n    const dotlottie: Zippable = {\n      'manifest.json': [strToU8(JSON.stringify(manifest)), {}],\n    };\n\n    for (const animation of this.animations) {\n      const json = await animation.toJSON();\n\n      dotlottie[`a/${animation.id}.json`] = [strToU8(JSON.stringify(json)), animation.zipOptions];\n\n      const imageAssets = animation.imageAssets;\n      const audioAssets = animation.audioAssets;\n\n      for (const asset of imageAssets) {\n        // Assure we have a base64 encoded version of the image\n        const dataAsString = await asset.toDataURL();\n\n        dotlottie[`i/${asset.fileName}`] = [base64ToUint8Array(dataAsString), asset.zipOptions];\n      }\n\n      for (const asset of audioAssets) {\n        // Assure we have a base64 encoded version of the audio\n        const dataAsString = await asset.toDataURL();\n\n        dotlottie[`u/${asset.fileName}`] = [base64ToUint8Array(dataAsString), asset.zipOptions];\n      }\n    }\n\n    for (const theme of this.themes) {\n      const themeData = await theme.toString();\n\n      dotlottie[`t/${theme.id}.json`] = [strToU8(themeData), theme.zipOptions];\n    }\n\n    for (const state of this.stateMachines) {\n      const stateData = state.toString();\n\n      dotlottie[`s/${state.id}.json`] = [strToU8(stateData), state.zipOptions];\n    }\n\n    const dotlottieArrayBuffer = await new Promise<ArrayBuffer>((resolve, reject) => {\n      zip(dotlottie, options?.zipOptions || {}, (err, data) => {\n        if (err) {\n          reject(err);\n\n          return;\n        }\n\n        resolve(data.buffer);\n      });\n    });\n\n    return dotlottieArrayBuffer;\n  }\n\n  /**\n   * Creates a DotLottie instance from an array buffer\n   * @param arrayBuffer - array buffer of the dotlottie file\n   * @returns DotLottie instance\n   * @throws Error\n   */\n  public override async fromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<DotLottie> {\n    const dotLottieVersion = await getDotLottieVersion(new Uint8Array(arrayBuffer));\n\n    if (dotLottieVersion !== '2') {\n      return toDotLottieV2(arrayBuffer);\n    }\n\n    const dotlottie = new DotLottie();\n\n    try {\n      const contentObj = await new Promise<Zippable>((resolve, reject) => {\n        unzip(new Uint8Array(arrayBuffer), (err, data) => {\n          if (err) {\n            reject(err);\n          }\n\n          resolve(data);\n        });\n      });\n\n      const tmpImages = [];\n      const tmpAudio = [];\n\n      if (contentObj['manifest.json'] instanceof Uint8Array) {\n        // valid buffer\n        try {\n          // Parse the manifest first so that we can pick up animation settings\n          const manifest = JSON.parse(strFromU8(contentObj['manifest.json'], false)) as Manifest;\n\n          for (const key of Object.keys(contentObj)) {\n            // true is passed to use binary string, otherwise btoa fails\n            const decodedStr = strFromU8(contentObj[key] as Uint8Array, true);\n\n            if (key.startsWith('a/') && key.endsWith('.json')) {\n              // extract animationId from key as the key = `a/${animationId}.json`\n              const animationId = /a\\/(.+)\\.json/u.exec(key)?.[1];\n\n              if (!animationId) {\n                throw new DotLottieError('Invalid animation id');\n              }\n\n              const animation = JSON.parse(decodedStr);\n\n              const animationSettings = manifest.animations.find((anim) => anim.id === animationId);\n\n              if (animationSettings === undefined) {\n                throw new DotLottieError('Animation not found inside manifest');\n              }\n\n              dotlottie.addAnimation({\n                data: animation,\n                ...animationSettings,\n              });\n            } else if (key.startsWith('i/')) {\n              // extract imageId from key as the key = `i/${imageId}.${ext}`\n              const imageId = /i\\/(.+)\\./u.exec(key)?.[1];\n\n              if (!imageId) {\n                throw new DotLottieError('Invalid image id');\n              }\n\n              let decodedImg = btoa(decodedStr);\n\n              const ext = await getExtensionTypeFromBase64(decodedImg);\n\n              // Push the images in to a temporary array\n              decodedImg = `data:image/${ext};base64,${decodedImg}`;\n              tmpImages.push(\n                new LottieImage({\n                  id: imageId,\n                  lottieAssetId: imageId,\n                  data: decodedImg,\n                  fileName: key.split('/')[1] || '',\n                }),\n              );\n            } else if (key.startsWith('u/')) {\n              // extract audioId from key as the key = `u/${audioId}.${ext}`\n              const audioId = /u\\/(.+)\\./u.exec(key)?.[1];\n\n              if (!audioId) {\n                throw new DotLottieError('Invalid image id');\n              }\n\n              let decodedAudio = btoa(decodedStr);\n\n              const ext = await getExtensionTypeFromBase64(decodedAudio);\n\n              // Push the audio in to a temporary array\n              decodedAudio = `data:audio/${ext};base64,${decodedAudio}`;\n              tmpAudio.push(\n                new LottieAudio({\n                  id: audioId,\n                  data: decodedAudio,\n                  fileName: key.split('/')[1] || '',\n                }),\n              );\n            } else if (key.startsWith('t/') && key.endsWith('.json')) {\n              // extract themeId from key as the key = `t/${themeId}.json`\n              const themeId = /t\\/(.+)\\.json/u.exec(key)?.[1];\n\n              if (!themeId) {\n                throw new DotLottieError('Invalid theme id');\n              }\n\n              manifest.themes?.forEach((theme) => {\n                if (theme.id === themeId) {\n                  dotlottie.addTheme({\n                    id: theme.id,\n                    name: theme.name,\n                    data: JSON.parse(decodedStr),\n                  });\n                }\n              });\n            } else if (key.startsWith('s/') && key.endsWith('.json')) {\n              // extract stateId from key as the key = `s/${stateId}.json`\n              const stateId = /s\\/(.+)\\.json/u.exec(key)?.[1];\n\n              if (!stateId) {\n                throw new DotLottieError('Invalid theme id');\n              }\n\n              manifest.stateMachines?.forEach((stateMachine) => {\n                if (stateMachine.id === stateId) {\n                  dotlottie.addStateMachine({\n                    id: stateMachine.id,\n                    name: stateMachine.name,\n                    data: JSON.parse(decodedStr),\n                  });\n                }\n              });\n            }\n          }\n\n          // Go through the images and find to which animation they belong\n          for (const image of tmpImages) {\n            for (const parentAnimation of dotlottie.animations) {\n              if (parentAnimation.data) {\n                const animationAssets = parentAnimation.data.assets as AnimationType['assets'];\n\n                if (animationAssets) {\n                  for (const asset of animationAssets) {\n                    if ('w' in asset && 'h' in asset) {\n                      if (asset.p === image.fileName) {\n                        image.parentAnimations.push(parentAnimation);\n                        parentAnimation.imageAssets.push(image);\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n\n          // Go through the audio and find to which animation they belong\n          for (const audio of tmpAudio) {\n            for (const parentAnimation of dotlottie.animations) {\n              if (parentAnimation.data) {\n                const animationAssets = parentAnimation.data.assets as AnimationType['assets'];\n\n                if (animationAssets) {\n                  for (const asset of animationAssets) {\n                    if (isAudioAsset(asset)) {\n                      if (asset.p.includes(audio.id)) {\n                        audio.parentAnimations.push(parentAnimation);\n                        parentAnimation.audioAssets.push(audio);\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        } catch (err) {\n          if (err instanceof Error) {\n            throw new DotLottieError(`Invalid manifest inside buffer! ${err.message}`);\n          }\n        }\n      } else {\n        // throw error as it's invalid buffer\n        throw new DotLottieError('Invalid buffer');\n      }\n    } catch (err) {\n      if (err instanceof Error) {\n        throw new DotLottieError(err.message);\n      }\n    }\n\n    return dotlottie;\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ThemeOptions } from '../common';\nimport { LottieThemeCommon } from '../common';\n\nexport class LottieTheme extends LottieThemeCommon {\n  public constructor(options: ThemeOptions) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { DotLottieStateMachineCommon, type DotLottieStateMachineCommonOptions } from '../common';\n\nexport class LottieStateMachine extends DotLottieStateMachineCommon {\n  public constructor(options: DotLottieStateMachineCommonOptions) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { PACKAGE_NAME } from '../../constants';\nimport type { ConversionOptions, GetAnimationOptions } from '../../types';\nimport { DotLottieError, isAudioAsset, isImageAsset, isValidURL } from '../../utils';\n\nimport type { AnimationOptionsV1, LottieAnimationCommonV1 } from './animation';\nimport type { LottieAudioCommonV1 } from './audio';\nimport type { LottieImageCommonV1 } from './image';\nimport type { DotLottieV1Plugin } from './plugin';\nimport type { ManifestV1 } from './schemas/manifest';\n\nexport interface DotLottieV1Options {\n  author?: string;\n  description?: string;\n  enableDuplicateImageOptimization?: boolean;\n  generator?: string;\n  keywords?: string;\n  revision?: number;\n}\n\nexport class DotLottieCommonV1 {\n  protected readonly _animationsMap: Map<string, LottieAnimationCommonV1> = new Map();\n\n  protected readonly _plugins: DotLottieV1Plugin[] = [];\n\n  protected _author: string = PACKAGE_NAME;\n\n  protected _description: string | undefined;\n\n  protected _generator: string = PACKAGE_NAME;\n\n  protected _keywords: string | undefined;\n\n  protected _version: string = '1';\n\n  protected _revision: number | undefined;\n\n  // Custom data for the DotLottieV1\n  protected _customData: Record<string, unknown> | undefined;\n\n  public enableDuplicateImageOptimization?: boolean;\n\n  public constructor(options?: DotLottieV1Options) {\n    if (typeof options?.author === 'string') {\n      this._author = options.author;\n    }\n\n    if (typeof options?.description === 'string') {\n      this._description = options.description;\n    }\n\n    if (typeof options?.generator === 'string') {\n      this._generator = options.generator;\n    }\n\n    if (typeof options?.keywords === 'string') {\n      this._keywords = options.keywords;\n    }\n\n    if (typeof options?.revision === 'number') {\n      this._revision = options.revision;\n    }\n\n    this.enableDuplicateImageOptimization = options?.enableDuplicateImageOptimization ?? false;\n  }\n\n  public async toBase64(_options: ConversionOptions | undefined = undefined): Promise<string> {\n    throw new DotLottieError('toBase64() method not implemented in concrete class!');\n  }\n\n  public create(_options?: DotLottieV1Options): DotLottieCommonV1 {\n    throw new DotLottieError('create() method not implemented in concrete class!');\n  }\n\n  public async download(_fileName: string, _options: ConversionOptions | undefined = undefined): Promise<void> {\n    throw new DotLottieError('download(fileName:string) method not implemented in concrete class!');\n  }\n\n  public addPlugins(..._plugins: DotLottieV1Plugin[]): DotLottieCommonV1 {\n    throw new DotLottieError('addPlugins(...plugins: DotLottieV1Plugin[]) not implemented in concrete class!');\n  }\n\n  public addAnimation(_animationOptions: AnimationOptionsV1): DotLottieCommonV1 {\n    throw new DotLottieError('addAnimation(animationOptions: AnimationOptions) not implemented in concrete class!');\n  }\n\n  public async fromArrayBuffer(_arrayBuffer: ArrayBuffer): Promise<DotLottieCommonV1> {\n    throw new DotLottieError(\n      'fromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<DotLottieCommonV1> not implemented in concrete class!',\n    );\n  }\n\n  public async toArrayBuffer(_options: ConversionOptions | undefined = undefined): Promise<ArrayBuffer> {\n    throw new DotLottieError('toArrayBuffer(): Promise<ArrayBuffer> is not implemented in concrete class!');\n  }\n\n  public get plugins(): DotLottieV1Plugin[] {\n    return this._plugins;\n  }\n\n  public get version(): string {\n    return this._version;\n  }\n\n  public get revision(): number | undefined {\n    return this._revision;\n  }\n\n  public get author(): string {\n    return this._author;\n  }\n\n  public get description(): string | undefined {\n    return this._description;\n  }\n\n  public get keywords(): string | undefined {\n    return this._keywords;\n  }\n\n  public get generator(): string {\n    return this._generator;\n  }\n\n  public get animations(): LottieAnimationCommonV1[] {\n    return Array.from(this._animationsMap.values());\n  }\n\n  public get manifest(): ManifestV1 {\n    return this._buildManifest();\n  }\n\n  public get custom(): Record<string, unknown> | undefined {\n    return this._customData;\n  }\n\n  public setCustomData(customData: Record<string, unknown> | undefined): DotLottieCommonV1 {\n    this._customData = customData ?? {};\n\n    return this;\n  }\n\n  public setAuthor(author: string): DotLottieCommonV1 {\n    this._author = author;\n\n    return this;\n  }\n\n  public setDescription(description: string | undefined): DotLottieCommonV1 {\n    this._description = typeof description === 'string' ? description : '';\n\n    return this;\n  }\n\n  public setKeywords(keywords: string | undefined): DotLottieCommonV1 {\n    this._keywords = typeof keywords === 'string' ? keywords : 'DotLottieV1';\n\n    return this;\n  }\n\n  public setRevision(revision: number): DotLottieCommonV1 {\n    this._revision = revision;\n\n    return this;\n  }\n\n  /**\n   * Renames the underlying LottieImageV1, as well as updating the image asset path inside the animation data.\n   * @param newName - desired id and fileName,\n   * @param imageId - The id of the LottieImageV1 to rename\n   */\n  private async _renameImage(\n    animation: LottieAnimationCommonV1,\n    newLottieAssetId: string,\n    lottieAssetId: string,\n  ): Promise<void> {\n    for (const imageAsset of animation.imageAssets) {\n      if (imageAsset.lottieAssetId === lottieAssetId) {\n        // Rename the LottieImageV1\n        const oldPath = imageAsset.fileName;\n\n        await imageAsset.renameImage(newLottieAssetId);\n\n        if (!animation.data) throw new DotLottieError('No animation data available.');\n\n        const animationAssets = animation.data.assets as AnimationType['assets'];\n\n        if (!animationAssets) throw new DotLottieError('No image assets to rename.');\n\n        // Find the image asset inside the animation data and rename its path\n        for (const asset of animationAssets) {\n          if ('w' in asset && 'h' in asset) {\n            if (asset.p === oldPath) {\n              asset.p = imageAsset.fileName;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Generates a map of duplicate image ids and their count.\n   * @returns Map of duplicate image ids and their count.\n   */\n  private _generateMapOfOccurencesFromImageIds(): Map<string, number> {\n    const dupeMap = new Map<string, number>();\n\n    this.animations.forEach((animation) => {\n      animation.imageAssets.forEach((imageAsset) => {\n        if (dupeMap.has(imageAsset.lottieAssetId)) {\n          const count = dupeMap.get(imageAsset.lottieAssetId) ?? 0;\n\n          dupeMap.set(imageAsset.lottieAssetId, count + 1);\n        } else {\n          dupeMap.set(imageAsset.lottieAssetId, 1);\n        }\n      });\n    });\n\n    return dupeMap;\n  }\n\n  /**\n   * Renames the image assets in all animations to avoid conflicts.\n   *\n   * Steps:\n   *  - Generate how many times across all animations the same image id has been used.\n   *  - Loop through every animation in reverse order\n   *  - Every time an animation uses an image asset that is also used elsewhere, append the count to the image's asset id and then decrement.\n   *\n   * Result of renaming for every animation:\n   *\n   * - Inside the Lottie's data and it's Asset object:\n   *  - The Asset id stays the same, meaning that every reference to the asset is still valid (refId)\n   *  - The path is changed to the new asset id with the format \\{assetId\\}_\\{count\\}\n   *\n   * - On the dotLottie file system scope:\n   *  - The image file name is changed to the new asset id \\{assetId\\}_\\{count\\}.\\{ext\\}\n   */\n  private async _renameImageAssets(): Promise<void> {\n    const occurenceMap = this._generateMapOfOccurencesFromImageIds();\n\n    // Loop over every animation\n    for (let i = this.animations.length - 1; i >= 0; i -= 1) {\n      const animation = this.animations.at(i);\n\n      if (animation) {\n        // Loop over every image asset of the animation\n        for (let j = animation.imageAssets.length - 1; j >= 0; j -= 1) {\n          const image = animation.imageAssets.at(j);\n\n          if (image) {\n            // Get how many times the same image id has been used\n            let count = occurenceMap.get(image.lottieAssetId) ?? 0;\n\n            if (count > 0) {\n              count -= 1;\n            }\n\n            // Decrement the count\n            occurenceMap.set(image.lottieAssetId, count);\n\n            if (count > 0) {\n              // Rename the with n-1 count\n              await this._renameImage(animation, `${image.lottieAssetId}_${count}`, image.lottieAssetId);\n            }\n          }\n        }\n      }\n    }\n  }\n\n  /**\n   * Renames the underlying LottieAudioV1, as well as updating the audio asset path inside the animation data.\n   * @param newName - desired id and fileName,\n   * @param audioId - The id of the LottieAudioV1 to rename\n   */\n  private async _renameAudio(animation: LottieAnimationCommonV1, newName: string, audioId: string): Promise<void> {\n    for (const audioAsset of animation.audioAssets) {\n      if (audioAsset.id === audioId) {\n        // Rename the LottieImageV1\n        await audioAsset.renameAudio(newName);\n\n        if (!animation.data) throw new DotLottieError('No animation data available.');\n\n        const animationAssets = animation.data.assets as AnimationType['assets'];\n\n        if (!animationAssets) throw new DotLottieError('No audio assets to rename.');\n\n        // Find the audio asset inside the animation data and rename its path\n        for (const asset of animationAssets) {\n          if (isAudioAsset(asset)) {\n            if (asset.id === audioId) {\n              asset.p = audioAsset.fileName;\n            }\n          }\n        }\n      }\n    }\n  }\n\n  private async _renameAudioAssets(): Promise<void> {\n    const audio: Map<string, LottieAudioCommonV1[]> = new Map();\n\n    this.animations.forEach((animation) => {\n      audio.set(animation.id, animation.audioAssets);\n    });\n\n    let size = 0;\n\n    audio.forEach((value) => {\n      size += value.length;\n    });\n\n    for (let i = this.animations.length - 1; i >= 0; i -= 1) {\n      const animation = this.animations.at(i);\n\n      if (animation) {\n        for (let j = animation.audioAssets.length - 1; j >= 0; j -= 1) {\n          const audioAsset = animation.audioAssets.at(j);\n\n          if (audioAsset) {\n            await this._renameAudio(animation, `audio_${size}`, audioAsset.id);\n            size -= 1;\n          }\n        }\n      }\n    }\n  }\n\n  protected _addLottieAnimation(animation: LottieAnimationCommonV1): DotLottieCommonV1 {\n    if (this._animationsMap.get(animation.id)) {\n      throw new DotLottieError('Duplicate animation id detected, aborting.');\n    }\n\n    this._animationsMap.set(animation.id, animation);\n\n    return this;\n  }\n\n  /**\n   * Inlines all assets of the passed animation\n   * @param animation - Animation whose asset are to be inlined\n   * @returns LottieAnimationCommonV1 with inlined assets\n   */\n  private async _findAssetsAndInline(animation: LottieAnimationCommonV1): Promise<LottieAnimationCommonV1> {\n    const animationAssets = animation.data?.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError(\"Failed to inline assets, the animation's assets are undefined.\");\n\n    const images = this.getImages();\n    const audios = this.getAudio();\n\n    for (const asset of animationAssets) {\n      if (isImageAsset(asset)) {\n        for (const image of images) {\n          if (image.fileName === asset.p) {\n            // encoded is true\n            asset.e = 1;\n            asset.u = '';\n            asset.p = await image.toDataURL();\n          }\n        }\n      } else if (isAudioAsset(asset)) {\n        for (const audio of audios) {\n          if (audio.fileName === asset.p) {\n            // encoded is true\n            asset.e = 1;\n            asset.u = '';\n            asset.p = await audio.toDataURL();\n          }\n        }\n      }\n    }\n\n    return animation;\n  }\n\n  /**\n   * Returns the desired animation\n   * @param animationId - desired animation id\n   * @param inlineAssets - if true will inline the assets inside the data of the LottieAnimationV1\n   * @returns\n   */\n  public async getAnimation(\n    animationId: string,\n    options?: GetAnimationOptions,\n  ): Promise<LottieAnimationCommonV1 | undefined> {\n    if (!options?.inlineAssets) return this._animationsMap.get(animationId);\n\n    let dataWithInlinedImages = this._animationsMap.get(animationId);\n\n    if (!dataWithInlinedImages) throw new DotLottieError('Failed to find animation.');\n\n    dataWithInlinedImages = await this._findAssetsAndInline(dataWithInlinedImages);\n\n    return dataWithInlinedImages;\n  }\n\n  public getAnimations(): Array<[string, LottieAnimationCommonV1]> | undefined {\n    return Array.from(this._animationsMap);\n  }\n\n  public removeAnimation(animationId: string): DotLottieCommonV1 {\n    const targetAnimation = this._animationsMap.get(animationId);\n\n    if (targetAnimation) {\n      this._animationsMap.delete(targetAnimation.id);\n    }\n\n    return this;\n  }\n\n  public getImages(): LottieImageCommonV1[] {\n    const images: LottieImageCommonV1[] = [];\n\n    this.animations.map((animation) => {\n      return images.push(...animation.imageAssets);\n    });\n\n    return images;\n  }\n\n  public getAudio(): LottieAudioCommonV1[] {\n    const audio: LottieAudioCommonV1[] = [];\n\n    this.animations.map((animation) => {\n      return audio.push(...animation.audioAssets);\n    });\n\n    return audio;\n  }\n\n  protected _buildManifest(): ManifestV1 {\n    const animationsList = Array.from(this._animationsMap.values()).map((animation) => ({\n      id: animation.id,\n      ...(animation.autoplay !== undefined && { autoplay: animation.autoplay }),\n      ...(animation.loop !== undefined && { loop: animation.loop }),\n      ...(animation.speed !== undefined && { speed: animation.speed }),\n      ...(animation.direction !== undefined && { direction: animation.direction }),\n      ...(animation.playMode !== undefined && { playMode: animation.playMode }),\n      ...(animation.hover !== undefined && { hover: animation.hover }),\n      ...(animation.intermission !== undefined && { intermission: animation.intermission }),\n      ...(animation.themeColor !== undefined && { themeColor: animation.themeColor }),\n    }));\n\n    const manifest: ManifestV1 = {\n      version: this.version,\n      generator: this.generator,\n      author: this.author,\n      ...(this.keywords !== undefined && { keywords: this.keywords }),\n      ...(this.revision !== undefined && { revision: this.revision }),\n      animations: animationsList,\n      ...(this.description && this.description.trim() !== '' ? { description: this.description } : {}),\n      ...(this._customData && Object.keys(this._customData).length !== 0 ? { custom: this._customData } : {}),\n    };\n\n    return manifest;\n  }\n\n  /**\n   * Constructs the manifest and calls toJSON on the animations\n   * so the data is fetched for every animation.\n   *\n   * @returns DotLottieV1 context\n   */\n  public async build(): Promise<DotLottieCommonV1> {\n    this._buildManifest();\n\n    for (const animation of this.animations) {\n      await animation.toJSON();\n    }\n\n    if (this.animations.length > 1) {\n      // Rename assets incrementally if there are multiple animations\n      await this._renameImageAssets();\n      await this._renameAudioAssets();\n    }\n\n    const parallelPlugins = [];\n    const sequentialPlugins = [];\n\n    for (const plugin of this.plugins) {\n      if (plugin.parallel) {\n        parallelPlugins.push(plugin);\n      } else {\n        sequentialPlugins.push(plugin);\n      }\n    }\n\n    // Run parallel plugins\n    await Promise.all(parallelPlugins.map(async (plugin) => plugin.onBuild()));\n\n    // Run sequential plugins\n    for (const plugin of sequentialPlugins) {\n      await plugin.onBuild();\n    }\n\n    return this;\n  }\n\n  public async toBlob(options: ConversionOptions | undefined = undefined): Promise<Blob> {\n    const arrayBuffer = await this.toArrayBuffer(options);\n\n    return new Blob([arrayBuffer], { type: 'application/zip' });\n  }\n\n  /**\n   * Creates a DotLottieV1 instance from a url to a DotLottieV1 file\n   * @param url - url to the DotLottieV1 file\n   * @returns DotLottieV1 instance\n   */\n  public async fromURL(url: string): Promise<DotLottieCommonV1> {\n    if (!isValidURL(url)) throw new DotLottieError('Invalid URL');\n\n    try {\n      const response = await fetch(url);\n\n      if (!response.ok) {\n        throw new DotLottieError(response.statusText);\n      }\n\n      const arrayBuffer = await response.arrayBuffer();\n\n      return this.fromArrayBuffer(arrayBuffer);\n    } catch (err) {\n      if (err instanceof Error) {\n        throw new DotLottieError(err.message);\n      }\n    }\n\n    throw new DotLottieError('Unknown error');\n  }\n\n  public merge(...DotLottieV1s: DotLottieCommonV1[]): DotLottieCommonV1 {\n    const mergedDotLottieV1 = this.create();\n\n    for (const dotLottieV1 of DotLottieV1s) {\n      dotLottieV1.animations.forEach((animation) => {\n        if (animation.data) {\n          mergedDotLottieV1.addAnimation({\n            id: animation.id,\n            data: animation.data,\n          });\n        } else if (animation.url) {\n          mergedDotLottieV1.addAnimation({\n            id: animation.id,\n            url: animation.url,\n          });\n        }\n      });\n    }\n\n    return mergedDotLottieV1;\n  }\n\n  protected _requireValidAuthor(author: string | undefined): asserts author is string {\n    if (typeof author !== 'string') throw new DotLottieError('Invalid author');\n  }\n\n  protected _requireValidDescription(description: string | undefined): asserts description is string {\n    if (typeof description !== 'string') throw new DotLottieError('Invalid description');\n  }\n\n  protected _requireValidGenerator(generator: string | undefined): asserts generator is string {\n    if (typeof generator !== 'string') throw new DotLottieError('Invalid generator');\n  }\n\n  protected _requireValidKeywords(keywords: string | undefined): asserts keywords is string {\n    if (typeof keywords !== 'string') throw new DotLottieError('Invalid keywords');\n  }\n\n  protected _requireValidVersion(version: string | undefined): asserts version is string {\n    if (typeof version !== 'string') throw new DotLottieError('Invalid version');\n  }\n\n  protected _requireValidCustomData(\n    customData: Record<string, unknown> | undefined,\n  ): asserts customData is Record<string, unknown> {\n    if (!customData) throw new DotLottieError('Invalid customData');\n  }\n}\n","/**\n * Copyright 2024 Design Barn Inc.\n */\n\nimport {\n  object,\n  type Output,\n  string,\n  array,\n  boolean,\n  number,\n  union,\n  optional,\n  record,\n  any,\n  nativeEnum,\n  literal,\n} from 'valibot';\n\nexport enum PlayMode {\n  Bounce = 'bounce',\n  Normal = 'normal',\n}\n\nexport const PlayModeSchema = nativeEnum(PlayMode);\n\nexport const ManifestAnimationSchemaV1 = object({\n  id: string(),\n\n  autoplay: optional(boolean()),\n  loop: optional(union([boolean(), number()])),\n  speed: optional(number()),\n  direction: optional(union([literal(1), literal(-1)])),\n  playMode: optional(PlayModeSchema),\n  hover: optional(boolean()),\n  intermission: optional(number()),\n  themeColor: optional(string()),\n});\nexport type ManifestAnimationV1 = Output<typeof ManifestAnimationSchemaV1>;\n\nexport const ManifestSchemaV1 = object({\n  version: optional(string()),\n  generator: optional(string()),\n\n  activeAnimationId: optional(string()),\n  animations: array(ManifestAnimationSchemaV1),\n  author: optional(string()),\n  custom: optional(record(string(), any())),\n  description: optional(string()),\n  keywords: optional(string()),\n  revision: optional(number()),\n});\n\nexport type ManifestV1 = Output<typeof ManifestSchemaV1>;\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\n\nimport type { AnimationData, ExportOptions } from '../../types';\nimport { DotLottieError, isAudioAsset } from '../../utils';\n\nimport type { LottieAudioCommonV1 } from './audio';\nimport type { LottieImageCommonV1 } from './image';\nimport { PlayMode } from './schemas/manifest';\nimport type { ManifestAnimationV1 } from './schemas/manifest';\n\ninterface AnimationOptionsBase extends ManifestAnimationV1 {\n  defaultActiveAnimation?: boolean;\n  zipOptions?: ZipOptions;\n}\n\ninterface AnimationOptionsWithData extends AnimationOptionsBase {\n  data: AnimationData;\n  url?: never;\n}\n\ninterface AnimationOptionsWithUrl extends AnimationOptionsBase {\n  data?: never;\n  url: string;\n}\n\nexport type AnimationOptionsV1 = AnimationOptionsWithData | AnimationOptionsWithUrl;\n\nexport class LottieAnimationCommonV1 {\n  protected _data?: AnimationData;\n\n  protected _id: string = '';\n\n  protected _url?: string;\n\n  private _direction: ManifestAnimationV1['direction'];\n\n  private _speed: number | undefined;\n\n  private _playMode: PlayMode | undefined;\n\n  private _loop: boolean | number | undefined;\n\n  private _autoplay: boolean | undefined;\n\n  private _hover: boolean | undefined;\n\n  private _intermission: number | undefined;\n\n  private _themeColor: string | undefined;\n\n  private _zipOptions: ZipOptions;\n\n  // Will be translated to 'activeAnimationId' inside of the manifest file\n  // This indicates if the player should play this animation by default rather than the first in the list.\n  protected _defaultActiveAnimation: boolean;\n\n  protected _imageAssets: LottieImageCommonV1[] = [];\n\n  protected _audioAssets: LottieAudioCommonV1[] = [];\n\n  public constructor(options: AnimationOptionsV1) {\n    this._requireValidOptions(options);\n\n    this._id = options.id;\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) this._data = options.data;\n    if (options.url) this._url = options.url;\n\n    this._defaultActiveAnimation = options.defaultActiveAnimation ?? false;\n\n    if (typeof options.direction === 'number') {\n      this.direction = options.direction;\n    }\n\n    if (typeof options.speed === 'number') {\n      this.speed = options.speed;\n    }\n\n    if (typeof options.playMode === 'string') {\n      this.playMode = options.playMode;\n    }\n\n    if (typeof options.loop === 'boolean' || typeof options.loop === 'number') {\n      this.loop = options.loop;\n    }\n\n    if (typeof options.autoplay === 'boolean') {\n      this.autoplay = options.autoplay;\n    }\n\n    if (typeof options.hover === 'boolean') {\n      this.hover = options.hover;\n    }\n\n    if (typeof options.intermission === 'number') {\n      this.intermission = options.intermission;\n    }\n\n    if (typeof options.themeColor === 'string') {\n      this.themeColor = options.themeColor;\n    }\n  }\n\n  public async toBase64(): Promise<string> {\n    throw new DotLottieError('lottie animation controls tobase64 not implemented!');\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get imageAssets(): LottieImageCommonV1[] {\n    return this._imageAssets;\n  }\n\n  public set imageAssets(imageAssets: LottieImageCommonV1[]) {\n    this._imageAssets = imageAssets;\n  }\n\n  public get audioAssets(): LottieAudioCommonV1[] {\n    return this._audioAssets;\n  }\n\n  public set audioAssets(audioAssets: LottieAudioCommonV1[]) {\n    this._audioAssets = audioAssets;\n  }\n\n  public get data(): AnimationData | undefined {\n    return this._data;\n  }\n\n  public set data(data: AnimationData | undefined) {\n    this._requireValidLottieData(data);\n\n    this._data = data;\n  }\n\n  public get url(): string | undefined {\n    return this._url;\n  }\n\n  public set url(url: string | undefined) {\n    this._requireValidUrl(url);\n\n    this._url = url;\n  }\n\n  public get themeColor(): string | undefined {\n    return this._themeColor;\n  }\n\n  public set themeColor(themeColor: string | undefined) {\n    if (themeColor) {\n      this._requireValidThemeColor(themeColor);\n    }\n\n    this._themeColor = themeColor;\n  }\n\n  public get direction(): ManifestAnimationV1['direction'] {\n    return this._direction;\n  }\n\n  public set direction(direction: ManifestAnimationV1['direction']) {\n    this._direction = direction;\n  }\n\n  public get speed(): number | undefined {\n    return this._speed;\n  }\n\n  public set speed(speed: number | undefined) {\n    if (typeof speed === 'number') {\n      this._requireValidSpeed(speed);\n    }\n\n    this._speed = speed;\n  }\n\n  public get playMode(): PlayMode | undefined {\n    return this._playMode;\n  }\n\n  public set playMode(playMode: PlayMode | undefined) {\n    if (typeof playMode === 'string') {\n      this._requireValidPlayMode(playMode);\n    }\n\n    this._playMode = playMode;\n  }\n\n  public get loop(): boolean | number | undefined {\n    return this._loop;\n  }\n\n  public set loop(loop: boolean | number | undefined) {\n    if (typeof loop === 'number' || typeof loop === 'boolean') {\n      this._requireValidLoop(loop);\n    }\n\n    this._loop = loop;\n  }\n\n  public get autoplay(): boolean | undefined {\n    return this._autoplay;\n  }\n\n  public set autoplay(autoplay: boolean | undefined) {\n    if (typeof autoplay === 'boolean') {\n      this._requireValidAutoplay(autoplay);\n    }\n\n    this._autoplay = autoplay;\n  }\n\n  public get defaultActiveAnimation(): boolean {\n    return this._defaultActiveAnimation;\n  }\n\n  public set defaultActiveAnimation(defaultActiveAnimation: boolean) {\n    this._defaultActiveAnimation = defaultActiveAnimation;\n  }\n\n  public get hover(): boolean | undefined {\n    return this._hover;\n  }\n\n  public set hover(hover: boolean | undefined) {\n    if (typeof hover === 'boolean') {\n      this._requireValidHover(hover);\n    }\n\n    this._hover = hover;\n  }\n\n  public get intermission(): number | undefined {\n    return this._intermission;\n  }\n\n  public set intermission(intermission: number | undefined) {\n    if (typeof intermission === 'number') {\n      this._requireValidIntermission(intermission);\n    }\n\n    this._intermission = intermission;\n  }\n\n  /**\n   * Return the animation data as an array buffer.\n   * @returns data - The animation data as an ArrayBuffer.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toArrayBuffer(options?: ExportOptions): Promise<ArrayBuffer> {\n    const dataJson = await this.toJSON(options);\n\n    return new TextEncoder().encode(JSON.stringify(dataJson)).buffer;\n  }\n\n  protected async _extractImageAssets(): Promise<boolean> {\n    throw new DotLottieError('_extractImageAssets(): Promise<boolean> method not implemented in concrete class');\n  }\n\n  protected async _extractAudioAssets(): Promise<boolean> {\n    throw new DotLottieError('_extractAudioAssets(): Promise<boolean> method not implemented in concrete class');\n  }\n\n  /**\n   * Return the animation data as a blob.\n   * @returns blob - The animation data as a Blob.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toBlob(options: ExportOptions = {}): Promise<Blob> {\n    const dataJson = await this.toJSON(options);\n\n    return new Blob([JSON.stringify(dataJson)], { type: 'application/json' });\n  }\n\n  /**\n   * Return the animation data as a JSON object.\n   * If the animation data is not already set, it will be fetched from the provided url.\n   * @returns data - The animation data.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public async toJSON(options?: ExportOptions): Promise<AnimationData> {\n    if (this._url && !this._data) {\n      this._data = await this._fromUrl(this._url);\n    }\n\n    this._requireValidLottieData(this._data);\n\n    if (this._data.assets?.length) {\n      // Even if the user wants to inline the assets, we still need to extract them\n      await this._extractImageAssets();\n      await this._extractAudioAssets();\n\n      if (options?.inlineAssets) {\n        const animationAssets = this.data?.assets as AnimationData['assets'];\n\n        if (!animationAssets)\n          throw new DotLottieError(\"Failed to inline assets, the animation's assets are undefined.\");\n\n        const images = this.imageAssets;\n        const audios = this.audioAssets;\n\n        for (const asset of animationAssets) {\n          if ('w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset) {\n            for (const image of images) {\n              // If we only compare paths, we can leave the asset.id alone\n              if (image.fileName === asset.p) {\n                // encoded is true\n                asset.e = 1;\n                asset.u = '';\n                asset.p = await image.toDataURL();\n              }\n            }\n          } else if (isAudioAsset(asset)) {\n            // Audio asset\n            for (const audio of audios) {\n              if (audio.fileName === asset.p) {\n                // encoded is true\n                asset.e = 1;\n                asset.u = '';\n                asset.p = await audio.toDataURL();\n              }\n            }\n          }\n        }\n      }\n    }\n\n    return this._data;\n  }\n\n  /**\n   * Fetch the animation data from the provided url.\n   * @param url - The url to fetch the animation data from.\n   * @returns animationData - The animation data.\n   * @throws Error - if the fetch request fails.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   */\n  private async _fromUrl(url: string): Promise<AnimationData> {\n    const response = await fetch(url);\n\n    const text = await response.text();\n\n    let json;\n\n    try {\n      json = JSON.parse(text);\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new DotLottieError(`${error.message}: Invalid json returned from url`);\n      }\n    }\n\n    this._requireValidLottieData(json as AnimationData);\n\n    return json;\n  }\n\n  /**\n   * Ensure that the provided url is a valid string.\n   * The url must be a non-empty string, otherwise an error will be thrown.\n   * @param url - The url to validate.\n   * @throws Error - if the url is not a valid string.\n   *\n   */\n  private _requireValidUrl(url: string | undefined): asserts url is string {\n    try {\n      // eslint-disable-next-line no-new\n      new URL(url || '');\n    } catch (_err) {\n      throw new DotLottieError('Invalid animation url');\n    }\n  }\n\n  /**\n   * Ensure that the provided data object is a valid Lottie animation data object.\n   * The data object must contain the following mandatory properties: v, ip, op, layers, fr, w, h.\n   * If the data object does not contain all mandatory properties, an error will be thrown.\n   * @param data - The data object to validate.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   */\n  private _requireValidLottieData(data: AnimationData | undefined): asserts data is AnimationData {\n    const mandatoryLottieProperties = ['v', 'ip', 'op', 'layers', 'fr', 'w', 'h'];\n\n    const hasAllMandatoryProperties = mandatoryLottieProperties.every((field) =>\n      Object.prototype.hasOwnProperty.call(data, field),\n    );\n\n    if (!hasAllMandatoryProperties) {\n      throw new DotLottieError('Received invalid Lottie data.');\n    }\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid animation id');\n  }\n\n  /**\n   * Ensure that the provided url is a valid string.\n   * The url must be a non-empty string, otherwise an error will be thrown.\n   * @param url - The url to validate.\n   * @throws Error - if the url is not a valid string.\n   *\n   */\n  private _requireValidDirection(direction: number): asserts direction is number {\n    if (direction !== -1 && direction !== 1) {\n      throw new DotLottieError('Direction can only be -1 (backwards) or 1 (forwards)');\n    }\n  }\n\n  /**\n   * Ensure that the provided intermission is a valid, positive number.\n   * @param intermission - The intermission to validate.\n   * @throws Error - if the intermission is not a valid number.\n   */\n  private _requireValidIntermission(intermission: number): asserts intermission is number {\n    if (intermission < 0 || !Number.isInteger(intermission)) {\n      throw new DotLottieError('intermission must be a positive number');\n    }\n  }\n\n  /**\n   * Ensure that the provided loop is a valid, positive number or boolean.\n   * @param loop - The loop to validate.\n   * @throws Error - if the loop is not a valid number or boolean.\n   */\n  private _requireValidLoop(loop: number | boolean): asserts loop is number | boolean {\n    if (typeof loop === 'number' && (!Number.isInteger(loop) || loop < 0)) {\n      throw new DotLottieError('loop must be a positive number or boolean');\n    }\n  }\n\n  /**\n   * Ensure that the provided options object is a valid AnimationOptions object.\n   * The options object must contain the following mandatory properties: id, data or url.\n   * If the options object does not contain all mandatory properties, an error will be thrown.\n   * @param options - The options object to validate.\n   * @throws Error - if the options object is not a valid AnimationOptions object.\n   * @throws Error - if the id is not a valid string.\n   * @throws Error - if the data object is not a valid Lottie animation data object.\n   * @throws Error - if the url is not a valid url string.\n   * @throws Error - if the data object is not set and the url is not provided.\n   */\n  private _requireValidOptions(options: AnimationOptionsV1): asserts options is AnimationOptionsV1 {\n    this._requireValidId(options.id);\n\n    if (!options.data && !options.url) {\n      throw new DotLottieError('No data or url provided.');\n    }\n\n    if (options.data) {\n      this._requireValidLottieData(options.data);\n    }\n\n    if (options.url) {\n      this._requireValidUrl(options.url);\n    }\n\n    if (options.direction) {\n      this._requireValidDirection(options.direction);\n    }\n\n    if (options.intermission) {\n      this._requireValidIntermission(options.intermission);\n    }\n\n    if (options.loop) {\n      this._requireValidLoop(options.loop);\n    }\n  }\n\n  private _requireValidSpeed(speed: number | undefined): asserts speed is number {\n    if (speed !== undefined && (typeof speed !== 'number' || speed < 0)) {\n      throw new DotLottieError('Speed must be a non-negative number');\n    }\n  }\n\n  private _requireValidPlayMode(playMode: PlayMode | undefined): asserts playMode is PlayMode {\n    const validPlayModes = Object.values(PlayMode);\n\n    if (playMode !== undefined && !validPlayModes.includes(playMode)) {\n      throw new DotLottieError(`playMode must be one of: ${validPlayModes.join(', ')}`);\n    }\n  }\n\n  private _requireValidAutoplay(autoplay: boolean | undefined): asserts autoplay is boolean {\n    if (autoplay !== undefined && typeof autoplay !== 'boolean') {\n      throw new DotLottieError('autoplay must be a boolean');\n    }\n  }\n\n  private _requireValidHover(hover: boolean | undefined): asserts hover is boolean {\n    if (hover !== undefined && typeof hover !== 'boolean') {\n      throw new DotLottieError('Hover must be a boolean');\n    }\n  }\n\n  private _requireValidThemeColor(themeColor: string | undefined): asserts themeColor is string {\n    if (themeColor !== undefined && typeof themeColor !== 'string') {\n      throw new DotLottieError('themeColor must be a string and start with #');\n    }\n\n    if (themeColor !== undefined && !themeColor.startsWith('#')) {\n      throw new DotLottieError('themeColor must be a string and start with #');\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\n\nimport type { ImageData } from '../../types';\nimport { dataUrlFromU8, DotLottieError, getExtensionTypeFromBase64 } from '../../utils';\n\nimport type { LottieAnimationCommonV1 } from './animation';\n\nexport interface ImageOptionsV1 {\n  data?: ImageData;\n  fileName: string;\n  id: string;\n  lottieAssetId: string;\n  parentAnimations?: LottieAnimationCommonV1[];\n  zipOptions?: ZipOptions;\n}\n\nexport class LottieImageCommonV1 {\n  protected _data?: ImageData;\n\n  /**\n   * Unique id for the LottieImageCommon object. This is never modified.\n   */\n  protected _id: string = '';\n\n  /**\n   * Asset id representing the image asset inside the Lottie animation. This can be modified.\n   */\n  protected _lottieAssetId: string = '';\n\n  protected _fileName: string = '';\n\n  protected _parentAnimations: LottieAnimationCommonV1[];\n\n  protected _zipOptions: ZipOptions;\n\n  public constructor(options: ImageOptionsV1) {\n    this._requireValidId(options.id);\n    this._requireValidLottieAssetId(options.lottieAssetId);\n    this._requireValidFileName(options.fileName);\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) {\n      this._data = options.data;\n    }\n\n    if (options.id) {\n      this._id = options.id;\n    }\n\n    if (options.lottieAssetId) {\n      this._lottieAssetId = options.lottieAssetId;\n    }\n\n    if (options.fileName) {\n      this._fileName = options.fileName;\n    }\n\n    this._parentAnimations = options.parentAnimations || [];\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid image id');\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidLottieAssetId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid Lottie Image Asset Id');\n  }\n\n  /**\n   * Ensure that the provided fileName is a valid string.\n   * The fileName must be a non-empty string, otherwise an error will be thrown.\n   * @param fileName - The fileName to validate.\n   * @throws Error - if the fileName is not a valid string.\n   */\n  private _requireValidFileName(fileName: string | undefined): asserts fileName is string {\n    if (!fileName) throw new DotLottieError('Invalid image fileName');\n  }\n\n  public get fileName(): string {\n    return this._fileName;\n  }\n\n  public set fileName(fileName: string) {\n    this._requireValidFileName(fileName);\n\n    this._fileName = fileName;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    this._requireValidId(id);\n\n    this._id = id;\n  }\n\n  public get lottieAssetId(): string {\n    return this._lottieAssetId;\n  }\n\n  public set lottieAssetId(id: string) {\n    this._requireValidLottieAssetId(id);\n    this._lottieAssetId = id;\n  }\n\n  public get data(): ImageData | undefined {\n    return this._data;\n  }\n\n  public set data(data: ImageData | undefined) {\n    if (!data) {\n      throw new DotLottieError('Invalid data');\n    }\n\n    this._data = data;\n  }\n\n  public get parentAnimations(): LottieAnimationCommonV1[] {\n    return this._parentAnimations;\n  }\n\n  public set parentAnimations(parentAnimations: LottieAnimationCommonV1[]) {\n    this._parentAnimations = parentAnimations;\n  }\n\n  public async toDataURL(): Promise<string> {\n    if (this._data && this._isDataURL(this._data)) return this.data as string;\n\n    const arrayBuffer = await this.toArrayBuffer();\n\n    return dataUrlFromU8(new Uint8Array(arrayBuffer));\n  }\n\n  /**\n   * Renames the lottieAssetId and fileName to newName.\n   * @param newName - A new lottieAssetId and filename for the image.\n   */\n  public async renameImage(newLottieAssetId: string): Promise<void> {\n    this._lottieAssetId = newLottieAssetId;\n\n    const data = await this.toDataURL();\n\n    const ext = await getExtensionTypeFromBase64(data);\n\n    if (!ext) {\n      throw new DotLottieError('File extension type could not be detected from asset file.');\n    }\n\n    this.fileName = `${newLottieAssetId}.${ext}`;\n  }\n\n  public async toArrayBuffer(): Promise<ArrayBuffer> {\n    const blob = await (await this.toBlob()).arrayBuffer();\n\n    return blob;\n  }\n\n  public async toBlob(): Promise<Blob> {\n    if (!this._data) {\n      throw new DotLottieError('Invalid image data.');\n    }\n\n    if (this._isDataURL(this._data)) {\n      const data = this._data as string;\n\n      const [header, base64] = data.split(',');\n\n      // If the data doesnt contain the encoding URL, return it\n      if ((!header || !base64) && data.length) {\n        return new Blob([data]);\n      }\n\n      if (!header || !base64) {\n        throw new DotLottieError('Invalid image data.');\n      }\n\n      // eslint-disable-next-line require-unicode-regexp\n      const type = header.replace('data:', '').replace(/;base64$/, '');\n\n      return new Blob([base64], { type });\n    }\n\n    if (this._isArrayBuffer(this._data)) {\n      return new Blob([this._data]);\n    }\n\n    if (this._isBlob(this._data)) {\n      return this._data as Blob;\n    }\n\n    throw new DotLottieError('Invalid image data.');\n  }\n\n  protected async _fromUrlToBlob(url: string): Promise<Blob> {\n    const response = await fetch(url);\n\n    return response.blob();\n  }\n\n  protected _isArrayBuffer(data: ImageData): boolean {\n    return data instanceof ArrayBuffer;\n  }\n\n  protected _isDataURL(data: ImageData): boolean {\n    return typeof data === 'string' && data.startsWith('data:');\n  }\n\n  protected _isBlob(data: ImageData): boolean {\n    return data instanceof Blob;\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ZipOptions } from 'fflate';\n\nimport type { AudioData } from '../../types';\nimport { dataUrlFromU8, DotLottieError, ErrorCodes, getExtensionTypeFromBase64 } from '../../utils';\n\nimport type { LottieAnimationCommonV1 } from './animation';\n\nexport interface AudioOptionsV1 {\n  data?: AudioData;\n  fileName: string;\n  id: string;\n  parentAnimations?: LottieAnimationCommonV1[];\n  url?: string;\n  zipOptions?: ZipOptions;\n}\n\nexport class LottieAudioCommonV1 {\n  protected _data?: AudioData;\n\n  protected _id: string = '';\n\n  protected _url?: string;\n\n  protected _fileName: string = '';\n\n  protected _parentAnimations: LottieAnimationCommonV1[];\n\n  protected _zipOptions: ZipOptions;\n\n  public constructor(options: AudioOptionsV1) {\n    this._requireValidId(options.id);\n    this._requireValidFileName(options.fileName);\n\n    this._zipOptions = options.zipOptions ?? {};\n\n    if (options.data) {\n      this._data = options.data;\n    }\n\n    if (options.id) {\n      this._id = options.id;\n    }\n\n    if (options.url) {\n      this._url = options.url;\n    }\n\n    if (options.fileName) {\n      this._fileName = options.fileName;\n    }\n\n    this._parentAnimations = options.parentAnimations || [];\n  }\n\n  public get zipOptions(): ZipOptions {\n    return this._zipOptions;\n  }\n\n  public set zipOptions(zipOptions: ZipOptions) {\n    this._zipOptions = zipOptions;\n  }\n\n  public get fileName(): string {\n    return this._fileName;\n  }\n\n  public set fileName(fileName: string) {\n    if (!fileName) throw new DotLottieError('Invalid audio file name', ErrorCodes.ASSET_NOT_FOUND);\n    this._fileName = fileName;\n  }\n\n  public get id(): string {\n    return this._id;\n  }\n\n  public set id(id: string) {\n    if (!id) throw new DotLottieError('Invalid audio id', ErrorCodes.ASSET_NOT_FOUND);\n    this._id = id;\n  }\n\n  public get data(): AudioData | undefined {\n    return this._data;\n  }\n\n  public set data(data: AudioData | undefined) {\n    if (!data) {\n      throw new DotLottieError('Invalid data');\n    }\n\n    this._data = data;\n  }\n\n  public get parentAnimations(): LottieAnimationCommonV1[] {\n    return this._parentAnimations;\n  }\n\n  public set parentAnimations(parentAnimations: LottieAnimationCommonV1[]) {\n    this._parentAnimations = parentAnimations;\n  }\n\n  public async toDataURL(): Promise<string> {\n    if (this._data && this._isDataURL(this._data)) return this.data as string;\n\n    const arrayBuffer = await this.toArrayBuffer();\n\n    return dataUrlFromU8(new Uint8Array(arrayBuffer));\n  }\n\n  /**\n   * Renames the id and fileName to newName.\n   * @param newName - A new id and filename for the audio.\n   */\n  public async renameAudio(newName: string): Promise<void> {\n    this.id = newName;\n\n    const data = await this.toDataURL();\n\n    const ext = await getExtensionTypeFromBase64(data);\n\n    if (!ext) {\n      throw new DotLottieError('File extension type could not be detected from asset file.');\n    }\n\n    this.fileName = `${newName}.${ext}`;\n  }\n\n  public async toArrayBuffer(): Promise<ArrayBuffer> {\n    const blob = await (await this.toBlob()).arrayBuffer();\n\n    return blob;\n  }\n\n  public async toBlob(): Promise<Blob> {\n    if (!this._data && this._url) {\n      this._data = await this._fromUrlToBlob(this._url);\n    }\n\n    if (!this._data) {\n      throw new Error('Invalid data');\n    }\n\n    if (this._isDataURL(this._data)) {\n      const data = this._data as string;\n\n      const [header, base64] = data.split(',');\n\n      // If the data doesnt contain the encoding URL, return it\n      if ((!header || !base64) && data.length) {\n        return new Blob([data]);\n      }\n\n      if (!header || !base64) {\n        throw new Error('Invalid data');\n      }\n\n      // eslint-disable-next-line require-unicode-regexp\n      const type = header.replace('data:', '').replace(/;base64$/, '');\n\n      return new Blob([base64], { type });\n    }\n\n    if (this._isArrayBuffer(this._data)) {\n      return new Blob([this._data]);\n    }\n\n    if (this._isBlob(this._data)) {\n      return this._data as Blob;\n    }\n\n    throw new Error('Invalid data');\n  }\n\n  protected async _fromUrlToBlob(url: string): Promise<Blob> {\n    const response = await fetch(url);\n\n    return response.blob();\n  }\n\n  protected _isArrayBuffer(data: AudioData): boolean {\n    return data instanceof ArrayBuffer;\n  }\n\n  protected _isDataURL(data: AudioData): boolean {\n    return typeof data === 'string' && data.startsWith('data:');\n  }\n\n  protected _isBlob(data: AudioData): boolean {\n    return data instanceof Blob;\n  }\n\n  /**\n   * Ensure that the provided id is a valid string.\n   * The id must be a non-empty string, otherwise an error will be thrown.\n   * @param id - The id to validate.\n   * @throws Error - if the id is not a valid string.\n   */\n  private _requireValidId(id: string | undefined): asserts id is string {\n    if (!id) throw new DotLottieError('Invalid audio id');\n  }\n\n  /**\n   * Ensure that the provided fileName is a valid string.\n   * The fileName must be a non-empty string, otherwise an error will be thrown.\n   * @param fileName - The fileName to validate.\n   * @throws Error - if the fileName is not a valid string.\n   */\n  private _requireValidFileName(fileName: string | undefined): asserts fileName is string {\n    if (!fileName) throw new DotLottieError('Invalid audio fileName');\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { AudioOptionsV1 } from '../common';\nimport { LottieAudioCommonV1 } from '../common';\n\nexport class LottieAudioV1 extends LottieAudioCommonV1 {\n  public constructor(options: AudioOptionsV1) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { ImageOptionsV1 } from '../common';\nimport { LottieImageCommonV1 } from '../common';\n\nexport class LottieImageV1 extends LottieImageCommonV1 {\n  public constructor(options: ImageOptionsV1) {\n    super(options);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { DotLottieError, getExtensionTypeFromBase64, isAudioAsset } from '../../utils';\nimport type { AnimationOptionsV1 } from '../common';\nimport { LottieAnimationCommonV1 } from '../common';\n\nimport { LottieAudioV1 } from './audio';\nimport { LottieImageV1 } from './image';\n\nexport class LottieAnimationV1 extends LottieAnimationCommonV1 {\n  public constructor(options: AnimationOptionsV1) {\n    super(options);\n  }\n\n  /**\n   * Return the animation data as a base64 encoded string.\n   *\n   * @returns data - The animation data as a base64 encoded string.\n   * @throws Error - if the animation data is not set and the url is not provided.\n   * @throws Error - if the animation data is not a valid Lottie animation data object.\n   * @throws Error - if the fetch request fails.\n   */\n  public override async toBase64(): Promise<string> {\n    const data = await this.toArrayBuffer();\n\n    if (typeof window === 'undefined') return Buffer.from(data).toString('base64');\n\n    const uint8Array = new Uint8Array(data);\n    const binaryString = uint8Array.reduce((acc, val) => acc + String.fromCharCode(val), '');\n\n    return window.btoa(binaryString);\n  }\n\n  /**\n   *\n   * Extract image assets from the animation.\n   *\n   * @returns boolean - true on error otherwise false on success\n   */\n  protected override async _extractImageAssets(): Promise<boolean> {\n    if (!this._data) throw new DotLottieError('Failed to extract image assets: Animation data does not exist');\n\n    const animationAssets = this._data.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError('Failed to extract image assets: No assets found inside animation');\n\n    for (const asset of animationAssets) {\n      if ('w' in asset && 'h' in asset && !('xt' in asset) && 'p' in asset) {\n        const imageData = asset.p.split(',');\n\n        // Image data is invalid\n        if (!imageData.length || !imageData[0] || !imageData[1]) {\n          break;\n        }\n\n        let extType = null;\n        const fileType = await getExtensionTypeFromBase64(asset.p);\n\n        // If we don't recognize the file type, we leave it inside the animation as is.\n        if (fileType) {\n          extType = fileType;\n\n          const fileName = `${asset.id}.${extType}`;\n\n          this._imageAssets.push(\n            new LottieImageV1({\n              data: asset.p,\n              id: asset.id,\n              lottieAssetId: asset.id,\n              fileName,\n              parentAnimations: [this],\n            }),\n          );\n\n          asset.p = fileName;\n          asset.u = '/images/';\n          asset.e = 0;\n        }\n      }\n    }\n\n    return false;\n  }\n\n  /**\n   *\n   * Extract audio assets from the animation.\n   *\n   * @returns boolean - true on error otherwise false on success\n   */\n  protected override async _extractAudioAssets(): Promise<boolean> {\n    if (!this._data) throw new DotLottieError('Failed to extract audio assets: Animation data does not exist');\n\n    const animationAssets = this._data.assets as AnimationType['assets'];\n\n    if (!animationAssets) throw new DotLottieError('Failed to extract image assets: No assets found inside animation');\n\n    for (const asset of animationAssets) {\n      if (isAudioAsset(asset)) {\n        const audioData = asset.p.split(',');\n\n        // Audio data is invalid\n        if (!audioData.length || !audioData[0] || !audioData[1]) {\n          break;\n        }\n\n        let extType = null;\n        const fileType = await getExtensionTypeFromBase64(asset.p);\n\n        extType = fileType;\n\n        const fileName = `${asset.id}.${extType}`;\n\n        this._audioAssets.push(\n          new LottieAudioV1({\n            data: asset.p,\n            id: asset.id,\n            fileName,\n            parentAnimations: [this],\n          }),\n        );\n\n        asset.p = fileName;\n        asset.u = '/audio/';\n        asset.e = 0;\n      }\n    }\n\n    return false;\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { DotLottieError } from '../../utils';\n\nimport type { DotLottieCommonV1 } from './dotlottie';\n\ninterface DotLottieV1PluginOptions {\n  parallel?: boolean;\n}\n\nexport class DotLottieV1Plugin {\n  protected dotLottieV1: DotLottieCommonV1 | undefined;\n\n  protected _parallel: boolean = false;\n\n  public constructor(options?: DotLottieV1PluginOptions) {\n    this.dotLottieV1 = undefined;\n\n    if (options?.parallel) {\n      this._parallel = options.parallel;\n    }\n  }\n\n  public install(dotLottieV1: DotLottieCommonV1): void {\n    this.dotLottieV1 = dotLottieV1;\n  }\n\n  public uninstall(): void {\n    this.dotLottieV1 = undefined;\n  }\n\n  public get parallel(): boolean {\n    return this._parallel;\n  }\n\n  public set parallel(value: boolean) {\n    this._parallel = value;\n  }\n\n  public async onBuild(): Promise<void> {\n    throw new DotLottieError('DotLottieV1-plugin build Not implemented!');\n  }\n\n  protected _requireDotLottieV1(dotLottieV1: DotLottieCommonV1 | undefined): asserts dotLottieV1 {\n    if (!dotLottieV1)\n      throw new DotLottieError('DotLottieV1 context is null inside of duplicate image detector plugin.');\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\n\nimport { DotLottieError } from '../../../utils';\nimport { LottieImageV1 } from '../../browser/image';\nimport type { LottieAnimationCommonV1 } from '../animation';\nimport type { LottieImageCommonV1 } from '../image';\nimport { DotLottieV1Plugin } from '../plugin';\n\ninterface LottieImageV1Compare {\n  excludeFromExport: boolean;\n  hash: string | undefined;\n  image: LottieImageCommonV1;\n}\n\nexport class DuplicateImageDetectorCommon extends DotLottieV1Plugin {\n  public async generatePhash(_image: LottieImageCommonV1): Promise<string> {\n    throw new DotLottieError(\n      'generatePhash(image: LottieImageCommonV1): Promise<Hash> is not implemented in concrete class.',\n    );\n  }\n\n  public distanceTo(_imageHash: string, _targetImageHash: string): number {\n    throw new DotLottieError(\n      'distanceTo(_imageHash: string, _targetImageHash: string): Promise<number> is not implemented in concrete class.',\n    );\n  }\n\n  private async _createRecordOfDuplicates(): Promise<Record<string, LottieImageCommonV1[]>> {\n    this._requireDotLottieV1(this.dotLottieV1);\n\n    const images: LottieImageV1Compare[] = [];\n    const recordOfDuplicates: Record<string, LottieImageCommonV1[]> = {};\n\n    // push all of the animation image assets in to the images array\n    for (const animation of this.dotLottieV1.animations) {\n      for (const image of animation.imageAssets) {\n        images.push({\n          excludeFromExport: false,\n          image,\n          hash: await this.generatePhash(image),\n        });\n      }\n    }\n\n    // For every array of images\n    // Loop over the images of the array\n    for (const image of images) {\n      // Now that we have a single image of the image array, compare it to every other image in the arry\n      for (const compareImage of images) {\n        if (\n          image.image.lottieAssetId !== compareImage.image.lottieAssetId &&\n          !image.excludeFromExport &&\n          !compareImage.excludeFromExport &&\n          image.hash &&\n          compareImage.hash &&\n          this.distanceTo(image.hash, compareImage.hash) < 5\n          // image.hash.getHammingDistance(compareImage.hash) < 5\n        ) {\n          // Check if key is already in use\n          if (!recordOfDuplicates[image.image.fileName] && !recordOfDuplicates[compareImage.image.fileName]) {\n            compareImage.excludeFromExport = true;\n\n            recordOfDuplicates[image.image.fileName] = [compareImage.image];\n          } else if (recordOfDuplicates[compareImage.image.fileName]) {\n            // Check for duplicates, otherwise push the duplicate image\n            if (\n              !recordOfDuplicates[compareImage.image.fileName]?.find(\n                (item) => item.lottieAssetId === image.image.lottieAssetId,\n              )\n            ) {\n              image.excludeFromExport = true;\n              recordOfDuplicates[compareImage.image.fileName]?.push(image.image);\n            }\n          }\n        }\n      }\n    }\n\n    return recordOfDuplicates;\n  }\n\n  /**\n   * Apply the image path to all duplicate images.\n   *\n   * @param recordOfDuplicates - A record of duplicate images, the key being a fileName,\n   * the value being the identical LottieImageCommonV1 object.\n   */\n  public adjustDuplicateImageAssetPath(\n    animation: LottieAnimationCommonV1,\n    recordOfDuplicates: Record<string, LottieImageCommonV1[]>,\n  ): void {\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        recordOfDuplicates[key]?.forEach((item) => {\n          // Check if this animation has the image before loop over data to save time ?\n\n          if (animation.data) {\n            const animationAssets = animation.data.assets as AnimationType['assets'];\n\n            if (animationAssets) {\n              animationAssets.forEach((asset) => {\n                if ('w' in asset && 'h' in asset) {\n                  // we've found an asset id thats equal to the id of a duplicate image\n                  // Or we found the fileName of a duplicate inside the asset, so we need to change it\n\n                  if (asset.p === item.fileName) {\n                    const fileName = key;\n\n                    asset.p = fileName;\n                  }\n                }\n              });\n            }\n          }\n        });\n      }\n    }\n  }\n\n  public override async onBuild(): Promise<void> {\n    this._requireDotLottieV1(this.dotLottieV1);\n\n    // Create a record of duplicates\n    const recordOfDuplicates: Record<string, LottieImageCommonV1[]> = await this._createRecordOfDuplicates();\n\n    // Check the record of duplicates and repath the duplicate images\n    this.dotLottieV1.animations.forEach((animation) => {\n      this.adjustDuplicateImageAssetPath(animation, recordOfDuplicates);\n    });\n\n    // Create an array of duplicates by looping over the recordOfDuplicates and using the key as the image to use\n    const clonedImages: Record<string, LottieImageV1> = {};\n    const images = this.dotLottieV1.getImages();\n\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        for (const image of images) {\n          if (image.fileName === key && image.data !== undefined) {\n            clonedImages[key] = new LottieImageV1({\n              data: image.data,\n              id: image.id,\n              lottieAssetId: image.lottieAssetId,\n              fileName: image.fileName,\n            });\n          }\n        }\n      }\n    }\n\n    if (Object.keys(clonedImages).length !== Object.keys(recordOfDuplicates).length) {\n      throw new DotLottieError('The number of cloned images does not match the number of duplicate keys.');\n    }\n\n    // For each image of recordOfDuplicates, remove itself from all the parent animations and push the clone\n    for (const key in recordOfDuplicates) {\n      if (key) {\n        recordOfDuplicates[key]?.forEach((image) => {\n          if (image.parentAnimations.length) {\n            for (const parentAnimation of image.parentAnimations) {\n              parentAnimation.imageAssets.splice(parentAnimation.imageAssets.indexOf(image), 1);\n\n              const clonedImage = clonedImages[key];\n\n              if (clonedImage !== undefined) {\n                parentAnimation.imageAssets.push(clonedImage);\n\n                clonedImage.parentAnimations.push(parentAnimation);\n              }\n            }\n          }\n        });\n      }\n    }\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\nimport { Hash, DifferenceHashBuilder } from 'browser-image-hash';\n\nimport type { LottieImageCommonV1 } from '../../common';\nimport { DuplicateImageDetectorCommon } from '../../common/plugins/duplicate-image-detector';\n\nexport class DuplicateImageDetector extends DuplicateImageDetectorCommon {\n  public override async generatePhash(image: LottieImageCommonV1): Promise<string> {\n    const builder = new DifferenceHashBuilder();\n    const targetURL = new URL(await image.toDataURL());\n\n    const destHash = await builder.build(targetURL);\n\n    return destHash.rawHash;\n  }\n\n  public override distanceTo(imageHash: string, targetImageHash: string): number {\n    const srcHash = new Hash(imageHash);\n    const targetHash = new Hash(targetImageHash);\n\n    return srcHash.getHammingDistance(targetHash);\n  }\n}\n","/**\n * Copyright 2023 Design Barn Inc.\n */\n\n/* eslint-disable @typescript-eslint/no-use-before-define */\n\nimport type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';\nimport type { Zippable } from 'fflate';\nimport { strToU8, zip, strFromU8, unzip } from 'fflate';\n\nimport type { ConversionOptions } from '../../types';\nimport {\n  base64ToUint8Array,\n  DotLottieError,\n  getDotLottieVersion,\n  getExtensionTypeFromBase64,\n  isAudioAsset,\n} from '../../utils';\nimport { DotLottie } from '../../v2/browser';\nimport type { AnimationOptionsV1, DotLottieV1Options } from '../common';\nimport { DotLottieCommonV1 } from '../common';\nimport type { ManifestV1 } from '../common/schemas/manifest';\n\nimport { LottieAnimationV1 } from './animation';\nimport { LottieAudioV1 } from './audio';\nimport { LottieImageV1 } from './image';\nimport { DuplicateImageDetector } from './plugins/duplicate-image-detector';\n\nexport async function toDotLottieV1(arrayBuffer: ArrayBuffer): Promise<DotLottieV1> {\n  const version = await getDotLottieVersion(new Uint8Array(arrayBuffer));\n\n  if (version === '2') {\n    const dotLottieV1 = new DotLottieV1();\n\n    const dotLottieV2 = await new DotLottie().fromArrayBuffer(arrayBuffer);\n\n    const animationIds = dotLottieV2.animations.map((animation) => animation.id);\n\n    for (const animationId of animationIds) {\n      const animation = await dotLottieV2.getAnimation(animationId, { inlineAssets: true });\n\n      if (animation && animation.data) {\n        dotLottieV1.addAnimation({\n          data: animation.data,\n          id: animationId,\n        });\n      }\n    }\n\n    await dotLottieV1.build();\n\n    return dotLottieV1;\n  } else {\n    return new DotLottieV1().fromArrayBuffer(arrayBuffer);\n  }\n}\n\nexport class DotLottieV1 extends DotLottieCommonV1 {\n  public constructor(options?: DotLottieV1Options) {\n    super(options);\n\n    if (this.enableDuplicateImageOptimization) {\n      const plugin = new DuplicateImageDetector();\n\n      plugin.install(this);\n\n      this._plugins.push(plugin);\n    }\n  }\n\n  public override addAnimation(animationOptions: AnimationOptionsV1): DotLottieV1 {\n    const animation = new LottieAnimationV1(animationOptions);\n\n    if (this._animationsMap.get(animationOptions.id)) {\n      throw new DotLottieError('Duplicate animation id detected, aborting.');\n    }\n\n    this._animationsMap.set(animation.id, animation);\n\n    return this;\n  }\n\n  public override async toBase64(options?: ConversionOptions): Promise<string> {\n    const data = await this.toArrayBuffer(options);\n\n    const uint8Array = new Uint8Array(data);\n    const binaryString = uint8Array.reduce((acc, val) => acc + String.fromCharCode(val), '');\n\n    return window.btoa(binaryString);\n  }\n\n  public override async download(fileName: string, options?: ConversionOptions): Promise<void> {\n    const blob = await this.toBlob(options);\n\n    const dataURL = URL.createObjectURL(blob);\n\n    const link = document.createElement('a');\n\n    link.href = dataURL;\n\n    link.download = fileName;\n\n    link.style.display = 'none';\n\n    document.body.append(link);\n\n    link.click();\n\n    setTimeout(() => {\n      URL.revokeObjectURL(dataURL);\n      link.remove();\n    }, 1000);\n  }\n\n  public override create(options?: DotLottieV1Options): DotLottieCommonV1 {\n    return new DotLottieV1(options);\n  }\n\n  public override async toArrayBuffer(options?: ConversionOptions): Promise<ArrayBuffer> {\n    const manifest = this._buildManifest();\n\n    const dotLottie: Zippable = {\n      'manifest.json': [strToU8(JSON.stringify(manifest)), {}],\n    };\n\n    for (const animation of this.animations) {\n      const json = await animation.toJSON();\n\n      dotLottie[`animations/${animation.id}.json`] = [strToU8(JSON.stringify(json)), animation.zipOptions];\n\n      const imageAssets = animation.imageAssets;\n      const audioAssets = animation.audioAssets;\n\n      for (const asset of imageAssets) {\n        // Assure we have a base64 encoded version of the image\n        const dataAsString = await asset.toDataURL();\n\n        dotLottie[`images/${asset.fileName}`] = [base64ToUint8Array(dataAsString), asset.zipOptions];\n      }\n\n      for (const asset of audioAssets) {\n        // Assure we have a base64 encoded version of the audio\n        const dataAsString = await asset.toDataURL();\n\n        dotLottie[`audio/${asset.fileName}`] = [base64ToUint8Array(dataAsString), asset.zipOptions];\n      }\n    }\n\n    const dotLottieArrayBuffer = await new Promise<ArrayBuffer>((resolve, reject) => {\n      zip(dotLottie, options?.zipOptions || {}, (err, data) => {\n        if (err) {\n          reject(err);\n\n          return;\n        }\n\n        resolve(data.buffer);\n      });\n    });\n\n    return dotLottieArrayBuffer;\n  }\n\n  /**\n   * Creates a DotLottieV1 instance from an array buffer\n   * @param arrayBuffer - array buffer of the DotLottieV1 file\n   * @returns DotLottieV1 instance\n   * @throws Error\n   */\n  public override async fromArrayBuffer(arrayBuffer: ArrayBuffer): Promise<DotLottieCommonV1> {\n    const dotLottieVersion = await getDotLottieVersion(new Uint8Array(arrayBuffer));\n\n    if (dotLottieVersion === '2') {\n      return toDotLottieV1(arrayBuffer);\n    }\n\n    const dotLottie = new DotLottieV1();\n\n    try {\n      const contentObj = await new Promise<Zippable>((resolve, reject) => {\n        unzip(new Uint8Array(arrayBuffer), (err, data) => {\n          if (err) {\n            reject(err);\n          }\n\n          resolve(data);\n        });\n      });\n\n      const tmpImages = [];\n      const tmpAudio = [];\n\n      if (contentObj['manifest.json'] instanceof Uint8Array) {\n        // valid buffer\n        try {\n          // Parse the manifest first so that we can pick up animation settings\n          const manifest = JSON.parse(strFromU8(contentObj['manifest.json'], false)) as ManifestV1;\n          const { author, custom, description, keywords } = manifest;\n\n          if (author) {\n            this._requireValidAuthor(author);\n            dotLottie.setAuthor(author);\n          }\n          if (custom) {\n            this._requireValidCustomData(custom);\n            dotLottie.setCustomData(custom);\n          }\n          if (description) {\n            this._requireValidDescription(description);\n            dotLottie.setDescription(description);\n          }\n          if (keywords) {\n            this._requireValidKeywords(keywords);\n            dotLottie.setKeywords(keywords);\n          }\n\n          for (const key of Object.keys(contentObj)) {\n            // true is passed to use binary string, otherwise btoa fails\n            const decodedStr = strFromU8(contentObj[key] as Uint8Array, true);\n\n            if (key.startsWith('animations/') && key.endsWith('.json')) {\n              // extract animationId from key as the key = `animations/${animationId}.json`\n              const animationId = /animations\\/(.+)\\.json/u.exec(key)?.[1];\n\n              if (!animationId) {\n                throw new DotLottieError('Invalid animation id');\n              }\n\n              const animation = JSON.parse(decodedStr);\n\n              const animationSettings = manifest.animations.find((anim) => anim.id === animationId);\n\n              if (animationSettings === undefined) {\n                throw new DotLottieError('Animation not found inside manifest');\n              }\n\n              dotLottie.addAnimation({\n                data: animation,\n                ...animationSettings,\n              });\n            } else if (key.startsWith('images/')) {\n              // extract imageId from key as the key = `images/${imageId}.${ext}`\n              const imageId = /images\\/(.+)\\./u.exec(key)?.[1];\n\n              if (!imageId) {\n                throw new DotLottieError('Invalid image id');\n              }\n\n              let decodedImg = btoa(decodedStr);\n\n              const ext = await getExtensionTypeFromBase64(decodedImg);\n\n              // Push the images in to a temporary array\n              decodedImg = `data:image/${ext};base64,${decodedImg}`;\n              tmpImages.push(\n                new LottieImageV1({\n                  id: imageId,\n                  lottieAssetId: imageId,\n                  data: decodedImg,\n                  fileName: key.split('/')[1] || '',\n                }),\n              );\n            } else if (key.startsWith('audio/')) {\n              // extract audioId from key as the key = `audio/${audioId}.${ext}`\n              const audioId = /audio\\/(.+)\\./u.exec(key)?.[1];\n\n              if (!audioId) {\n                throw new DotLottieError('Invalid image id');\n              }\n\n              let decodedAudio = btoa(decodedStr);\n\n              const ext = await getExtensionTypeFromBase64(decodedAudio);\n\n              // Push the audio in to a temporary array\n              decodedAudio = `data:audio/${ext};base64,${decodedAudio}`;\n              tmpAudio.push(\n                new LottieAudioV1({\n                  id: audioId,\n                  data: decodedAudio,\n                  fileName: key.split('/')[1] || '',\n                }),\n              );\n            }\n          }\n\n          // Go through the images and find to which animation they belong\n          for (const image of tmpImages) {\n            for (const parentAnimation of dotLottie.animations) {\n              if (parentAnimation.data) {\n                const animationAssets = parentAnimation.data.assets as AnimationType['assets'];\n\n                if (animationAssets) {\n                  for (const asset of animationAssets) {\n                    if ('w' in asset && 'h' in asset) {\n                      if (asset.p === image.fileName) {\n                        image.parentAnimations.push(parentAnimation);\n                        parentAnimation.imageAssets.push(image);\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n\n          // Go through the audio and find to which animation they belong\n          for (const audio of tmpAudio) {\n            for (const parentAnimation of dotLottie.animations) {\n              if (parentAnimation.data) {\n                const animationAssets = parentAnimation.data.assets as AnimationType['assets'];\n\n                if (animationAssets) {\n                  for (const asset of animationAssets) {\n                    if (isAudioAsset(asset)) {\n                      if (asset.p.includes(audio.id)) {\n                        audio.parentAnimations.push(parentAnimation);\n                        parentAnimation.audioAssets.push(audio);\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        } catch (err) {\n          if (err instanceof Error) {\n            throw new DotLottieError(`Invalid manifest inside buffer! ${err.message}`);\n          }\n        }\n      } else {\n        // throw error as it's invalid buffer\n        throw new DotLottieError('Invalid buffer');\n      }\n    } catch (err) {\n      if (err instanceof Error) {\n        throw new DotLottieError(err.message);\n      }\n    }\n\n    return dotLottie;\n  }\n}\n","/**\n * Copyright 2024 Design Barn Inc.\n */\n\nimport { DotLottieV1 } from './v1/browser';\nimport type { DotLottieV1Options } from './v1/common';\nimport { DotLottie } from './v2/browser';\nimport type { DotLottieOptions } from './v2/common';\n\nexport function makeDotLottie<T extends 'v1' | 'v2'>(\n  version: T,\n  options?: T extends 'v1' ? DotLottieV1Options : DotLottieOptions,\n): T extends 'v1' ? DotLottieV1 : DotLottie {\n  if (version === 'v1') {\n    return new DotLottieV1(options as DotLottieV1Options) as T extends 'v1' ? DotLottieV1 : DotLottie;\n  }\n\n  return new DotLottie(options as DotLottieOptions) as T extends 'v1' ? DotLottieV1 : DotLottie;\n}\n\nexport * from './v1/browser';\nexport * from './v1/common';\nexport * from './v2/browser';\nexport * from './v2/common';\nexport * from './utils';\nexport * from './types';\n"]}