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/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@xmcl/system@2.2.9/dist/index.browser.mjs\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export abstract class FileSystem {\n  abstract readonly root: string\n  abstract readonly sep: string\n  abstract readonly type: 'zip' | 'path'\n  abstract readonly writeable: boolean\n\n  // base methods\n\n  abstract join(...paths: string[]): string\n\n  abstract isDirectory(name: string): Promise<boolean>\n  abstract existsFile(name: string): Promise<boolean>\n  abstract readFile(name: string, encoding: 'utf-8' | 'base64'): Promise<string>\n  abstract readFile(name: string, encoding: undefined): Promise<Uint8Array>\n  abstract readFile(name: string): Promise<Uint8Array>\n  abstract readFile(name: string, encoding?: 'utf-8' | 'base64'): Promise<Uint8Array | string>\n\n  /**\n     * Get the url for a file entry. If the system does not support get url. This should return an empty string.\n     */\n  getUrl(name: string): string { return '' }\n\n  abstract listFiles(name: string): Promise<string[]>\n\n  abstract cd(name: string): void\n\n  isClosed(): boolean { return false }\n  close(): void { }\n\n  // extension methods\n\n  async missingFile(name: string) {\n    return this.existsFile(name).then((v) => !v)\n  }\n\n  async walkFiles(target: string, walker: (path: string) => void | Promise<void>) {\n    if (await this.isDirectory(target)) {\n      const childs = await this.listFiles(target)\n      for (const child of childs) {\n        await this.walkFiles(this.join(target, child), walker)\n      }\n    } else {\n      const result = walker(this.join(target))\n      if (result instanceof Promise) {\n        await result\n      }\n    }\n  }\n}\n","import { FileSystem } from './system'\nimport JSZip from 'jszip'\n\nclass JSZipFS extends FileSystem {\n  sep = '/'\n  type: 'zip' | 'path' = 'zip'\n  writeable = true\n  root = ''\n\n  protected normalizePath(path: string): string {\n    if (path.startsWith('/')) {\n      path = path.substring(1)\n    }\n    if (this.root !== '') {\n      path = [this.root, path].join('/')\n    }\n    return path\n  }\n\n  join(...paths: string[]): string {\n    return paths.join('/')\n  }\n\n  isDirectory(name: string): Promise<boolean> {\n    name = this.normalizePath(name)\n    name = name.endsWith('/') ? name : name + '/'\n    return Promise.resolve(Object.keys(this.zip.files).some((e) => e.startsWith(name)))\n  }\n\n  async writeFile(name: string, data: Uint8Array): Promise<void> {\n    name = this.normalizePath(name)\n    this.zip.file(name, data)\n  }\n\n  existsFile(name: string): Promise<boolean> {\n    name = this.normalizePath(name)\n    if (this.zip.files[name] !== undefined) { return Promise.resolve(true) }\n    return this.isDirectory(name)\n  }\n\n  readFile(name: any, encoding?: any): Promise<any> {\n    name = this.normalizePath(name)\n    if (!encoding) {\n      return this.zip.files[name].async('uint8array')\n    }\n    if (encoding === 'utf-8') {\n      return this.zip.files[name].async('text')\n    }\n    if (encoding === 'base64') {\n      return this.zip.files[name].async('base64')\n    }\n    throw new TypeError(`Expect encoding to be utf-8/base64 or empty. Got ${encoding}.`)\n  }\n\n  async listFiles(name: string): Promise<string[]> {\n    if (!await this.isDirectory(name)) { return Promise.reject(new TypeError('Require a directory!')) }\n    name = this.normalizePath(name)\n    return Promise.resolve(Object.keys(this.zip.files)\n      .filter((e) => e.startsWith(name))\n      .map((e) => e.substring(name.length))\n      .map((e) => e.startsWith('/') ? e.substring(1) : e)\n      .map((e) => e.split('/')[0]))\n  }\n\n  cd(name: string): void {\n    if (name.startsWith('/')) {\n      this.root = name.substring(1)\n      return\n    }\n    const paths = name.split('/')\n    for (const path of paths) {\n      if (path === '.') {\n        continue\n      } else if (path === '..') {\n        const sub = this.root.split('/')\n        if (sub.length > 0) {\n          sub.pop()\n          this.root = sub.join('/')\n        }\n      } else {\n        if (this.root === '') {\n          this.root = path\n        } else {\n          this.root += `/${path}`\n        }\n      }\n    }\n  }\n\n  constructor(private zip: JSZip) { super() }\n}\n\nexport async function openFileSystem(basePath: string | Uint8Array): Promise<FileSystem> {\n  if (typeof basePath === 'string') { throw new Error('Unsupported') }\n  return new JSZipFS(await JSZip.loadAsync(basePath))\n}\nexport function resolveFileSystem(base: string | Uint8Array | FileSystem): Promise<FileSystem> {\n  if (typeof base === 'string' || base instanceof Uint8Array) {\n    return openFileSystem(base)\n  } else {\n    return Promise.resolve(base)\n  }\n}\n\nexport * from './system'\n"]}