{"version":3,"file":"localazy-cdn-client.cjs","names":[],"sources":["../../src/cdn/api/api.ts","../../src/cdn/cache/memory-cache-adapter.ts","../../src/cdn/utils.ts","../../src/cdn/cache/locales-cache.ts","../../src/cdn/response/response-factory.ts","../../src/cdn/context/context.ts","../../src/cdn/metafile/metafile-file.ts","../../src/cdn/metafile/metafile-locale.ts","../../src/cdn/metafile/metafile-data.ts","../../src/cdn/metafile/metafile-params.ts","../../src/cdn/context/metafile-context.ts","../../src/cdn/http/fetch-http-adapter.ts","../../src/cdn/methods/cdn-base.ts","../../src/cdn/methods/cdn-cache.ts","../../src/cdn/methods/cdn-metafile.ts","../../src/cdn/request/locales-map.ts","../../src/cdn/request/request.ts","../../src/cdn/request/request-builder.ts","../../src/cdn/cdn-client.ts"],"sourcesContent":["import type { Context } from '@/cdn/context/context.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\n\nexport class Api {\n  protected context: Context;\n\n  constructor(context: Context) {\n    this.context = context;\n  }\n\n  public async fetchLocale(options: ApiLocaleRequest): Promise<object | string> {\n    if (this.context.cache.has(options)) {\n      return new Promise((resolve): void => {\n        resolve(this.context.cache.get(options) as object | string);\n      });\n    }\n\n    return this.context.client.get(options.metafileLocale.uri);\n  }\n\n  public async fetchMetafile(): Promise<IMetafile> {\n    return (await this.context.client.get(this.context.metafile.params.jsonPath)) as IMetafile;\n  }\n}\n","import type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\n\nexport class MemoryCacheAdapter<K, V> implements ICacheAdapter<K, V> {\n  protected map: Map<K, V>;\n\n  constructor() {\n    this.map = new Map();\n  }\n\n  public get(key: K): V | undefined {\n    return this.map.get(key);\n  }\n\n  public has(key: K): boolean {\n    return this.map.has(key);\n  }\n\n  public set(key: K, value: V): void {\n    this.map.set(key, value);\n  }\n\n  public flush(): void {\n    this.map = new Map();\n  }\n}\n","export const isString = (value: unknown): value is string => typeof value === 'string';\n\nexport const isUndefined = (value: unknown): value is undefined => typeof value === 'undefined';\n\nexport const isArray = <T>(value: unknown): value is T[] => Array.isArray(value);\n\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n  Object.prototype.toString.call(value) === '[object Object]';\n\nexport const uniq = <T>(array: T[]): T[] => [...new Set(array)];\n\nexport const uniqBy = <T>(array: T[], predicate: (item: T) => string): T[] => {\n  const seen: Record<string, boolean> = {};\n\n  return array.filter((item: T): boolean => {\n    const key: string = predicate(item);\n\n    if (!Object.hasOwn(seen, key)) {\n      seen[key] = true;\n\n      return true;\n    }\n\n    return false;\n  });\n};\n","import { MemoryCacheAdapter } from '@/cdn/cache/memory-cache-adapter.js';\nimport type { Context } from '@/cdn/context/context.js';\nimport { uniq } from '@/cdn/utils.js';\nimport type { ICacheAdapter } from '@/interfaces/i-cache-adapter.js';\nimport type { CacheGetLocalesRequest } from '@/types/cache-get-locales-request.js';\nimport type { CacheHasLocalesRequest } from '@/types/cache-has-locales-request.js';\nimport type { CacheKeyMetafileOptions } from '@/types/cache-key-metafile-options.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\n\nexport class LocalesCache {\n  protected context: Context;\n\n  protected cacheAdapter: ICacheAdapter<string, object | string>;\n\n  constructor(context: Context) {\n    this.context = context;\n    this.cacheAdapter = new MemoryCacheAdapter();\n  }\n\n  public setIfMissed(options: CacheStoreLocalesRequest): void {\n    const { metafileFile, metafileLocale, data }: CacheStoreLocalesRequest = options;\n\n    const key: string = this.keyFromMetafile({\n      metafileFile,\n      metafileLocale,\n    });\n\n    if (!this.cacheAdapter.has(key)) {\n      this.cacheAdapter.set(key, data);\n    }\n  }\n\n  public has(options: CacheHasLocalesRequest): boolean {\n    const key: string = this.keyFromMetafile(options);\n\n    return this.cacheAdapter.has(key);\n  }\n\n  public get(options: CacheGetLocalesRequest): object | string | undefined {\n    const key: string = this.keyFromMetafile(options);\n\n    return this.cacheAdapter.get(key);\n  }\n\n  public flush(): void {\n    this.cacheAdapter.flush();\n  }\n\n  protected keyFromMetafile(options: CacheKeyMetafileOptions): string {\n    const { metafileFile, metafileLocale }: CacheKeyMetafileOptions = options;\n    const productFlavors: string = [...uniq(metafileFile.productFlavors)].sort().join('-');\n\n    const indices: string[] = [\n      this.context.metafile.params.cdnId,\n      metafileFile.id,\n      metafileFile.file,\n      metafileFile.path,\n      metafileFile.library,\n      metafileFile.module,\n      metafileFile.buildType,\n      productFlavors,\n      metafileLocale.locale,\n      metafileLocale.timestamp.toString(),\n    ];\n\n    return indices.filter((key: string): boolean => key !== '').join('-');\n  }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CacheStoreLocalesRequest } from '@/types/cache-store-locales-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\nimport type { ResponseFactoryOptions } from '@/types/response-factory-options.js';\n\nexport class ResponseFactory {\n  protected context: Context;\n\n  constructor(context: Context) {\n    this.context = context;\n  }\n\n  public createCdnResponse(options: ResponseFactoryOptions): CdnResponse {\n    const {\n      requests,\n      responses,\n      hasSingleFileResponse,\n      hasSingleLocaleResponse,\n    }: ResponseFactoryOptions = options;\n\n    if (responses.length === 0 || typeof responses[0] === 'undefined') {\n      return {};\n    }\n\n    this.cacheResponses(requests, responses);\n\n    return hasSingleFileResponse && hasSingleLocaleResponse\n      ? responses[0]\n      : ResponseFactory.transformResponses(options);\n  }\n\n  protected cacheResponses(requests: ApiLocaleRequest[], responses: (object | string)[]): void {\n    responses.forEach((response: object | string, index: number): void => {\n      if (typeof requests[index] !== 'undefined') {\n        const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n        if (metafileFile && metafileLocale) {\n          this.context.cache.setIfMissed({ metafileFile, metafileLocale, data: response });\n        }\n      }\n    });\n  }\n\n  protected static transformResponses(options: ResponseFactoryOptions): CdnResponse {\n    const { requests, responses, hasSingleFileResponse }: ResponseFactoryOptions = options;\n\n    return responses.reduce((acc: CdnResponse, cur: object | string, index: number) => {\n      if (typeof requests[index] !== 'undefined') {\n        const { metafileFile, metafileLocale }: Partial<CacheStoreLocalesRequest> = requests[index];\n\n        if (metafileFile && metafileLocale) {\n          if (hasSingleFileResponse) {\n            // @ts-expect-error fix output type\n            acc[metafileLocale.locale] = cur;\n          } else {\n            // @ts-expect-error fix output type\n            if (!acc[metafileFile.id]) {\n              // @ts-expect-error fix output type\n              acc[metafileFile.id] = {};\n            }\n\n            // @ts-expect-error fix output type\n            acc[metafileFile.id][metafileLocale.locale] = cur;\n          }\n        }\n      }\n\n      return acc;\n    }, {});\n  }\n}\n","import { Api } from '@/cdn/api/api.js';\nimport { LocalesCache } from '@/cdn/cache/locales-cache.js';\nimport type { CdnClient } from '@/cdn/cdn-client.js';\nimport type { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { ResponseFactory } from '@/cdn/response/response-factory.js';\nimport type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\nimport type { ContextOptions } from '@/types/context-options.js';\n\nexport class Context {\n  public metafile: MetafileContext;\n\n  public cdn: CdnClient;\n\n  public client: IHttpAdapter;\n\n  public api: Api;\n\n  public cache: LocalesCache;\n\n  public responseFactory: ResponseFactory;\n\n  constructor(options: ContextOptions) {\n    this.metafile = options.metafileContext;\n    this.cdn = options.cdn;\n    this.client = options.client;\n    this.api = new Api(this);\n    this.cache = new LocalesCache(this);\n    this.responseFactory = new ResponseFactory(this);\n  }\n}\n","import type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { IMetafileFile } from '@/interfaces/i-metafile-file.js';\nimport type { CdnFileLocale } from '@/types/cdn-file-locale.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { MetafileFileOptions } from '@/types/metafile-file-options.js';\n\nexport class MetafileFile implements Omit<IMetafileFile, 'locales'> {\n  public id: string;\n\n  public file: string;\n\n  public path: string;\n\n  public library: string;\n\n  public module: string;\n\n  public buildType: string;\n\n  public timestamp: number;\n\n  public productFlavors: string[];\n\n  public locales: MetafileLocale[];\n\n  protected baseUrl: string;\n\n  constructor(options: MetafileFileOptions) {\n    this.id = options.id;\n    this.file = options.file;\n    this.path = options.path;\n    this.library = options.library;\n    this.module = options.module;\n    this.buildType = options.buildType;\n    this.timestamp = options.timestamp;\n    this.productFlavors = options.productFlavors;\n    this.locales = options.locales;\n    this.baseUrl = options.baseUrl;\n  }\n\n  public toCdnFile(): CdnFile {\n    return {\n      id: this.id,\n      file: this.file,\n      path: this.path,\n      library: this.library,\n      module: this.module,\n      buildType: this.buildType,\n      productFlavors: this.productFlavors,\n      locales: this.locales.map(\n        (locale: MetafileLocale): CdnFileLocale => ({\n          locale: locale.locale,\n          isBaseLocale: locale.isBaseLocale,\n          uri: `${this.baseUrl}${locale.uri}`,\n        }),\n      ),\n    };\n  }\n}\n","import type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\n\nexport class MetafileLocale implements IMetafileFileLocale {\n  public language: string;\n\n  public region: string;\n\n  public script: string;\n\n  public isRtl: boolean;\n\n  public name: string;\n\n  public localizedName: string;\n\n  public uri: string;\n\n  public timestamp: number;\n\n  protected baseLocale: string;\n\n  constructor(options: IMetafileFileLocale, baseLocale: string) {\n    this.language = options.language;\n    this.region = options.region;\n    this.script = options.script;\n    this.isRtl = options.isRtl;\n    this.name = options.name;\n    this.localizedName = options.localizedName;\n    this.uri = options.uri;\n    this.timestamp = options.timestamp;\n    this.baseLocale = baseLocale;\n  }\n\n  get locale(): string {\n    if (this.language && this.region && this.script) {\n      return `${this.language}_${this.region}#${this.script}`;\n    }\n\n    if (this.language && this.script) {\n      return `${this.language}#${this.script}`;\n    }\n\n    if (this.language && this.region) {\n      return `${this.language}_${this.region}`;\n    }\n\n    return this.language;\n  }\n\n  get isBaseLocale(): boolean {\n    return this.locale === this.baseLocale;\n  }\n\n  public toCdnLocale(): CdnLocale {\n    return {\n      locale: this.locale,\n      isBaseLocale: this.isBaseLocale,\n      language: this.language,\n      region: this.region,\n      script: this.script,\n      isRtl: this.isRtl,\n      name: this.name,\n      localizedName: this.localizedName,\n    };\n  }\n}\n","import { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { uniqBy } from '@/cdn/utils.js';\nimport type { IMetafileFileLocale } from '@/interfaces/i-metafile-file-locale.js';\nimport type { IMetafileFiles } from '@/interfaces/i-metafile-files.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { FilesMap } from '@/types/files-map.js';\nimport type { MetafileOptions } from '@/types/metafile-options.js';\n\nexport class MetafileData implements Omit<IMetafile, 'files' | 'baseLocale'> {\n  public projectUrl: string;\n\n  public baseLocale: CdnLocale;\n\n  public locales: CdnLocale[];\n\n  public timestamp: number;\n\n  public files: MetafileFile[];\n\n  public filesMap: FilesMap;\n\n  constructor(options: MetafileOptions, params: MetafileParams) {\n    this.projectUrl = options.projectUrl;\n    this.timestamp = options.timestamp;\n    this.files = MetafileData.filesFactory(options.files, options.baseLocale, params);\n    this.filesMap = MetafileData.filesMapFactory(this.files);\n    this.locales = MetafileData.localesFactory(this.files);\n    this.baseLocale = this.locales.find((locale: CdnLocale) => locale.isBaseLocale) as CdnLocale;\n  }\n\n  public static createEmpty(params: MetafileParams): MetafileData {\n    return new MetafileData(\n      {\n        projectUrl: '',\n        baseLocale: '',\n        timestamp: 0,\n        files: {},\n      },\n      params,\n    );\n  }\n\n  protected static filesFactory(\n    files: IMetafileFiles,\n    baseLocale: string,\n    params: MetafileParams,\n  ): MetafileFile[] {\n    return Object.keys(files).reduce((acc: MetafileFile[], cur: string) => {\n      if (typeof files[cur] !== 'undefined') {\n        const locales: MetafileLocale[] = files[cur].locales.map(\n          (locale: IMetafileFileLocale) => new MetafileLocale(locale, baseLocale),\n        );\n\n        acc.push(\n          new MetafileFile({\n            ...files[cur],\n            id: cur,\n            locales,\n            baseUrl: params.baseUrl,\n          }),\n        );\n      }\n\n      return acc;\n    }, []);\n  }\n\n  protected static filesMapFactory(files: MetafileFile[]): FilesMap {\n    return files.reduce((acc: FilesMap, cur: MetafileFile) => {\n      acc[cur.id] = cur;\n\n      return acc;\n    }, {});\n  }\n\n  protected static localesFactory(files: MetafileFile[]): CdnLocale[] {\n    const locales: CdnLocale[] = files.reduce((acc: CdnLocale[], cur: MetafileFile) => {\n      acc.push(...cur.locales.map((locale: MetafileLocale): CdnLocale => locale.toCdnLocale()));\n      return acc;\n    }, []);\n\n    return uniqBy(locales, (cdnLocale: CdnLocale): string => cdnLocale.locale);\n  }\n}\n","import type { IMetafileParams } from '@/interfaces/i-metafile-params.js';\n\nexport class MetafileParams implements IMetafileParams {\n  protected options: IMetafileParams;\n\n  constructor(metafileUrl: string) {\n    this.options = MetafileParams.parseMetafileUrl(metafileUrl);\n  }\n\n  get url(): string {\n    return this.options.url;\n  }\n\n  get baseUrl(): string {\n    return this.options.baseUrl;\n  }\n\n  get cdnId(): string {\n    return this.options.cdnId;\n  }\n\n  get jsonPath(): string {\n    return this.options.jsonPath;\n  }\n\n  protected static parseMetafileUrl(metafileUrl: string): IMetafileParams {\n    let url: URL;\n\n    try {\n      url = new URL(metafileUrl);\n    } catch {\n      throw new Error('Invalid param: \"options.metafile\" cannot be parsed as url.');\n    }\n\n    const matches: string[] | null = /^\\/(.*?)\\/(.*?)\\.(v2.json|js|ts)$/.exec(url.pathname);\n\n    if (\n      matches === null ||\n      matches.length !== 4 ||\n      typeof matches[1] === 'undefined' ||\n      typeof matches[2] === 'undefined'\n    ) {\n      throw new Error('Invalid param: \"options.metafile\" contains invalid metafile url.');\n    }\n\n    const cdnId: string = matches[1];\n    const tagId: string = matches[2];\n\n    return {\n      url: metafileUrl,\n      baseUrl: url.origin,\n      cdnId,\n      jsonPath: `/${cdnId}/${tagId}.v2.json`,\n    };\n  }\n}\n","import { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\n\nexport class MetafileContext {\n  public params: MetafileParams;\n\n  public parsedData: IMetafile | null;\n\n  public data: MetafileData;\n\n  constructor(options: CdnClientOptions) {\n    this.params = new MetafileParams(options.metafile);\n    this.parsedData = null;\n    this.data = MetafileData.createEmpty(this.params);\n  }\n\n  public setMetafile(metafile: IMetafile): void {\n    this.parsedData = metafile;\n\n    this.data = new MetafileData(metafile, this.params);\n  }\n}\n","import type { IHttpAdapter } from '@/interfaces/i-http-adapter.js';\n\nexport class FetchHttpAdapter implements IHttpAdapter {\n  protected baseUrl: string;\n\n  constructor(baseUrl: string) {\n    this.baseUrl = baseUrl;\n  }\n\n  async get(url: string): Promise<string | object> {\n    const response: Response = await fetch(`${this.baseUrl}${url}`);\n    const contentType: string | null = response.headers.get('content-type');\n    const isJson: boolean =\n      contentType === 'application/json5' || contentType === 'application/json';\n\n    if (response.status >= 400) {\n      throw new Error(`Request failed with status code ${response.status.toString()}`);\n    }\n\n    let result: string | object;\n\n    if (isJson) {\n      result = (await response.json()) as object;\n    } else {\n      result = await response.text();\n    }\n\n    return result;\n  }\n}\n","import type { Context } from '@/cdn/context/context.js';\n\nexport abstract class CdnBase {\n  protected context: Context;\n\n  constructor(context: Context) {\n    this.context = context;\n  }\n}\n","import { CdnBase } from '@/cdn/methods/cdn-base.js';\n\nexport class CdnCache extends CdnBase {\n  public flush = (): void => {\n    this.context.cache.flush();\n  };\n}\n","import type { MetafileData } from '@/cdn/metafile/metafile-data.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport { MetafileParams } from '@/cdn/metafile/metafile-params.js';\nimport { CdnBase } from '@/cdn/methods/cdn-base.js';\nimport type { IMetafile } from '@/interfaces/i-metafile.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\nimport type { CdnLocale } from '@/types/cdn-locale.js';\nimport type { CdnLocalesOptions } from '@/types/cdn-locales-options.js';\n\nexport class CdnMetafile extends CdnBase {\n  get projectUrl(): string {\n    return this.context.metafile.data.projectUrl;\n  }\n\n  get baseLocale(): CdnLocale {\n    return this.context.metafile.data.baseLocale;\n  }\n\n  get url(): string {\n    return this.context.metafile.params.url;\n  }\n\n  get files(): CdnFile[] {\n    return this.context.metafile.data.files.map((file: MetafileFile): CdnFile => file.toCdnFile());\n  }\n\n  public locales = (options?: CdnLocalesOptions): CdnLocale[] => {\n    const { excludeBaseLocale }: CdnLocalesOptions = options || {};\n    const { locales }: MetafileData = this.context.metafile.data;\n\n    return excludeBaseLocale\n      ? locales.filter((cdnLocale: CdnLocale): boolean => !cdnLocale.isBaseLocale)\n      : locales;\n  };\n\n  public refresh = async (): Promise<void> => {\n    const response: IMetafile = await this.context.api.fetchMetafile();\n\n    this.context.metafile.setMetafile(response);\n  };\n\n  public switch = async (options: CdnClientOptions): Promise<void> => {\n    this.context.metafile.params = new MetafileParams(options.metafile);\n\n    await this.refresh();\n  };\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { LocalesMapData } from '@/types/locales-map-data.js';\nimport type { LocalesMapOptions } from '@/types/locales-map-options.js';\n\nexport class LocalesMap {\n  public data: LocalesMapData;\n\n  protected context: Context;\n\n  constructor(options: LocalesMapOptions) {\n    this.context = options.context;\n    this.data = options.data || {};\n  }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport type { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport { LocalesMap } from '@/cdn/request/locales-map.js';\nimport type { ApiLocaleRequest } from '@/types/api-locale-request.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class Request {\n  public files: MetafileFile[];\n\n  public localesMap: LocalesMap;\n\n  public hasSingleFileResponse: boolean;\n\n  public hasSingleLocaleResponse: boolean;\n\n  protected context: Context;\n\n  constructor(context: Context) {\n    this.files = [];\n    this.localesMap = new LocalesMap({ context });\n    this.hasSingleFileResponse = false;\n    this.hasSingleLocaleResponse = false;\n    this.context = context;\n  }\n\n  public async execute(): Promise<CdnResponse> {\n    const payload: [Promise<string | object>, ApiLocaleRequest][] = this.getPromises();\n    const promises: Promise<string | object>[] = payload.map(\n      (item: [Promise<string | object>, ApiLocaleRequest]) => item[0],\n    );\n    const requests: ApiLocaleRequest[] = payload.map(\n      (item: [Promise<string | object>, ApiLocaleRequest]) => item[1],\n    );\n    const responses: (string | object)[] = await Promise.all(promises);\n\n    return this.context.responseFactory.createCdnResponse({\n      requests,\n      responses,\n      localesMap: this.localesMap,\n      hasSingleFileResponse: this.hasSingleFileResponse,\n      hasSingleLocaleResponse: this.hasSingleLocaleResponse,\n    });\n  }\n\n  protected getPromises(): [Promise<string | object>, ApiLocaleRequest][] {\n    return this.files.reduce(\n      (acc: [Promise<string | object>, ApiLocaleRequest][], cur: MetafileFile) => {\n        if (typeof this.localesMap.data?.[cur.id] !== 'undefined') {\n          acc.push(\n            ...this.localesMap.data[cur.id].map(\n              (metafileLocale: MetafileLocale): [Promise<string | object>, ApiLocaleRequest] => {\n                const request: ApiLocaleRequest = {\n                  metafileFile: cur,\n                  metafileLocale,\n                };\n\n                return [this.context.api.fetchLocale(request), request];\n              },\n            ),\n          );\n        }\n        return acc;\n      },\n      [],\n    );\n  }\n}\n","import type { Context } from '@/cdn/context/context.js';\nimport { MetafileFile } from '@/cdn/metafile/metafile-file.js';\nimport type { MetafileLocale } from '@/cdn/metafile/metafile-locale.js';\nimport type { LocalesMap } from '@/cdn/request/locales-map.js';\nimport { Request } from '@/cdn/request/request.js';\nimport { isArray, isPlainObject, isString, isUndefined } from '@/cdn/utils.js';\nimport type { IRequestBuilder } from '@/interfaces/i-request-builder.js';\nimport type { CdnFile } from '@/types/cdn-file.js';\n\nexport class RequestBuilder implements IRequestBuilder {\n  protected context: Context;\n\n  protected request: Request;\n\n  constructor(context: Context) {\n    this.context = context;\n    this.request = new Request(this.context);\n  }\n\n  public addFiles(files?: (CdnFile | string)[] | CdnFile | string): this {\n    if (!(isPlainObject(files) || isString(files) || isUndefined(files) || isArray(files))) {\n      throw new Error('Invalid param: \"request.files\" must be object, array, string or undefined.');\n    }\n\n    if (isArray(files)) {\n      files.forEach((i: CdnFile | string): void => {\n        if (!(isPlainObject(i) || isString(i))) {\n          throw new Error('Invalid param: array \"request.files\" must contain objects or strings.');\n        }\n      });\n    }\n\n    if (isString(files)) {\n      this.request.hasSingleFileResponse = true;\n\n      const file: MetafileFile | undefined = this.context.metafile.data.files.find(\n        (i: MetafileFile): boolean => i.id === files,\n      );\n\n      if (!(file instanceof MetafileFile)) {\n        throw new Error(`File not found: \"${files}\".`);\n      }\n\n      this.request.files = [file];\n    } else if (isUndefined(files)) {\n      this.request.files = [...this.context.metafile.data.files];\n    } else if (isArray(files)) {\n      this.request.files = files.map((file: CdnFile | string): MetafileFile => {\n        let metafileFile: MetafileFile;\n\n        if (isString(file)) {\n          const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n            (i: MetafileFile): boolean => i.id === file,\n          );\n\n          if (isUndefined(foundFile)) {\n            throw new Error(`File not found: \"${file}\".`);\n          }\n\n          metafileFile = foundFile;\n        } else {\n          const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n            (i: MetafileFile): boolean => i.id === file.id,\n          );\n\n          if (isUndefined(foundFile)) {\n            throw new Error(`File not found: \"${file.id}\".`);\n          }\n\n          metafileFile = foundFile;\n        }\n\n        return metafileFile;\n      });\n    } else if (isPlainObject(files)) {\n      this.request.hasSingleFileResponse = true;\n\n      const foundFile: MetafileFile | undefined = this.context.metafile.data.files.find(\n        (i: MetafileFile): boolean => i.id === files.id,\n      );\n\n      if (isUndefined(foundFile)) {\n        throw new Error(`File not found: \"${files.id}\".`);\n      }\n\n      this.request.files = [foundFile];\n    }\n\n    return this;\n  }\n\n  public addLocales(locales?: string[] | string, excludeBaseLocale?: boolean): this {\n    if (!(isString(locales) || isUndefined(locales) || isArray(locales))) {\n      throw new Error('Invalid param: \"request.locales\" must be array, string or undefined.');\n    }\n\n    if (isArray(locales)) {\n      locales.forEach((i: MetafileFile | string): void => {\n        if (!isString(i)) {\n          throw new Error('Invalid param: array \"request.locales\" must contain strings.');\n        }\n      });\n    }\n\n    if (isString(locales)) {\n      this.request.hasSingleLocaleResponse = true;\n      this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n        acc.data[cur.id] = cur.locales.filter(\n          (metafileLocale: MetafileLocale): boolean => metafileLocale.locale === locales,\n        );\n\n        return acc;\n      }, this.request.localesMap);\n    } else if (isUndefined(locales)) {\n      this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n        acc.data[cur.id] = excludeBaseLocale\n          ? cur.locales.filter(\n              (metafileLocale: MetafileLocale): boolean => !metafileLocale.isBaseLocale,\n            )\n          : cur.locales;\n\n        return acc;\n      }, this.request.localesMap);\n    } else if (isArray(locales)) {\n      this.request.files.reduce((acc: LocalesMap, cur: MetafileFile) => {\n        acc.data[cur.id] = cur.locales.filter((metafileLocale: MetafileLocale) =>\n          locales.includes(metafileLocale.locale),\n        );\n\n        return acc;\n      }, this.request.localesMap);\n    }\n\n    return this;\n  }\n\n  public getCdnRequest(): Request {\n    const result: Request = this.request;\n    this.request = new Request(this.context);\n    return result;\n  }\n}\n","import { Context } from '@/cdn/context/context.js';\nimport { MetafileContext } from '@/cdn/context/metafile-context.js';\nimport { FetchHttpAdapter } from '@/cdn/http/fetch-http-adapter.js';\nimport { CdnCache } from '@/cdn/methods/cdn-cache.js';\nimport { CdnMetafile } from '@/cdn/methods/cdn-metafile.js';\nimport { RequestBuilder } from '@/cdn/request/request-builder.js';\nimport { isString } from '@/cdn/utils.js';\nimport type { CdnClientOptions } from '@/types/cdn-client-options.js';\nimport type { CdnFetchOptions } from '@/types/cdn-fetch-options.js';\nimport type { CdnResponse } from '@/types/cdn-response.js';\n\nexport class CdnClient {\n  public metafile: CdnMetafile;\n\n  public cache: CdnCache;\n\n  protected context: Context;\n\n  public static version = '__CLIENT_VERSION__';\n\n  protected constructor(options: CdnClientOptions) {\n    const metafileContext: MetafileContext = new MetafileContext(options);\n    const client: FetchHttpAdapter = new FetchHttpAdapter(metafileContext.params.baseUrl);\n\n    this.context = new Context({ metafileContext, cdn: this, client });\n    this.metafile = new CdnMetafile(this.context);\n    this.cache = new CdnCache(this.context);\n  }\n\n  public fetch = async (options?: CdnFetchOptions): Promise<CdnResponse> => {\n    const { files, locales, excludeBaseLocale }: CdnFetchOptions = options || {};\n    const requestBuilder: RequestBuilder = new RequestBuilder(this.context)\n      .addFiles(files)\n      .addLocales(locales, excludeBaseLocale);\n\n    return requestBuilder.getCdnRequest().execute();\n  };\n\n  public static async create(options: CdnClientOptions): Promise<CdnClient> {\n    if (!options) {\n      throw new Error('Invalid param: missing required \"options\" parameter.');\n    }\n\n    if (!isString(options.metafile)) {\n      throw new Error('Invalid param: \"options.metafile\" must be string.');\n    }\n\n    const cdn: CdnClient = new CdnClient(options);\n\n    await cdn.metafile.refresh();\n\n    return cdn;\n  }\n}\n"],"mappings":";;;;;AAIA,IAAa,MAAb,MAAiB;CACf;CAEA,YAAY,SAAkB;EAC5B,KAAK,UAAU;CACjB;CAEA,MAAa,YAAY,SAAqD;EAC5E,IAAI,KAAK,QAAQ,MAAM,IAAI,OAAO,GAChC,OAAO,IAAI,SAAS,YAAkB;GACpC,QAAQ,KAAK,QAAQ,MAAM,IAAI,OAAO,CAAoB;EAC5D,CAAC;EAGH,OAAO,KAAK,QAAQ,OAAO,IAAI,QAAQ,eAAe,GAAG;CAC3D;CAEA,MAAa,gBAAoC;EAC/C,OAAQ,MAAM,KAAK,QAAQ,OAAO,IAAI,KAAK,QAAQ,SAAS,OAAO,QAAQ;CAC7E;AACF;;;ACtBA,IAAa,qBAAb,MAAqE;CACnE;CAEA,cAAc;EACZ,KAAK,sBAAM,IAAI,IAAI;CACrB;CAEA,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