{"version":3,"sources":["jsdelivr-header.js","/npm/@inpageedit/core@0.16.0/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,yNCoBA,eAAe,EACb,EAGI,CAAE,QAAS,IAA8B,eAE7C,MAAQ,UAAS,WAAY,GAAQ,EAGJ,mBAAtB,QAAQ,KAAK,YAEhB,OAAO,IAAI,OAGnB,MAAM,EAAqB,OAAe,YAAc,GAClD,EAAM,IAAI,EAAI,CAClB,WAAY,CACV,WAEF,kBAAmB,GAAc,eAAiB,KAepD,GAXA,OAAO,IAAM,QAGP,EAAI,QAGV,OAAO,IAAI,MAAK,KACd,GAAG,KAAK,oBAAoB,KAAK,EAAG,IAIlC,MAAM,QAAQ,OAAO,iBAAkB,CACzC,MAAM,EAAmB,GACzB,KAAO,OAAO,gBAAgB,QAC5B,IACE,MAAM,EAAU,OAAO,gBAAgB,QACpB,mBAAZ,GAA0B,IAAU,GAC3C,EAAiB,KAAK,EACxB,OAEA,CAEF,OAAO,gBAAkB,CACvB,KAAO,IACc,mBAAZ,GAA0B,EAAQ,GACzC,EAAiB,KAAK,EAAO,GAGjC,EAAI,GAAG,WAAW,KAChB,OAAO,gBAAkB,IAE7B,CAGA,EAAI,OAAO,YAAY,KACrB,kVAEE,EAAI,QACJ,0BACiB,2BACA,EAAU,kCACV,EAAU,aAEjC,CAEA,SAAS,IACP,MAAM,EACuE,OAA3E,SAAS,cAAc,gDACnB,EAAU,SACb,cAA+B,wBAC9B,MAAM,MAAM,KAAK,GACrB,OAAO,GAAe,EAAU,OAAU,CAC5C,CAEA,SAAS,EAAQ,EAAa,GAC5B,MAAM,EAAM,OAAO,IAAI,GACvB,OAAK,OAAe,KAGlB,OAAe,IAAO,EACxB,KACO,EACT,CAlGA,OAAO,MAAQ,GACf,OAAO,kBAAoB,GAG3B,EAAQ,uBAAuB,KAC7B,MAAM,EAAU,IACZ,GACF,EAAS,CACP,UACA,cACD,W","file":"/npm/@inpageedit/core@0.16.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@inpageedit/core@0.16.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Web-autoloader entry point\n *\n * For forward compatibility, do not change the file name\n * If you are building a library, please use the `@inpageedit/core/core` entry point\n */\n\nimport { InPageEdit } from './core.js'\n\n// re-export all\nexport * from './core.js'\n\n// Safe guard\nwindow.RLQ ||= []\nwindow.__IPE_MODULES__ ||= []\n\n// Auto load if the site is MediaWiki\nrunOnce('InPageEdit#autoload', () => {\n  const baseURL = detectMediaWikiApiEndpoint()\n  if (baseURL) {\n    autoload({\n      baseURL,\n      InPageEdit,\n    })\n  }\n})\nasync function autoload(\n  _overload: {\n    baseURL?: string\n    InPageEdit: typeof InPageEdit\n  } = { baseURL: detectMediaWikiApiEndpoint(), InPageEdit: InPageEdit }\n) {\n  const { baseURL, InPageEdit: IPE } = _overload\n\n  // 防止多次运行\n  if (typeof window?.ipe?.stop === 'function') {\n    console.warn('[InPageEdit] Already loaded, disposing...')\n    await window.ipe.stop()\n  }\n\n  const oldGlobalVar: any = (window as any).InPageEdit || {}\n  const ipe = new IPE({\n    apiConfigs: {\n      baseURL,\n    },\n    legacyPreferences: oldGlobalVar?.myPreferences || {},\n  })\n\n  // Merge into global variables\n  window.ipe = ipe\n\n  // Start the App\n  await ipe.start()\n\n  // Trigger the mw.hook\n  window.RLQ.push(() => {\n    mw.hook('InPageEdit.ready').fire(ipe)\n  })\n\n  // Initialize global modules\n  if (Array.isArray(window.__IPE_MODULES__)) {\n    const installedModules = [] as any[]\n    while (window.__IPE_MODULES__.length) {\n      try {\n        const payload = window.__IPE_MODULES__.shift()\n        typeof payload === 'function' && payload?.(ipe)\n        installedModules.push(payload)\n      } catch (error) {\n        console.error('[InPageEdit] Failed to initialize module:', error)\n      }\n    }\n    window.__IPE_MODULES__ = {\n      push: (payload) => {\n        typeof payload === 'function' && payload(ipe)\n        installedModules.push(payload)\n      },\n    }\n    ipe.on('dispose', () => {\n      window.__IPE_MODULES__ = installedModules\n    })\n  }\n\n  // 花里胡哨的加载提示\n  ipe.logger('AUTOLOAD').info(\n    '\\n' +\n      '    ____      ____                   ______    ___ __ \\n   /  _/___  / __ \\\\____ _____ ____  / ____/___/ (_) /_\\n   / // __ \\\\/ /_/ / __ `/ __ `/ _ \\\\/ __/ / __  / / __/\\n _/ // / / / ____/ /_/ / /_/ /  __/ /___/ /_/ / / /_  \\n/___/_/ /_/_/    \\\\__,_/\\\\__, /\\\\___/_____/\\\\__,_/_/\\\\__/  \\n                      /____/                v' +\n      ipe.version +\n      `\n- Wiki API Endpoint: ${baseURL}\n- Documentation:     ${Endpoints.HOME_URL}\n- Bug Reports:       ${Endpoints.GITHUB_URL}`\n  )\n}\n\nfunction detectMediaWikiApiEndpoint(): string | undefined {\n  const isMediaWiki =\n    document.querySelector('meta[name=\"generator\"][content^=\"MediaWiki\"]') !== null\n  const apiBase = document\n    .querySelector<HTMLLinkElement>('link[rel=\"EditURI\"]')\n    ?.href?.split('?')[0]\n  return isMediaWiki && apiBase ? apiBase : undefined\n}\n\nfunction runOnce(key: string, fn: Function) {\n  const sym = Symbol.for(key)\n  if ((window as any)[sym]) {\n    return false\n  }\n  ;(window as any)[sym] = true\n  fn()\n  return true\n}\n\n// HMR\nif (import.meta.hot) {\n  const SEPARATOR = `\\n${'='.repeat(20)} [InPageEdit] HMR ${'='.repeat(20)}\\n`\n  import.meta.hot.accept(async (modules) => {\n    const apiBase = detectMediaWikiApiEndpoint()!\n    const IPE = modules?.InPageEdit as unknown as typeof InPageEdit\n    if (!apiBase || !IPE) {\n      console.warn(SEPARATOR.trimStart(), 'missing modules', SEPARATOR.trimEnd())\n      location.reload()\n      return\n    }\n\n    console.info(SEPARATOR.trimStart(), \"I'm so hot!\", modules, SEPARATOR.trimEnd())\n    await window?.ipe?.stop()\n    window.ipe = undefined as any\n    autoload({\n      baseURL: apiBase,\n      InPageEdit: IPE,\n    })\n  })\n}\n\n// 类型定义\n\n// Global types declaration\ndeclare global {\n  const ipe: InPageEdit\n  interface Window {\n    ipe: InPageEdit\n    __IPE_MODULES__: {\n      push(payload: (ipe: InPageEdit) => void): void\n    }\n  }\n}\n\n// MediaWiki ResourceLoader Queue\ndeclare global {\n  interface Window {\n    RLQ: {\n      push(callback: () => void): void\n      push(depAndCallback: [string, () => void]): void\n      push(depsAndCallback: [string[], () => void]): void\n    }\n  }\n}\n\n// declare mw.hook\ndeclare global {\n  namespace mw {\n    /**\n     * @see https://doc.wikimedia.org/mediawiki-core/master/js/Hook.html\n     * @see https://github.com/wikimedia-gadgets/types-mediawiki/blob/9b4e7c3b9034d64a44a0667229a6d9585fe09b30/mw/hook.d.ts\n     */\n    interface Hook<T extends any[] = any[]> {\n      add(...handler: Array<(...data: T) => any>): this\n      deprecate(msg: string): this\n      fire(...data: T): this\n      remove(...handler: Array<(...data: T) => any>): this\n    }\n    function hook(name: 'InPageEdit.ready'): Hook<[InPageEdit]>\n  }\n}\n"]}