@elementspanel/panel 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +6 -2
  3. package/app.js +6400 -0
  4. package/app.js.map +1 -0
  5. package/bin/panel.cjs +2 -0
  6. package/package.json +107 -4
  7. package/public/assets/AppDialog.vue_vue_type_style_index_0_lang-e6e38e8b.js +2 -0
  8. package/public/assets/AppDialog.vue_vue_type_style_index_0_lang-e6e38e8b.js.map +1 -0
  9. package/public/assets/CardPanel-59b7da2e.js +2 -0
  10. package/public/assets/CardPanel-59b7da2e.js.map +1 -0
  11. package/public/assets/DesktopDialog-e4041e4e.js +2 -0
  12. package/public/assets/DesktopDialog-e4041e4e.js.map +1 -0
  13. package/public/assets/Loading.vue_vue_type_script_setup_true_lang-1b74dd54.js +2 -0
  14. package/public/assets/Loading.vue_vue_type_script_setup_true_lang-1b74dd54.js.map +1 -0
  15. package/public/assets/PageToolbar-7130e13d.js +2 -0
  16. package/public/assets/PageToolbar-7130e13d.js.map +1 -0
  17. package/public/assets/_elements-sdk_cordis-b0b88a2c.js +2 -0
  18. package/public/assets/_elements-sdk_cordis-b0b88a2c.js.map +1 -0
  19. package/public/assets/_elements-sdk_cordis-e3bebc89.js +9 -0
  20. package/public/assets/_elements-sdk_cordis-e3bebc89.js.map +1 -0
  21. package/public/assets/_elements-sdk_cosmokit-e4842f5c.js +2 -0
  22. package/public/assets/_elements-sdk_cosmokit-e4842f5c.js.map +1 -0
  23. package/public/assets/_elements-sdk_pinia-2c56d2c1.js +6 -0
  24. package/public/assets/_elements-sdk_pinia-2c56d2c1.js.map +1 -0
  25. package/public/assets/_elements-sdk_vue-80f42d87.js +2 -0
  26. package/public/assets/_elements-sdk_vue-80f42d87.js.map +1 -0
  27. package/public/assets/_elements-sdk_vue-i18n-4b8a106a.js +2 -0
  28. package/public/assets/_elements-sdk_vue-i18n-4b8a106a.js.map +1 -0
  29. package/public/assets/_elements-sdk_vue-router-a171591a.js +2 -0
  30. package/public/assets/_elements-sdk_vue-router-a171591a.js.map +1 -0
  31. package/public/assets/_plugin-vue_export-helper-c27b6911.js +2 -0
  32. package/public/assets/_plugin-vue_export-helper-c27b6911.js.map +1 -0
  33. package/public/assets/chartjs-1e331dfb.js +19 -0
  34. package/public/assets/chartjs-1e331dfb.js.map +1 -0
  35. package/public/assets/codemirror-1b74112a.js +29 -0
  36. package/public/assets/codemirror-1b74112a.js.map +1 -0
  37. package/public/assets/const-93b324c0.js +2 -0
  38. package/public/assets/const-93b324c0.js.map +1 -0
  39. package/public/assets/const-ea30795c.js +38 -0
  40. package/public/assets/const-ea30795c.js.map +1 -0
  41. package/public/assets/context-cc90576e.js +2 -0
  42. package/public/assets/context-cc90576e.js.map +1 -0
  43. package/public/assets/copy-b106bb10.js +2 -0
  44. package/public/assets/copy-b106bb10.js.map +1 -0
  45. package/public/assets/core-d3bfdede.js +2 -0
  46. package/public/assets/core-d3bfdede.js.map +1 -0
  47. package/public/assets/daemon_connection_error-9eb654cc.png +0 -0
  48. package/public/assets/dayjs.min-25183c0a.js +2 -0
  49. package/public/assets/dayjs.min-25183c0a.js.map +1 -0
  50. package/public/assets/desktopNotice-5ca3448c.js +2 -0
  51. package/public/assets/desktopNotice-5ca3448c.js.map +1 -0
  52. package/public/assets/dom-ff483262.js +2 -0
  53. package/public/assets/dom-ff483262.js.map +1 -0
  54. package/public/assets/htmlparser2-bcb8f9db.js +3 -0
  55. package/public/assets/htmlparser2-bcb8f9db.js.map +1 -0
  56. package/public/assets/i18n-e810b9fa.js +2 -0
  57. package/public/assets/i18n-e810b9fa.js.map +1 -0
  58. package/public/assets/index-6e8d74f8.js +2 -0
  59. package/public/assets/index-6e8d74f8.js.map +1 -0
  60. package/public/assets/index-c684efbd.js +2 -0
  61. package/public/assets/index-c684efbd.js.map +1 -0
  62. package/public/assets/index-e3f35709.js +2 -0
  63. package/public/assets/index-e3f35709.js.map +1 -0
  64. package/public/assets/instance-cc59e210.js +2 -0
  65. package/public/assets/instance-cc59e210.js.map +1 -0
  66. package/public/assets/instance_contract-0115efe5.js +2 -0
  67. package/public/assets/instance_contract-0115efe5.js.map +1 -0
  68. package/public/assets/lodash-001e4f93.js +28 -0
  69. package/public/assets/lodash-001e4f93.js.map +1 -0
  70. package/public/assets/logo-9e2a668b.svg +15 -0
  71. package/public/assets/logo_b-35ccadda.svg +8 -0
  72. package/public/assets/materialdesignicons-webfont-0b183104.eot +0 -0
  73. package/public/assets/materialdesignicons-webfont-61e8aba5.ttf +0 -0
  74. package/public/assets/materialdesignicons-webfont-662fefa8.woff2 +0 -0
  75. package/public/assets/materialdesignicons-webfont-a5928a0d.woff +0 -0
  76. package/public/assets/msl-logo-699c8076.png +0 -0
  77. package/public/assets/nodes-a56b1b35.js +2 -0
  78. package/public/assets/nodes-a56b1b35.js.map +1 -0
  79. package/public/assets/plugin_contract-691cd37a.js +2 -0
  80. package/public/assets/plugin_contract-691cd37a.js.map +1 -0
  81. package/public/assets/preload-helper-a4192956.js +2 -0
  82. package/public/assets/preload-helper-a4192956.js.map +1 -0
  83. package/public/assets/protocol-97f7bab7.js +2 -0
  84. package/public/assets/protocol-97f7bab7.js.map +1 -0
  85. package/public/assets/randId-56f93901.js +2 -0
  86. package/public/assets/randId-56f93901.js.map +1 -0
  87. package/public/assets/router-eff205cc.js +3 -0
  88. package/public/assets/router-eff205cc.js.map +1 -0
  89. package/public/assets/safe-87846d89.js +89 -0
  90. package/public/assets/safe-87846d89.js.map +1 -0
  91. package/public/assets/sdk-3f2277ab.js +2 -0
  92. package/public/assets/sdk-3f2277ab.js.map +1 -0
  93. package/public/assets/shared-597ef52b.js +2 -0
  94. package/public/assets/shared-597ef52b.js.map +1 -0
  95. package/public/assets/useAppConfigStore-352fe033.js +2 -0
  96. package/public/assets/useAppConfigStore-352fe033.js.map +1 -0
  97. package/public/assets/useAppRouters-747b627a.js +2 -0
  98. package/public/assets/useAppRouters-747b627a.js.map +1 -0
  99. package/public/assets/useAppStateStore-a438b9a6.js +2 -0
  100. package/public/assets/useAppStateStore-a438b9a6.js.map +1 -0
  101. package/public/assets/useAppToolsStore-288c4fe8.js +2 -0
  102. package/public/assets/useAppToolsStore-288c4fe8.js.map +1 -0
  103. package/public/assets/useDefineApi-b726db1e.js +7 -0
  104. package/public/assets/useDefineApi-b726db1e.js.map +1 -0
  105. package/public/assets/useInstanceActionAvailability-16de3001.js +2 -0
  106. package/public/assets/useInstanceActionAvailability-16de3001.js.map +1 -0
  107. package/public/assets/useKeyboardEvents-6f7f845c.js +2 -0
  108. package/public/assets/useKeyboardEvents-6f7f845c.js.map +1 -0
  109. package/public/assets/useMountComponent-4043cb4c.js +2 -0
  110. package/public/assets/useMountComponent-4043cb4c.js.map +1 -0
  111. package/public/assets/useOverviewChart-7d758bc4.js +2 -0
  112. package/public/assets/useOverviewChart-7d758bc4.js.map +1 -0
  113. package/public/assets/useOverviewInfo-9ca25ab9.js +2 -0
  114. package/public/assets/useOverviewInfo-9ca25ab9.js.map +1 -0
  115. package/public/assets/usePolling-1bc2009b.js +2 -0
  116. package/public/assets/usePolling-1bc2009b.js.map +1 -0
  117. package/public/assets/useScreen-fad29b7c.js +2 -0
  118. package/public/assets/useScreen-fad29b7c.js.map +1 -0
  119. package/public/assets/useSocketIo-ea3c9a61.js +2 -0
  120. package/public/assets/useSocketIo-ea3c9a61.js.map +1 -0
  121. package/public/assets/useThemeSwitch-dc70883c.js +2 -0
  122. package/public/assets/useThemeSwitch-dc70883c.js.map +1 -0
  123. package/public/assets/vue-4c6a2976.css +1 -0
  124. package/public/assets/vue-6b52a630.js +64 -0
  125. package/public/assets/vue-6b52a630.js.map +1 -0
  126. package/public/assets/vuetifyModal-8382b175.js +2 -0
  127. package/public/assets/vuetifyModal-8382b175.js.map +1 -0
  128. package/public/assets/xterm-62ba073f.js +67 -0
  129. package/public/assets/xterm-62ba073f.js.map +1 -0
  130. package/public/favicon.ico +0 -0
  131. package/public/index.html +207 -0
  132. package/public/robots.txt +2 -0
  133. package/public/stats.html +4950 -0
  134. package/runtime/cli.cjs +305 -0
  135. package/runtime/daemon-tools.cjs +113 -0
  136. package/runtime/npm-plugins.cjs +207 -0
  137. package/runtime/plugin-resolution.cjs +141 -0
  138. package/runtime/shared-dependencies.cjs +35 -0
  139. package/runtime/worker.cjs +25 -0
@@ -0,0 +1,2 @@
1
+ import{c as e}from"./context-cc90576e.js";const i="LANGUAGE";function o(n){return n?n.trim().replace(/-/g,"_").toLowerCase():"en_us"}function t(){const n=e.get("i18n");if(!n)throw new Error('Panel frontend plugin "i18n" is not loaded.');return n}function u(){return t().instance}function c(n,r=!0){t().setLanguage(n,r)}function g(){return t().getCurrentLang()}function f(){return t().isCN()}function a(...n){return t().translate(...n)}const L=a;export{i as L,o as a,u as b,g,f as i,c as s,L as t};
2
+ //# sourceMappingURL=i18n-e810b9fa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-e810b9fa.js","sources":["../../../../plugins/i18n/panel/src/lang/i18n.ts"],"sourcesContent":["import type { I18n } from \"vue-i18n\";\nimport { ctx } from \"@/plugin/context\";\nimport type { FrontendI18nService, PanelLanguageOption } from \"@/plugin\";\n\nexport const LANGUAGE_KEY = \"LANGUAGE\";\n\nexport function toStandardLang(language?: string) {\n if (!language) return \"en_us\";\n return language.trim().replace(/-/g, \"_\").toLowerCase();\n}\n\nfunction service(): FrontendI18nService {\n const i18n = ctx.get(\"i18n\");\n if (!i18n) throw new Error('Panel frontend plugin \"i18n\" is not loaded.');\n return i18n;\n}\n\nexport function getI18nInstance(): I18n {\n return service().instance;\n}\n\nexport function getSupportedLanguageOptions(): readonly PanelLanguageOption[] {\n return service().supportedLanguages;\n}\n\nexport function getSupportLanguages(): string[] {\n return service().getSupportLanguages();\n}\n\nexport function searchSupportLanguage(language: string): string {\n return service().searchSupportLanguage(language);\n}\n\nexport function setLanguage(language: string, reload = true): void {\n service().setLanguage(language, reload);\n}\n\nexport function getCurrentLang(): string {\n return service().getCurrentLang();\n}\n\nexport function isCN(): boolean {\n return service().isCN();\n}\n\nexport function isEN(): boolean {\n return service().isEN();\n}\n\nexport function $t(...args: any[]): string {\n return service().translate(...args);\n}\n\nexport const t = $t;\n"],"names":["LANGUAGE_KEY","toStandardLang","language","service","i18n","ctx","getI18nInstance","setLanguage","reload","getCurrentLang","isCN","$t","args","t"],"mappings":"0CAIO,MAAMA,EAAe,WAErB,SAASC,EAAeC,EAAmB,CAChD,OAAKA,EACEA,EAAS,OAAO,QAAQ,KAAM,GAAG,EAAE,cADpB,OAExB,CAEA,SAASC,GAA+B,CAChC,MAAAC,EAAOC,EAAI,IAAI,MAAM,EAC3B,GAAI,CAACD,EAAY,MAAA,IAAI,MAAM,6CAA6C,EACjE,OAAAA,CACT,CAEO,SAASE,GAAwB,CACtC,OAAOH,EAAU,EAAA,QACnB,CAcgB,SAAAI,EAAYL,EAAkBM,EAAS,GAAY,CACzDL,IAAE,YAAYD,EAAUM,CAAM,CACxC,CAEO,SAASC,GAAyB,CAChC,OAAAN,EAAA,EAAU,gBACnB,CAEO,SAASO,GAAgB,CACvB,OAAAP,EAAA,EAAU,MACnB,CAMO,SAASQ,KAAMC,EAAqB,CACzC,OAAOT,EAAQ,EAAE,UAAU,GAAGS,CAAI,CACpC,CAEO,MAAMC,EAAIF"}
@@ -0,0 +1,2 @@
1
+ import{c as d}from"./context-cc90576e.js";import{_ as B}from"./preload-helper-a4192956.js";import{c as M,v as U,r as J}from"./plugin_contract-691cd37a.js";import{bA as b}from"./vue-6b52a630.js";import"./_elements-sdk_cordis-e3bebc89.js";import"./_elements-sdk_cosmokit-e4842f5c.js";import"./htmlparser2-bcb8f9db.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const n of i)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function r(i){const n={};return i.integrity&&(n.integrity=i.integrity),i.referrerPolicy&&(n.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?n.credentials="include":i.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function a(i){if(i.ep)return;i.ep=!0;const n=r(i);fetch(i.href,n)}})();function G(e){const t=new Set,r=[],a=new WeakSet,i=new WeakSet,n=o=>{if(i.has(o))return;i.add(o);const c=o.reset;o.reset=function(){return this.disposables=this.disposables.map(l=>{if(a.has(l))return l;const m=(...s)=>{let f;try{f=l(...s)}catch(p){throw r.push(p),p}if(f&&typeof f.then=="function"){const p=Promise.resolve(f).catch(w=>{r.push(w)}).finally(()=>t.delete(p));t.add(p)}return f};for(const s of Object.getOwnPropertySymbols(l))Object.defineProperty(m,s,Object.getOwnPropertyDescriptor(l,s));return a.add(m),m}),c.call(this)}};return e.on("internal/runtime",n),e.on("internal/fork",n),async()=>{do await e.events.flush(),await Promise.all([...t]);while(t.size);if(r.length){const o=r.splice(0);throw new Error(`Plugin cleanup failed: ${o.map(String).join("; ")}`)}}}const N={runtime:"startup",i18n:"i18n",console:"console"},y=new Set(Object.keys(N)),P=M(),_=G(d),u=b([]),g=new Map;function D(e,t){return(Number(e.metadata.priority)||0)-(Number(t.metadata.priority)||0)||e.metadata.id.localeCompare(t.metadata.id)}function H(e){return Array.isArray(e.inject)?[...new Set(e.inject)]:e.inject?Object.entries(e.inject).filter(([,t])=>t==null?void 0:t.required).map(([t])=>t):[]}function V(e){if(!e||e.error||e.runtime.error)return"failed";switch(e.status){case 0:return"pending";case 1:return"loading";case 2:return"active";case 3:case 4:return"failed";default:return"pending"}}function W(e){e.missingServices=e.requiredServices.filter(t=>!d.get(t)),e.state=e.restartRequired||e.reloadRequired?"restart-required":e.error?"failed":V(e.fork)}function Q(e){var r,a;const t=e.error||((r=e.fork)==null?void 0:r.error)||((a=e.fork)==null?void 0:a.runtime.error);if(t!=null)return t instanceof Error?t:new Error(String(t))}function h(){for(const e of u)W(e)}d.on("internal/status",e=>{u.find(r=>r.fork===e)&&h()});function T(e){const t=typeof e.id=="string"?e.id.trim():"";return t?{...e,id:t}:null}function K(e,t){for(const r of[e,e==null?void 0:e.default])if(!(typeof r!="object"||r===null)&&typeof r.apply=="function")return r;d.logger("plugin").warn(`Panel frontend plugin "${t}" must export an apply() function.`)}async function X(e){const t=[];try{await Promise.all((e.styles||[]).map(r=>new Promise((a,i)=>{const n=document.createElement("link");n.rel="stylesheet",n.href=r,n.dataset.panelPlugin=e.metadata.id,n.addEventListener("load",()=>a(),{once:!0}),n.addEventListener("error",()=>i(new Error(`Failed to load panel plugin stylesheet: ${r}`)),{once:!0}),document.head.appendChild(n),t.push(n)})))}catch(r){throw t.forEach(a=>a.remove()),r}return()=>t.forEach(r=>r.remove())}function Y(e){document.querySelectorAll(`style[data-panel-plugin=${JSON.stringify(e.metadata.id)}]`).forEach(t=>t.remove());for(const t of e.styles||[]){const r=new URL(t,document.baseURI).href;document.querySelectorAll("link[rel='stylesheet']").forEach(a=>{try{new URL(a.href,document.baseURI).href===r&&a.remove()}catch{}})}}async function Z(){const e=new URL("plugins/manifest.json",document.baseURI),t=await fetch(e.href,{cache:"no-store"});if(!t.ok){if(t.status===404)return[];throw new Error(`Failed to load panel plugin manifest: HTTP ${t.status}`)}const r=await t.json(),a=Array.isArray(r)?r:r==null?void 0:r.data;if(!Array.isArray(a))throw new Error("Invalid panel plugin manifest.");const i=o=>new URL(o,e).href,n=[];for(const o of a){if(!o||typeof o!="object"||Array.isArray(o))continue;const c=T(o.metadata||o),l=typeof o.entry=="string"?o.entry:"";if(!c||c.enabled===!1||!l)continue;const m=i(l);n.push({metadata:c,directory:typeof o.directory=="string"?o.directory:c.id,assetDirectory:typeof o.assetDirectory=="string"?o.assetDirectory:c.id,entry:m,revision:typeof o.revision=="string"?o.revision:String(c.version||""),styles:Array.isArray(o.styles)?o.styles.filter(s=>typeof s=="string").map(i):[],load:async s=>{const f=new URL(m);return s&&f.searchParams.set("panel_plugin_reload",s),B(()=>import(f.href),[],import.meta.url)}})}return n}async function O(){const e=await Z(),t=new Map;for(const r of e){const a=T(r.metadata);!a||a.enabled===!1||t.has(a.id)||t.set(a.id,{...r,metadata:a})}return[...t.values()].sort(D)}function C(e){return J(e,{id:t=>t.metadata.id,dependencies:t=>t.metadata.frontendInject,compare:D})}function ee(e){const t=[];for(const r of C(e).ordered){try{U(r.metadata.elements)}catch{continue}if(r.metadata.restartRequired||!r.entry)continue;const a=document.createElement("link");a.rel="modulepreload",a.href=r.entry,a.crossOrigin="anonymous",document.head.appendChild(a),t.push(a);for(const i of r.styles||[]){const n=document.createElement("link");n.rel="preload",n.setAttribute("as","style"),n.href=i,document.head.appendChild(n),t.push(n)}}return()=>t.forEach(r=>r.remove())}async function F(e,t){let r;try{if(U(e.metadata.elements),e.metadata.restartRequired)throw new Error("The plugin backend requires a restart before this version can load.");const[a,i]=await Promise.allSettled([X(e),Promise.resolve().then(()=>e.load(t))]);if(a.status==="rejected")throw a.reason;if(r=a.value,i.status==="rejected")throw i.reason;const n=K(i.value,e.metadata.id);if(!n)throw new Error(`Panel frontend plugin has no apply() export: ${e.metadata.id}`);return{module:n,removeStyles:r}}catch(a){return r==null||r(),{error:a instanceof Error?a:new Error(String(a))}}}function x(e,t){const r=u.find(i=>i.metadata.id===e.metadata.id);if(r)return r.error=t,r.state="failed",h(),r;const a=b({source:e,metadata:e.metadata,directory:e.directory,revision:e.revision,state:"failed",requiredServices:[],missingServices:[],error:t});return u.push(a),h(),a}async function E(e,t,r,a){var c,l,m;const i=u.find(s=>s.metadata.id===e.metadata.id);if(i)return i;const n=(e.metadata.frontendInject||[]).filter(s=>{var f;return((f=u.find(p=>p.metadata.id===s))==null?void 0:f.state)!=="active"});if(n.length)return a&&"module"in a&&((c=a.removeStyles)==null||c.call(a)),x(e,new Error(`Frontend plugin dependencies are not active: ${n.join(", ")}`));const o=b({source:e,metadata:e.metadata,directory:e.directory,revision:e.revision,state:"loading",requiredServices:[],missingServices:[]});u.push(o),h();try{const s=a??await F(e,t);if("error"in s)throw s.error;o.removeStyles=s.removeStyles;const{module:f}=s;o.requiredServices=H(f);{let p,w;if(o.fork=d.plugin({...f,name:e.metadata.id,apply:(...z)=>{try{return p=f.apply(...z)}catch(j){throw w=j,j}}},r===void 0?e.metadata.config:r),w)throw w;await p,d.logger("plugin").info(`Panel frontend plugin loaded: ${e.metadata.id}`)}}catch(s){o.error=s instanceof Error?s:new Error(String(s)),(l=o.fork)==null||l.dispose(),o.fork=void 0,(m=o.removeStyles)==null||m.call(o),d.logger("plugin").error(`Panel frontend plugin failed to load: ${e.metadata.id}`,s)}return h(),o}function te(e){const t=d.get("vue"),r=d.get("routes");return!t||!r?!1:t.router.currentRoute.value.matched.some(a=>r.ownerOf(a.path)===e.metadata.id)}async function v(e){var i,n;if(y.has(e))throw new Error(`The essential frontend plugin "${e}" cannot be unloaded.`);const t=u.find(o=>o.metadata.id===e);if(!t)return!1;t.state="unloading",h();const r=d.get("vue");r&&te(t)&&await r.router.replace("/404"),(i=t.fork)==null||i.dispose();try{await _()}catch(o){throw t.error=o instanceof Error?o:new Error(String(o)),o}(n=t.removeStyles)==null||n.call(t),Y(t.source);const a=u.indexOf(t);return a>=0&&u.splice(a,1),h(),d.logger("plugin").info(`Panel frontend plugin unloaded: ${e}`),!0}async function re(e){let t=g.get(e);if(t||(await $(),t=g.get(e)),!t)throw new Error(`Panel frontend plugin not found: ${e}`);return E(t)}async function ne(e){if(y.has(e))throw new Error(`The essential frontend plugin "${e}" cannot be reloaded.`);await v(e);{const r=await O();g.clear(),r.forEach(a=>g.set(a.metadata.id,a))}const t=g.get(e);if(!t)throw new Error(`Panel frontend plugin not found: ${e}`);return E(t,t.revision||String(t.metadata.version||"reload"))}async function $(e){e??(e=await O());const t=new Map(e.map(n=>[n.metadata.id,n]));g.clear(),t.forEach((n,o)=>g.set(o,n));for(const n of[...u].reverse())y.has(n.metadata.id)||t.has(n.metadata.id)||await v(n.metadata.id);const r=C(e);for(const[n,o]of r.issues){const c=t.get(n);if(!c)continue;u.find(m=>m.metadata.id===n)&&!y.has(n)&&await v(n),x(c,new Error(o.message))}const a=[];for(const n of r.ordered){const o=u.find(l=>l.metadata.id===n.metadata.id);o&&(o.restartRequired=!!n.metadata.restartRequired);const c=o&&(n.revision!==o.source.revision||JSON.stringify(n.metadata)!==JSON.stringify(o.metadata)||!!n.metadata.restartRequired!=!!o.source.metadata.restartRequired);if(o&&(c||n.metadata.restartRequired)){if(y.has(n.metadata.id)||n.metadata.restartRequired){o.restartRequired=!!n.metadata.restartRequired,o.reloadRequired=!!(c&&y.has(n.metadata.id));continue}await v(n.metadata.id)}u.some(l=>l.metadata.id===n.metadata.id)||a.push(n)}const i=await Promise.all(a.map(n=>F(n)));for(const[n,o]of a.entries())await E(o,void 0,void 0,i[n]);return await _(),h(),e.map(n=>n.metadata)}async function ae(){const e=await O();g.clear(),e.forEach(r=>g.set(r.metadata.id,r));const t=ee(e);try{for(const r of y){const a=g.get(r);if(!a)throw new Error(`Panel frontend foundation plugin not found: ${r}`);const i=await E(a);if(i.error)throw i.error;if(!i.fork||!d.get(N[r]))throw new Error(`Panel frontend foundation plugin failed to initialize: ${r}`)}await $(e),window.dispatchEvent(new CustomEvent("elementspanel:plugins-changed"))}finally{t()}}function k(){return u}function q(){return u.map(e=>{const t=Q(e);return{id:e.metadata.id,state:e.state,required:!!e.metadata.frontendRequired,revision:e.revision,requiredServices:[...e.requiredServices],missingServices:[...e.missingServices],...t?{error:t.message}:{}}})}function S(){h();const e=q().filter(t=>t.required&&t.state!=="active");if(e.length)throw new Error(`Required frontend plugins are not active: ${e.map(t=>`${t.id} (${t.state}${t.error?`: ${t.error}`:""})`).join(", ")}`)}const A=e=>P(()=>v(e)),I=e=>P(()=>re(e)),L=e=>P(()=>ne(e)),R=()=>P(async()=>{const e=await $();return window.dispatchEvent(new CustomEvent("elementspanel:plugins-changed")),e});function oe(){if(typeof EventSource>"u")return()=>{};const e=new EventSource(new URL("plugins/events",document.baseURI).href);let t="",r=!1,a;const i=()=>{r||R().catch(n=>{d.logger("plugin").error("Failed to synchronize plugins",n),a=setTimeout(i,2e3)})};return e.onmessage=n=>{let o;try{o=JSON.parse(n.data).revision}catch{return}typeof o!="string"||o===t||r||(t=o,a&&clearTimeout(a),i())},()=>{r=!0,a&&clearTimeout(a),e.close()}}async function ie(){d.provide("plugins",void 0,!0),d.set("plugins",{get loaded(){return k()},get diagnostics(){return q()},load:I,unload:A,reload:L,refresh:R,audit:S}),await ae(),S(),window.ElementsPanelPlugins={load:I,unload:A,reload:L,refresh:R,loaded:k,diagnostics:q,audit:S},await d.parallel("plugins/loaded"),await d.start(),d.effect(oe)}ie().catch(async e=>{var r;console.error("Plugin startup failed:",e);const t=d.get("startup");if(t)t.showError(e);else{const a=window;(r=a.setAppLoadingError)==null||r.call(a,e instanceof Error?e.message:String(e))}await d.stop()});
2
+ //# sourceMappingURL=index-6e8d74f8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"mappings":"kgCACO,SAASA,EAAoBC,EAAU,CACtC,MAAAC,MAAc,IACdC,EAAsB,GACtBC,MAAc,QACdC,MAAa,QACbC,EAAWC,GAAe,CAC1B,GAAAF,EAAO,IAAIE,CAAK,EAAG,OACvBF,EAAO,IAAIE,CAAK,EAChB,MAAMC,EAAQD,EAAM,MACpBA,EAAM,MAAQ,UAAY,CACxB,YAAK,YAAc,KAAK,YAAY,IAAKE,GAAsB,CACzD,GAAAL,EAAQ,IAAIK,CAAO,EAAU,OAAAA,EAC3B,MAAAC,EAAU,IAAIC,IAAoB,CAClC,IAAAC,EACA,IACOA,EAAAH,EAAQ,GAAGE,CAAI,QACjBE,EAAO,CACd,MAAAV,EAAS,KAAKU,CAAK,EACbA,CACR,CACA,GAAID,GAAU,OAAQA,EAA4B,MAAS,WAAY,CACrE,MAAME,EAAO,QAAQ,QAAQF,CAAM,EAChC,MAAOC,GAAU,CAChBV,EAAS,KAAK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B,EACfI,IAErB,OAAO,qBAAuB,CAC5B,KAAME,EACN,OAAQD,EACR,OAAQE,EACR,QAASC,EACT,OAAQN,EACR,YAAaC,EACb,MAAOC,CAAA,EAEH,MAAAvG,EAAI,SAAS,gBAAgB,EACnC,MAAMA,EAAI,QACVA,EAAI,OAAO4G,EAAkB,CAC/B,CCvDAO,KAA4B,MAAM,MAAOvG,GAAU,OACzC,cAAM,yBAA0BA,CAAK,EACvC,MAAAwG,EAAUpH,EAAI,IAAI,SAAS,EAC7B,GAAAoH,EAASA,EAAQ,UAAUxG,CAAK,MAC/B,CACH,MAAMyG,EAAO,QACblF,EAAAkF,EAAK,qBAAL,MAAAlF,EAAA,KAAAkF,EAA0BzG,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,EACjF,CACA,MAAMZ,EAAI,MACZ,CAAC","names":["trackPluginDisposal","ctx","pending","failures","tracked","scopes","observe","scope","reset","dispose","wrapper","args","result","error","task","key","errors","FOUNDATION_SERVICES","ESSENTIAL_PLUGIN_IDS","change","createPluginQueue","settle","plugins","shallowReactive","sources","compareSources","a","b","requiredServices","module","value","name","scopeState","refreshPluginState","plugin","pluginError","_a","_b","notifyPluginDiagnostics","candidate","normalizeMetadata","id","toModule","loadStyles","source","links","href","resolve","reject","link","removePluginStyles","style","normalizedHref","fetchProductionSources","manifestUrl","response","body","manifest","toUrl","item","metadata","entry","entryUrl","cacheKey","url","__vitePreload","discoverSources","discovered","unique","resolveSourceGraph","resolvePluginDependencyOrder","preloadPluginAssets","validatePluginCompatibility","preparePlugin","removeStyles","styles","recordGraphFailure","existing","install","configOverride","prepared","unavailableDependencies","resources","applied","thrown","_c","isCurrentRoute","vue","routes","record","unloadPluginInternal","index","loadPluginInternal","refreshPluginsInternal","reloadPluginInternal","next","graph","issue","current","changed","bootstrapPanelFrontendPlugins","removePreloads","getLoadedPlugins","getPluginDiagnostics","auditFrontendPlugins","unloadPlugin","loadPlugin","reloadPlugin","refreshPlugins","watchPluginChanges","events","revision","stopped","retry","synchronize","event","setupPanelFrontendPlugins","startup","host"],"sources":["../../../common/src/plugin_lifecycle.ts","../../src/plugin/loader.ts","../../src/plugin/install.ts","../../src/main.ts"],"sourcesContent":["/** Cordis 3 starts async disposers without awaiting them. Track them per host. */\nexport function trackPluginDisposal(ctx: any) {\n const pending = new Set<Promise<unknown>>();\n const failures: unknown[] = [];\n const tracked = new WeakSet<Function>();\n const scopes = new WeakSet<object>();\n const observe = (scope: any) => {\n if (scopes.has(scope)) return;\n scopes.add(scope);\n const reset = scope.reset;\n scope.reset = function () {\n this.disposables = this.disposables.map((dispose: Function) => {\n if (tracked.has(dispose)) return dispose;\n const wrapper = (...args: unknown[]) => {\n let result: unknown;\n try {\n result = dispose(...args);\n } catch (error) {\n failures.push(error);\n throw error;\n }\n if (result && typeof (result as Promise<unknown>).then === \"function\") {\n const task = Promise.resolve(result)\n .catch((error) => {\n failures.push(error);\n })\n .finally(() => pending.delete(task));\n pending.add(task);\n }\n return result;\n };\n // Cordis marks persistent disposers with a symbol; preserve its semantics.\n for (const key of Object.getOwnPropertySymbols(dispose))\n Object.defineProperty(wrapper, key, Object.getOwnPropertyDescriptor(dispose, key)!);\n tracked.add(wrapper);\n return wrapper;\n });\n return reset.call(this);\n };\n };\n ctx.on(\"internal/runtime\", observe);\n ctx.on(\"internal/fork\", observe);\n return async () => {\n do {\n await ctx.events.flush();\n await Promise.all([...pending]);\n } while (pending.size);\n if (failures.length) {\n const errors = failures.splice(0);\n throw new Error(`Plugin cleanup failed: ${errors.map(String).join(\"; \")}`);\n }\n };\n}\n","import {\n createPluginQueue,\n resolvePluginDependencyOrder,\n type PluginState,\n validatePluginCompatibility\n} from \"../../../common/src/plugin_contract\";\nimport { trackPluginDisposal } from \"../../../common/src/plugin_lifecycle\";\nimport { shallowReactive } from \"vue\";\nimport type { EffectScope, ForkScope } from \"cordis\";\nimport {\n ctx,\n type PanelFrontendPluginContext,\n type PanelFrontendPluginDiagnostic\n} from \"./context\";\nimport { panelPluginModules } from \"virtual:panel-plugins\";\n\nconst FOUNDATION_SERVICES: Record<string, string> = {\n runtime: \"startup\",\n i18n: \"i18n\",\n console: \"console\"\n};\nconst ESSENTIAL_PLUGIN_IDS = new Set(Object.keys(FOUNDATION_SERVICES));\nconst change = createPluginQueue();\nconst settle = trackPluginDisposal(ctx);\n\n/**\n * Fetches plugin code and hands it to cordis.\n *\n * Discovery is unchanged: in development the Vite plugin supplies a virtual\n * module of static imports; in production the browser fetches\n * `plugins/manifest.json` and imports each entry by URL. What that feeds is now\n * `ctx.plugin()`, and unloading is `fork.dispose()` — every route, card, menu,\n * action and translation the plugin registered is an effect of its scope.\n */\n\nexport interface PanelFrontendPluginMetadata {\n id: string;\n version?: string;\n description?: string;\n enabled?: boolean;\n priority?: number;\n frontend?: string;\n ui?: string;\n frontendInject?: string[];\n frontendImmediate?: boolean;\n frontendRequired?: boolean;\n config?: unknown;\n restartRequired?: boolean;\n [key: string]: unknown;\n}\n\n/** A frontend plugin module, as its entry exports it. */\nexport interface PanelFrontendPluginModule {\n inject?: string[] | Record<string, { required: boolean }>;\n apply(ctx: PanelFrontendPluginContext, config?: unknown): void | Promise<void>;\n}\n\ninterface PluginSource {\n metadata: PanelFrontendPluginMetadata;\n directory: string;\n assetDirectory: string;\n entry?: string;\n revision?: string;\n styles?: string[];\n load: (cacheKey?: string) => Promise<Record<string, unknown>>;\n}\n\ntype PreparedPlugin =\n | { module: PanelFrontendPluginModule; removeStyles?: () => void }\n | { error: Error };\n\nexport interface LoadedPanelFrontendPlugin {\n metadata: PanelFrontendPluginMetadata;\n directory: string;\n state: PluginState;\n requiredServices: readonly string[];\n missingServices: readonly string[];\n revision?: string;\n fork?: ForkScope;\n error?: Error;\n restartRequired?: boolean;\n reloadRequired?: boolean;\n}\n\ninterface InternalPlugin extends LoadedPanelFrontendPlugin {\n source: PluginSource;\n /** Only the stylesheet links, which are not cordis effects. */\n removeStyles?: () => void;\n}\n\nconst plugins = shallowReactive<InternalPlugin[]>([]);\nconst sources = new Map<string, PluginSource>();\n\nfunction compareSources(a: PluginSource, b: PluginSource) {\n return (\n (Number(a.metadata.priority) || 0) - (Number(b.metadata.priority) || 0) ||\n a.metadata.id.localeCompare(b.metadata.id)\n );\n}\n\nfunction requiredServices(module: PanelFrontendPluginModule) {\n if (Array.isArray(module.inject)) return [...new Set(module.inject)];\n if (!module.inject) return [];\n return Object.entries(module.inject)\n .filter(([, value]) => value?.required)\n .map(([name]) => name);\n}\n\nfunction scopeState(scope?: ForkScope): PluginState {\n if (!scope) return \"failed\";\n if (scope.error || scope.runtime.error) return \"failed\";\n switch (scope.status) {\n case 0: // ScopeStatus.PENDING\n return \"pending\";\n case 1: // ScopeStatus.LOADING\n return \"loading\";\n case 2: // ScopeStatus.ACTIVE\n return \"active\";\n case 3: // ScopeStatus.FAILED\n case 4: // ScopeStatus.DISPOSED\n return \"failed\";\n default:\n return \"pending\";\n }\n}\n\nfunction refreshPluginState(plugin: InternalPlugin) {\n plugin.missingServices = plugin.requiredServices.filter((name) => !ctx.get(name as never));\n plugin.state =\n plugin.restartRequired || plugin.reloadRequired\n ? \"restart-required\"\n : plugin.error\n ? \"failed\"\n : scopeState(plugin.fork);\n}\n\nfunction pluginError(plugin: InternalPlugin): Error | undefined {\n const error = plugin.error || plugin.fork?.error || plugin.fork?.runtime.error;\n if (error === undefined || error === null) return undefined;\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction notifyPluginDiagnostics() {\n for (const plugin of plugins) refreshPluginState(plugin);\n}\n\nctx.on(\"internal/status\", (scope: EffectScope) => {\n const plugin = plugins.find((candidate) => candidate.fork === scope);\n if (plugin) notifyPluginDiagnostics();\n});\n\nfunction normalizeMetadata(value: Record<string, unknown>): PanelFrontendPluginMetadata | null {\n const id = typeof value.id === \"string\" ? value.id.trim() : \"\";\n if (!id) return null;\n return { ...value, id } as PanelFrontendPluginMetadata;\n}\n\n/**\n * The plugin object a module exports, whether as named exports or as `default`.\n *\n * Only an object counts: every function has `Function.prototype.apply`, so a\n * module whose default export is a function would otherwise be mistaken for a\n * plugin and then called with the context as `this`.\n */\nfunction toModule(value: any, id: string): PanelFrontendPluginModule | undefined {\n for (const candidate of [value, value?.default]) {\n if (typeof candidate !== \"object\" || candidate === null) continue;\n if (typeof candidate.apply === \"function\") return candidate;\n }\n ctx.logger(\"plugin\").warn(`Panel frontend plugin \"${id}\" must export an apply() function.`);\n return undefined;\n}\n\nasync function loadStyles(source: PluginSource) {\n const links: HTMLLinkElement[] = [];\n try {\n await Promise.all(\n (source.styles || []).map(\n (href) =>\n new Promise<void>((resolve, reject) => {\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = href;\n link.dataset.panelPlugin = source.metadata.id;\n link.addEventListener(\"load\", () => resolve(), { once: true });\n link.addEventListener(\n \"error\",\n () => reject(new Error(`Failed to load panel plugin stylesheet: ${href}`)),\n { once: true }\n );\n document.head.appendChild(link);\n links.push(link);\n })\n )\n );\n } catch (error) {\n links.forEach((link) => link.remove());\n throw error;\n }\n return () => links.forEach((link) => link.remove());\n}\n\n/**\n * Removes stylesheets the plugin injected itself, which the core cannot track:\n * `<style>` elements it tagged, and any `<link>` matching one of its hrefs.\n */\nfunction removePluginStyles(source: PluginSource) {\n document\n .querySelectorAll<HTMLStyleElement>(\n `style[data-panel-plugin=${JSON.stringify(source.metadata.id)}]`\n )\n .forEach((style) => style.remove());\n for (const href of source.styles || []) {\n const normalizedHref = new URL(href, document.baseURI).href;\n document.querySelectorAll<HTMLLinkElement>(\"link[rel='stylesheet']\").forEach((link) => {\n try {\n if (new URL(link.href, document.baseURI).href === normalizedHref) link.remove();\n } catch {\n // Ignore malformed third-party stylesheet URLs.\n }\n });\n }\n}\n\nasync function fetchProductionSources(): Promise<PluginSource[]> {\n const manifestUrl = new URL(\"plugins/manifest.json\", document.baseURI);\n const response = await fetch(manifestUrl.href, { cache: \"no-store\" });\n if (!response.ok) {\n if (response.status === 404) return [];\n throw new Error(`Failed to load panel plugin manifest: HTTP ${response.status}`);\n }\n const body = await response.json();\n // Older panel builds may still pass the manifest through the standard API\n // envelope. Accept both the raw array and `{ data: [...] }` forms.\n const manifest = Array.isArray(body) ? body : body?.data;\n if (!Array.isArray(manifest)) throw new Error(\"Invalid panel plugin manifest.\");\n\n const toUrl = (value: string) => new URL(value, manifestUrl).href;\n const result: PluginSource[] = [];\n for (const item of manifest) {\n if (!item || typeof item !== \"object\" || Array.isArray(item)) continue;\n const metadata = normalizeMetadata((item as any).metadata || item);\n const entry = typeof (item as any).entry === \"string\" ? (item as any).entry : \"\";\n if (!metadata || metadata.enabled === false || !entry) continue;\n const entryUrl = toUrl(entry);\n result.push({\n metadata,\n directory:\n typeof (item as any).directory === \"string\" ? (item as any).directory : metadata.id,\n assetDirectory:\n typeof (item as any).assetDirectory === \"string\"\n ? (item as any).assetDirectory\n : metadata.id,\n entry: entryUrl,\n revision: typeof item.revision === \"string\" ? item.revision : String(metadata.version || \"\"),\n styles: Array.isArray((item as any).styles)\n ? (item as any).styles\n .filter((style: unknown): style is string => typeof style === \"string\")\n .map(toUrl)\n : [],\n load: async (cacheKey) => {\n const url = new URL(entryUrl);\n if (cacheKey) url.searchParams.set(\"panel_plugin_reload\", cacheKey);\n return import(/* @vite-ignore */ url.href) as Promise<Record<string, unknown>>;\n }\n });\n }\n return result;\n}\n\nasync function discoverSources() {\n const discovered = import.meta.env.DEV\n ? (panelPluginModules as PluginSource[])\n : await fetchProductionSources();\n const unique = new Map<string, PluginSource>();\n for (const source of discovered) {\n const metadata = normalizeMetadata(source.metadata);\n if (!metadata || metadata.enabled === false || unique.has(metadata.id)) continue;\n unique.set(metadata.id, { ...source, metadata });\n }\n return [...unique.values()].sort(compareSources);\n}\n\nfunction resolveSourceGraph(discovered: readonly PluginSource[]) {\n return resolvePluginDependencyOrder(discovered, {\n id: (source) => source.metadata.id,\n dependencies: (source) => source.metadata.frontendInject,\n compare: compareSources\n });\n}\n\n/** Fetch production assets during foundation startup without evaluating plugin code. */\nfunction preloadPluginAssets(discovered: readonly PluginSource[]) {\n const links: HTMLLinkElement[] = [];\n if (!import.meta.env.DEV) {\n for (const source of resolveSourceGraph(discovered).ordered) {\n try {\n validatePluginCompatibility(source.metadata.elements);\n } catch {\n continue;\n }\n if (source.metadata.restartRequired || !source.entry) continue;\n const module = document.createElement(\"link\");\n module.rel = \"modulepreload\";\n module.href = source.entry;\n module.crossOrigin = \"anonymous\";\n document.head.appendChild(module);\n links.push(module);\n for (const href of source.styles || []) {\n const style = document.createElement(\"link\");\n style.rel = \"preload\";\n style.setAttribute(\"as\", \"style\");\n style.href = href;\n document.head.appendChild(style);\n links.push(style);\n }\n }\n }\n return () => links.forEach((link) => link.remove());\n}\n\n/** Preparation never rejects, so an optional download failure cannot abort the batch. */\nasync function preparePlugin(source: PluginSource, cacheKey?: string): Promise<PreparedPlugin> {\n let removeStyles: (() => void) | undefined;\n try {\n validatePluginCompatibility(source.metadata.elements);\n if (source.metadata.restartRequired)\n throw new Error(\"The plugin backend requires a restart before this version can load.\");\n const [styles, entry] = await Promise.allSettled([\n import.meta.env.DEV ? Promise.resolve(undefined) : loadStyles(source),\n Promise.resolve().then(() => source.load(cacheKey))\n ]);\n if (styles.status === \"rejected\") throw styles.reason;\n removeStyles = styles.value;\n if (entry.status === \"rejected\") throw entry.reason;\n const module = toModule(entry.value, source.metadata.id);\n if (!module)\n throw new Error(`Panel frontend plugin has no apply() export: ${source.metadata.id}`);\n return { module, removeStyles };\n } catch (error) {\n removeStyles?.();\n return { error: error instanceof Error ? error : new Error(String(error)) };\n }\n}\n\nfunction recordGraphFailure(source: PluginSource, error: Error) {\n const existing = plugins.find((plugin) => plugin.metadata.id === source.metadata.id);\n if (existing) {\n existing.error = error;\n existing.state = \"failed\";\n notifyPluginDiagnostics();\n return existing;\n }\n const plugin = shallowReactive<InternalPlugin>({\n source,\n metadata: source.metadata,\n directory: source.directory,\n revision: source.revision,\n state: \"failed\",\n requiredServices: [],\n missingServices: [],\n error\n });\n plugins.push(plugin);\n notifyPluginDiagnostics();\n return plugin;\n}\n\nasync function install(\n source: PluginSource,\n cacheKey?: string,\n configOverride?: unknown,\n prepared?: PreparedPlugin\n) {\n const existing = plugins.find((plugin) => plugin.metadata.id === source.metadata.id);\n if (existing) return existing;\n\n const unavailableDependencies = (source.metadata.frontendInject || []).filter(\n (id) => plugins.find((plugin) => plugin.metadata.id === id)?.state !== \"active\"\n );\n if (unavailableDependencies.length) {\n if (prepared && \"module\" in prepared) prepared.removeStyles?.();\n return recordGraphFailure(\n source,\n new Error(\n `Frontend plugin dependencies are not active: ${unavailableDependencies.join(\", \")}`\n )\n );\n }\n\n const plugin = shallowReactive<InternalPlugin>({\n source,\n metadata: source.metadata,\n directory: source.directory,\n revision: source.revision,\n state: \"loading\",\n requiredServices: [],\n missingServices: []\n });\n plugins.push(plugin);\n notifyPluginDiagnostics();\n try {\n const resources = prepared ?? (await preparePlugin(source, cacheKey));\n if (\"error\" in resources) throw resources.error;\n plugin.removeStyles = resources.removeStyles;\n const { module } = resources;\n plugin.requiredServices = requiredServices(module);\n {\n // An `async apply()` is awaited here, so a plugin is fully applied before\n // the next one activates and before the app is mounted. Resource loading\n // happens in parallel before this dependency-ordered activation phase.\n //\n // cordis catches a synchronous throw from `apply()` and cancels the scope\n // itself, so the wrapper keeps a copy of it: without that, a plugin that\n // failed on its first line would still be reported as loaded.\n let applied: unknown;\n let thrown: unknown;\n // The manifest id is the plugin's name, so `ctx.name` — which is what\n // appears in its log lines — always matches the package metadata.\n plugin.fork = ctx.plugin(\n {\n ...module,\n name: source.metadata.id,\n apply: (...args) => {\n try {\n return (applied = module.apply(...args));\n } catch (error) {\n thrown = error;\n throw error;\n }\n }\n },\n configOverride === undefined\n ? (source.metadata as { config?: unknown }).config\n : configOverride\n );\n if (thrown) throw thrown;\n await applied;\n ctx.logger(\"plugin\").info(`Panel frontend plugin loaded: ${source.metadata.id}`);\n }\n } catch (error: any) {\n // Failure is atomic: whatever the plugin managed to register before it threw\n // goes with its scope, so a half-loaded plugin never stays behind.\n plugin.error = error instanceof Error ? error : new Error(String(error));\n plugin.fork?.dispose();\n plugin.fork = undefined;\n plugin.removeStyles?.();\n ctx\n .logger(\"plugin\")\n .error(`Panel frontend plugin failed to load: ${source.metadata.id}`, error);\n }\n notifyPluginDiagnostics();\n return plugin;\n}\n\nfunction isCurrentRoute(plugin: InternalPlugin) {\n const vue = ctx.get(\"vue\");\n const routes = ctx.get(\"routes\");\n if (!vue || !routes) return false;\n return vue.router.currentRoute.value.matched.some(\n (record) => routes.ownerOf(record.path) === plugin.metadata.id\n );\n}\n\nasync function unloadPluginInternal(id: string) {\n if (ESSENTIAL_PLUGIN_IDS.has(id)) {\n throw new Error(`The essential frontend plugin \"${id}\" cannot be unloaded.`);\n }\n const plugin = plugins.find((candidate) => candidate.metadata.id === id);\n if (!plugin) return false;\n plugin.state = \"unloading\";\n notifyPluginDiagnostics();\n // Leave the plugin's page before its routes go, or the router lands on\n // nothing.\n const vue = ctx.get(\"vue\");\n if (vue && isCurrentRoute(plugin)) await vue.router.replace(\"/404\");\n plugin.fork?.dispose();\n try {\n await settle();\n } catch (error) {\n plugin.error = error instanceof Error ? error : new Error(String(error));\n throw error;\n }\n plugin.removeStyles?.();\n removePluginStyles(plugin.source);\n const index = plugins.indexOf(plugin);\n if (index >= 0) plugins.splice(index, 1);\n notifyPluginDiagnostics();\n ctx.logger(\"plugin\").info(`Panel frontend plugin unloaded: ${id}`);\n return true;\n}\n\nasync function loadPluginInternal(id: string) {\n let source = sources.get(id);\n if (!source && !import.meta.env.DEV) {\n await refreshPluginsInternal();\n source = sources.get(id);\n }\n if (!source) throw new Error(`Panel frontend plugin not found: ${id}`);\n return install(source);\n}\n\nasync function reloadPluginInternal(id: string) {\n if (ESSENTIAL_PLUGIN_IDS.has(id)) {\n throw new Error(`The essential frontend plugin \"${id}\" cannot be reloaded.`);\n }\n await unloadPluginInternal(id);\n if (!import.meta.env.DEV) {\n const discovered = await discoverSources();\n sources.clear();\n discovered.forEach((source) => sources.set(source.metadata.id, source));\n }\n const source = sources.get(id);\n if (!source) throw new Error(`Panel frontend plugin not found: ${id}`);\n // The server revision is the cache identity. Reloading unchanged code still\n // retries activation without manufacturing an unbounded timestamp URL.\n return install(source, source.revision || String(source.metadata.version || \"reload\"));\n}\n\n/** Re-reads what is installed and loads or unloads to match. */\nasync function refreshPluginsInternal(discovered?: PluginSource[]) {\n discovered ??= await discoverSources();\n const next = new Map(discovered.map((source) => [source.metadata.id, source]));\n sources.clear();\n next.forEach((source, id) => sources.set(id, source));\n for (const plugin of [...plugins].reverse()) {\n if (ESSENTIAL_PLUGIN_IDS.has(plugin.metadata.id)) continue;\n if (!next.has(plugin.metadata.id)) await unloadPluginInternal(plugin.metadata.id);\n }\n const graph = resolveSourceGraph(discovered);\n for (const [id, issue] of graph.issues) {\n const source = next.get(id);\n if (!source) continue;\n const current = plugins.find((plugin) => plugin.metadata.id === id);\n if (current && !ESSENTIAL_PLUGIN_IDS.has(id)) await unloadPluginInternal(id);\n recordGraphFailure(source, new Error(issue.message));\n }\n const pending: PluginSource[] = [];\n for (const source of graph.ordered) {\n const current = plugins.find((plugin) => plugin.metadata.id === source.metadata.id);\n if (current) current.restartRequired = Boolean(source.metadata.restartRequired);\n const changed =\n current &&\n (source.revision !== current.source.revision ||\n JSON.stringify(source.metadata) !== JSON.stringify(current.metadata) ||\n Boolean(source.metadata.restartRequired) !==\n Boolean(current.source.metadata.restartRequired));\n if (current && (changed || source.metadata.restartRequired)) {\n if (ESSENTIAL_PLUGIN_IDS.has(source.metadata.id) || source.metadata.restartRequired) {\n current.restartRequired = Boolean(source.metadata.restartRequired);\n current.reloadRequired = Boolean(changed && ESSENTIAL_PLUGIN_IDS.has(source.metadata.id));\n continue;\n }\n await unloadPluginInternal(source.metadata.id);\n }\n if (!plugins.some((plugin) => plugin.metadata.id === source.metadata.id)) pending.push(source);\n }\n const prepared = await Promise.all(pending.map((source) => preparePlugin(source)));\n for (const [index, source] of pending.entries()) {\n await install(source, undefined, undefined, prepared[index]);\n }\n await settle();\n notifyPluginDiagnostics();\n return discovered.map((source) => source.metadata) as readonly PanelFrontendPluginMetadata[];\n}\n\n/** Discover once, prefetch assets, then activate foundations before the remaining batch. */\nexport async function bootstrapPanelFrontendPlugins() {\n const discovered = await discoverSources();\n sources.clear();\n discovered.forEach((source) => sources.set(source.metadata.id, source));\n const removePreloads = preloadPluginAssets(discovered);\n try {\n for (const id of ESSENTIAL_PLUGIN_IDS) {\n const source = sources.get(id);\n if (!source) throw new Error(`Panel frontend foundation plugin not found: ${id}`);\n const plugin = await install(source);\n if (plugin.error) throw plugin.error;\n if (!plugin.fork || !ctx.get(FOUNDATION_SERVICES[id])) {\n throw new Error(`Panel frontend foundation plugin failed to initialize: ${id}`);\n }\n }\n await refreshPluginsInternal(discovered);\n window.dispatchEvent(new CustomEvent(\"elementspanel:plugins-changed\"));\n } finally {\n removePreloads();\n }\n}\n\nexport function getLoadedPlugins(): readonly LoadedPanelFrontendPlugin[] {\n return plugins;\n}\n\nexport function getPluginDiagnostics(): readonly PanelFrontendPluginDiagnostic[] {\n return plugins.map((plugin) => {\n const error = pluginError(plugin);\n return {\n id: plugin.metadata.id,\n state: plugin.state,\n required: Boolean(plugin.metadata.frontendRequired),\n revision: plugin.revision,\n requiredServices: [...plugin.requiredServices],\n missingServices: [...plugin.missingServices],\n ...(error ? { error: error.message } : {})\n };\n });\n}\n\nexport function auditFrontendPlugins() {\n notifyPluginDiagnostics();\n const failures = getPluginDiagnostics().filter(\n (plugin) => plugin.required && plugin.state !== \"active\"\n );\n if (!failures.length) return;\n throw new Error(\n `Required frontend plugins are not active: ${failures\n .map((plugin) => `${plugin.id} (${plugin.state}${plugin.error ? `: ${plugin.error}` : \"\"})`)\n .join(\", \")}`\n );\n}\n\n/** Serialize UI actions and server notifications against the same browser state. */\nexport const unloadPlugin = (id: string) => change(() => unloadPluginInternal(id));\nexport const loadPlugin = (id: string) => change(() => loadPluginInternal(id));\nexport const reloadPlugin = (id: string) => change(() => reloadPluginInternal(id));\nexport const refreshPlugins = () =>\n change(async () => {\n const result = await refreshPluginsInternal();\n window.dispatchEvent(new CustomEvent(\"elementspanel:plugins-changed\"));\n return result;\n });\n\n/** Reconnect receives the complete current generation; no event history is needed. */\nexport function watchPluginChanges(): () => void {\n if (import.meta.env.DEV || typeof EventSource === \"undefined\") return () => {};\n const events = new EventSource(new URL(\"plugins/events\", document.baseURI).href);\n let revision = \"\";\n let stopped = false;\n let retry: ReturnType<typeof setTimeout> | undefined;\n const synchronize = () => {\n if (stopped) return;\n void refreshPlugins().catch((error) => {\n ctx.logger(\"plugin\").error(\"Failed to synchronize plugins\", error);\n retry = setTimeout(synchronize, 2000);\n });\n };\n events.onmessage = (event) => {\n let next: string;\n try {\n next = JSON.parse(event.data).revision;\n } catch {\n return;\n }\n if (typeof next !== \"string\" || next === revision || stopped) return;\n revision = next;\n if (retry) clearTimeout(retry);\n synchronize();\n };\n return () => {\n stopped = true;\n if (retry) clearTimeout(retry);\n events.close();\n };\n}\n","import { ctx } from \"./context\";\nimport {\n bootstrapPanelFrontendPlugins,\n auditFrontendPlugins,\n getPluginDiagnostics,\n getLoadedPlugins,\n loadPlugin,\n refreshPlugins,\n reloadPlugin,\n unloadPlugin,\n watchPluginChanges\n} from \"./loader\";\n\ndeclare global {\n interface Window {\n ElementsPanelPlugins?: {\n load: typeof loadPlugin;\n unload: typeof unloadPlugin;\n reload: typeof reloadPlugin;\n refresh: typeof refreshPlugins;\n loaded: typeof getLoadedPlugins;\n diagnostics: typeof getPluginDiagnostics;\n audit: typeof auditFrontendPlugins;\n };\n }\n}\n\nexport async function setupPanelFrontendPlugins() {\n ctx.provide(\"plugins\", undefined, true);\n ctx.set(\"plugins\", {\n get loaded() {\n return getLoadedPlugins();\n },\n get diagnostics() {\n return getPluginDiagnostics();\n },\n load: loadPlugin,\n unload: unloadPlugin,\n reload: reloadPlugin,\n refresh: refreshPlugins,\n audit: auditFrontendPlugins\n });\n\n await bootstrapPanelFrontendPlugins();\n auditFrontendPlugins();\n\n window.ElementsPanelPlugins = {\n load: loadPlugin,\n unload: unloadPlugin,\n reload: reloadPlugin,\n refresh: refreshPlugins,\n loaded: getLoadedPlugins,\n diagnostics: getPluginDiagnostics,\n audit: auditFrontendPlugins\n };\n await ctx.parallel(\"plugins/loaded\");\n await ctx.start();\n ctx.effect(watchPluginChanges);\n}\n","import { ctx } from \"./plugin/context\";\nimport { setupPanelFrontendPlugins } from \"./plugin/install\";\n\nsetupPanelFrontendPlugins().catch(async (error) => {\n console.error(\"Plugin startup failed:\", error);\n const startup = ctx.get(\"startup\");\n if (startup) startup.showError(error);\n else {\n const host = window as Window & { setAppLoadingError?: (message: string) => void };\n host.setAppLoadingError?.(error instanceof Error ? error.message : String(error));\n }\n await ctx.stop();\n});\n"],"file":"assets/index-6e8d74f8.js"}
@@ -0,0 +1,2 @@
1
+ const y=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],T=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],d=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],M=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],s=(t,i,e)=>{let a=t;return typeof i=="string"||Array.isArray(i)?a=t.toLocaleString(i,e):(i===!0||e!==void 0)&&(a=t.toLocaleString(void 0,e)),a},g=t=>{if(typeof t=="number")return Math.log10(t);const i=t.toString(10);return i.length+Math.log10("0."+i.slice(0,15))},S=t=>typeof t=="number"?Math.log(t):g(t)*Math.log(10),b=(t,i)=>{if(typeof t=="number")return t/i;const e=t/BigInt(i),a=t%BigInt(i);return Number(e)+Number(a)/i};function h(t,i){if(typeof t!="bigint"&&!Number.isFinite(t))throw new TypeError(`Expected a finite number, got ${typeof t}: ${t}`);i={bits:!1,binary:!1,space:!0,...i};const e=i.bits?i.binary?M:d:i.binary?T:y,a=i.space?" ":"";if(i.signed&&(typeof t=="number"?t===0:t===0n))return` 0${a}${e[0]}`;const r=t<0,c=r?"-":i.signed?"+":"";r&&(t=-t);let n;if(i.minimumFractionDigits!==void 0&&(n={minimumFractionDigits:i.minimumFractionDigits}),i.maximumFractionDigits!==void 0&&(n={maximumFractionDigits:i.maximumFractionDigits,...n}),t<1){const B=s(t,i.locale,n);return c+B+a+e[0]}const f=Math.min(Math.floor(i.binary?S(t)/Math.log(1024):g(t)/3),e.length-1);t=b(t,(i.binary?1024:1e3)**f),n||(t=t.toPrecision(3));const o=s(Number(t),i.locale,n),l=e[f];return c+o+a+l}export{h as p};
2
+ //# sourceMappingURL=index-c684efbd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-c684efbd.js","sources":["../../node_modules/pretty-bytes/index.js"],"sourcesContent":["const BYTE_UNITS = [\n\t'B',\n\t'kB',\n\t'MB',\n\t'GB',\n\t'TB',\n\t'PB',\n\t'EB',\n\t'ZB',\n\t'YB',\n];\n\nconst BIBYTE_UNITS = [\n\t'B',\n\t'KiB',\n\t'MiB',\n\t'GiB',\n\t'TiB',\n\t'PiB',\n\t'EiB',\n\t'ZiB',\n\t'YiB',\n];\n\nconst BIT_UNITS = [\n\t'b',\n\t'kbit',\n\t'Mbit',\n\t'Gbit',\n\t'Tbit',\n\t'Pbit',\n\t'Ebit',\n\t'Zbit',\n\t'Ybit',\n];\n\nconst BIBIT_UNITS = [\n\t'b',\n\t'kibit',\n\t'Mibit',\n\t'Gibit',\n\t'Tibit',\n\t'Pibit',\n\t'Eibit',\n\t'Zibit',\n\t'Yibit',\n];\n\n/*\nFormats the given number using `Number#toLocaleString`.\n- If locale is a string, the value is expected to be a locale-key (for example: `de`).\n- If locale is true, the system default locale is used for translation.\n- If no value for locale is specified, the number is returned unmodified.\n*/\nconst toLocaleString = (number, locale, options) => {\n\tlet result = number;\n\tif (typeof locale === 'string' || Array.isArray(locale)) {\n\t\tresult = number.toLocaleString(locale, options);\n\t} else if (locale === true || options !== undefined) {\n\t\tresult = number.toLocaleString(undefined, options);\n\t}\n\n\treturn result;\n};\n\nconst log10 = numberOrBigInt => {\n\tif (typeof numberOrBigInt === 'number') {\n\t\treturn Math.log10(numberOrBigInt);\n\t}\n\n\tconst string = numberOrBigInt.toString(10);\n\n\treturn string.length + Math.log10('0.' + string.slice(0, 15));\n};\n\nconst log = numberOrBigInt => {\n\tif (typeof numberOrBigInt === 'number') {\n\t\treturn Math.log(numberOrBigInt);\n\t}\n\n\treturn log10(numberOrBigInt) * Math.log(10);\n};\n\nconst divide = (numberOrBigInt, divisor) => {\n\tif (typeof numberOrBigInt === 'number') {\n\t\treturn numberOrBigInt / divisor;\n\t}\n\n\tconst integerPart = numberOrBigInt / BigInt(divisor);\n\tconst remainder = numberOrBigInt % BigInt(divisor);\n\treturn Number(integerPart) + (Number(remainder) / divisor);\n};\n\nexport default function prettyBytes(number, options) {\n\tif (typeof number !== 'bigint' && !Number.isFinite(number)) {\n\t\tthrow new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);\n\t}\n\n\toptions = {\n\t\tbits: false,\n\t\tbinary: false,\n\t\tspace: true,\n\t\t...options,\n\t};\n\n\tconst UNITS = options.bits\n\t\t? (options.binary ? BIBIT_UNITS : BIT_UNITS)\n\t\t: (options.binary ? BIBYTE_UNITS : BYTE_UNITS);\n\n\tconst separator = options.space ? ' ' : '';\n\n\tif (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {\n\t\treturn ` 0${separator}${UNITS[0]}`;\n\t}\n\n\tconst isNegative = number < 0;\n\tconst prefix = isNegative ? '-' : (options.signed ? '+' : '');\n\n\tif (isNegative) {\n\t\tnumber = -number;\n\t}\n\n\tlet localeOptions;\n\n\tif (options.minimumFractionDigits !== undefined) {\n\t\tlocaleOptions = {minimumFractionDigits: options.minimumFractionDigits};\n\t}\n\n\tif (options.maximumFractionDigits !== undefined) {\n\t\tlocaleOptions = {maximumFractionDigits: options.maximumFractionDigits, ...localeOptions};\n\t}\n\n\tif (number < 1) {\n\t\tconst numberString = toLocaleString(number, options.locale, localeOptions);\n\t\treturn prefix + numberString + separator + UNITS[0];\n\t}\n\n\tconst exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);\n\tnumber = divide(number, (options.binary ? 1024 : 1000) ** exponent);\n\n\tif (!localeOptions) {\n\t\tnumber = number.toPrecision(3);\n\t}\n\n\tconst numberString = toLocaleString(Number(number), options.locale, localeOptions);\n\n\tconst unit = UNITS[exponent];\n\n\treturn prefix + numberString + separator + unit;\n}\n"],"names":["BYTE_UNITS","BIBYTE_UNITS","BIT_UNITS","BIBIT_UNITS","toLocaleString","number","locale","options","result","log10","numberOrBigInt","string","log","divide","divisor","integerPart","remainder","prettyBytes","UNITS","separator","isNegative","prefix","localeOptions","numberString","exponent","unit"],"mappings":"AAAA,MAAMA,EAAa,CAClB,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IACD,EAEMC,EAAe,CACpB,IACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,KACD,EAEMC,EAAY,CACjB,IACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,MACD,EAEMC,EAAc,CACnB,IACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,OACD,EAQMC,EAAiB,CAACC,EAAQC,EAAQC,IAAY,CACnD,IAAIC,EAASH,EACb,OAAI,OAAOC,GAAW,UAAY,MAAM,QAAQA,CAAM,EACrDE,EAASH,EAAO,eAAeC,EAAQC,CAAO,GACpCD,IAAW,IAAQC,IAAY,UACzCC,EAASH,EAAO,eAAe,OAAWE,CAAO,GAG3CC,CACR,EAEMC,EAAQC,GAAkB,CAC/B,GAAI,OAAOA,GAAmB,SAC7B,OAAO,KAAK,MAAMA,CAAc,EAGjC,MAAMC,EAASD,EAAe,SAAS,EAAE,EAEzC,OAAOC,EAAO,OAAS,KAAK,MAAM,KAAOA,EAAO,MAAM,EAAG,EAAE,CAAC,CAC7D,EAEMC,EAAMF,GACP,OAAOA,GAAmB,SACtB,KAAK,IAAIA,CAAc,EAGxBD,EAAMC,CAAc,EAAI,KA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Ga,EAAM,OAAS,CAAC,EACzHb,EAASQ,EAAOR,GAASE,EAAQ,OAAS,KAAO,MAASiB,CAAQ,EAE7DF,IACJjB,EAASA,EAAO,YAAY,CAAC,GAG9B,MAAMkB,EAAenB,EAAe,OAAOC,CAAM,EAAGE,EAAQ,OAAQe,CAAa,EAE3EG,EAAOP,EAAMM,CAAQ,EAE3B,OAAOH,EAASE,EAAeJ,EAAYM,CAC5C","x_google_ignoreList":[0]}
@@ -0,0 +1,2 @@
1
+ const d=Object.create(null);d.open="0";d.close="1";d.ping="2";d.pong="3";d.message="4";d.upgrade="5";d.noop="6";const O=Object.create(null);Object.keys(d).forEach(s=>{O[d[s]]=s});const L={type:"error",data:"parser error"},te=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",se=typeof ArrayBuffer=="function",ne=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s&&s.buffer instanceof ArrayBuffer,V=({type:s,data:e},t,n)=>te&&e instanceof Blob?t?n(e):$(e,n):se&&(e instanceof ArrayBuffer||ne(e))?t?n(e):$(new Blob([e]),n):n(d[s]+(e||"")),$=(s,e)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];e("b"+(n||""))},t.readAsDataURL(s)};function Y(s){return s instanceof Uint8Array?s:s instanceof ArrayBuffer?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}let S;function ye(s,e){if(te&&s.data instanceof Blob)return s.data.arrayBuffer().then(Y).then(e);if(se&&(s.data instanceof ArrayBuffer||ne(s.data)))return e(Y(s.data));V(s,!1,t=>{S||(S=new TextEncoder),e(S.encode(t))})}const z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let s=0;s<z.length;s++)E[z.charCodeAt(s)]=s;const ge=s=>{let e=s.length*.75,t=s.length,n,i=0,r,o,h,a;s[s.length-1]==="="&&(e--,s[s.length-2]==="="&&e--);const g=new ArrayBuffer(e),y=new Uint8Array(g);for(n=0;n<t;n+=4)r=E[s.charCodeAt(n)],o=E[s.charCodeAt(n+1)],h=E[s.charCodeAt(n+2)],a=E[s.charCodeAt(n+3)],y[i++]=r<<2|o>>4,y[i++]=(o&15)<<4|h>>2,y[i++]=(h&3)<<6|a&63;return g},me=typeof ArrayBuffer=="function",F=(s,e)=>{if(typeof s!="string")return{type:"message",data:ie(s,e)};const t=s.charAt(0);return t==="b"?{type:"message",data:be(s.substring(1),e)}:O[t]?s.length>1?{type:O[t],data:s.substring(1)}:{type:O[t]}:L},be=(s,e)=>{if(me){const t=ge(s);return ie(t,e)}else return{base64:!0,data:s}},ie=(s,e)=>{switch(e){case"blob":return s instanceof Blob?s:new Blob([s]);case"arraybuffer":default:return s instanceof ArrayBuffer?s:s.buffer}},re=String.fromCharCode(30),we=(s,e)=>{const t=s.length,n=new Array(t);let i=0;s.forEach((r,o)=>{V(r,!1,h=>{n[o]=h,++i===t&&e(n.join(re))})})},ve=(s,e)=>{const t=s.split(re),n=[];for(let i=0;i<t.length;i++){const r=F(t[i],e);if(n.push(r),r.type==="error")break}return n};function _e(){return new TransformStream({transform(s,e){ye(s,t=>{const n=t.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,n)}else{i=new Uint8Array(9);const r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(n))}s.data&&typeof s.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}let x;function k(s){return s.reduce((e,t)=>e+t.length,0)}function A(s,e){if(s[0].length===e)return s.shift();const t=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)t[i]=s[0][n++],n===s[0].length&&(s.shift(),n=0);return s.length&&n<s[0].length&&(s[0]=s[0].slice(n)),t}function Ee(s,e){x||(x=new TextDecoder);const t=[];let n=0,i=-1,r=!1;return new TransformStream({transform(o,h){for(t.push(o);;){if(n===0){if(k(t)<1)break;const a=A(t,1);r=(a[0]&128)===128,i=a[0]&127,i<126?n=3:i===126?n=1:n=2}else if(n===1){if(k(t)<2)break;const a=A(t,2);i=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),n=3}else if(n===2){if(k(t)<8)break;const a=A(t,8),g=new DataView(a.buffer,a.byteOffset,a.length),y=g.getUint32(0);if(y>Math.pow(2,53-32)-1){h.enqueue(L);break}i=y*Math.pow(2,32)+g.getUint32(4),n=3}else{if(k(t)<i)break;const a=A(t,i);h.enqueue(F(r?a:x.decode(a),e)),n=0}if(i===0||i>s){h.enqueue(L);break}}}})}const oe=4;function u(s){if(s)return ke(s)}function ke(s){for(var e in u.prototype)s[e]=u.prototype[e];return s}u.prototype.on=u.prototype.addEventListener=function(s,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+s]=this._callbacks["$"+s]||[]).push(e),this};u.prototype.once=function(s,e){function t(){this.off(s,t),e.apply(this,arguments)}return t.fn=e,this.on(s,t),this};u.prototype.off=u.prototype.removeListener=u.prototype.removeAllListeners=u.prototype.removeEventListener=function(s,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+s];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+s],this;for(var n,i=0;i<t.length;i++)if(n=t[i],n===e||n.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+s],this};u.prototype.emit=function(s){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+s],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,i=t.length;n<i;++n)t[n].apply(this,e)}return this};u.prototype.emitReserved=u.prototype.emit;u.prototype.listeners=function(s){return this._callbacks=this._callbacks||{},this._callbacks["$"+s]||[]};u.prototype.hasListeners=function(s){return!!this.listeners(s).length};const f=(()=>typeof self<"u"?self:typeof window<"u"?window:Function("return this")())();function ce(s,...e){return e.reduce((t,n)=>(s.hasOwnProperty(n)&&(t[n]=s[n]),t),{})}const Ae=f.setTimeout,Te=f.clearTimeout;function B(s,e){e.useNativeTimers?(s.setTimeoutFn=Ae.bind(f),s.clearTimeoutFn=Te.bind(f)):(s.setTimeoutFn=f.setTimeout.bind(f),s.clearTimeoutFn=f.clearTimeout.bind(f))}const Re=1.33;function Oe(s){return typeof s=="string"?Ce(s):Math.ceil((s.byteLength||s.size)*Re)}function Ce(s){let e=0,t=0;for(let n=0,i=s.length;n<i;n++)e=s.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function Be(s){let e="";for(let t in s)s.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(s[t]));return e}function Se(s){let e={},t=s.split("&");for(let n=0,i=t.length;n<i;n++){let r=t[n].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return e}class xe extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class M extends u{constructor(e){super(),this.writable=!1,B(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new xe(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=F(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Be(e);return t.length?"?"+t:""}}const ae="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),P=64,Ne={};let J=0,T=0,X;function Q(s){let e="";do e=ae[s%P]+e,s=Math.floor(s/P);while(s>0);return e}function he(){const s=Q(+new Date);return s!==X?(J=0,X=s):s+"."+Q(J++)}for(;T<P;T++)Ne[ae[T]]=T;let ue=!1;try{ue=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Le=ue;function fe(s){const e=s.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Le))return new XMLHttpRequest}catch{}if(!e)try{return new f[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function Pe(){}const qe=function(){return new fe({xdomain:!1}).responseType!=null}();class De extends M{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const n=location.protocol==="https:";let i=location.port;i||(i=n?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}const t=e&&e.forceBase64;this.supportsBinary=qe&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let n=0;this.polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};ve(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,we(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=he()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new p(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}}class p extends u{constructor(e,t){super(),B(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=t.data!==void 0?t.data:null,this.create()}create(){var e;const t=ce(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new fe(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let i in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(i)&&n.setRequestHeader(i,this.opts.extraHeaders[i])}}catch{}if(this.method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var i;n.readyState===3&&((i=this.opts.cookieJar)===null||i===void 0||i.parseCookies(n)),n.readyState===4&&(n.status===200||n.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof n.status=="number"?n.status:0)},0))},n.send(this.data)}catch(i){this.setTimeoutFn(()=>{this.onError(i)},0);return}typeof document<"u"&&(this.index=p.requestsCount++,p.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Pe,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete p.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}p.requestsCount=0;p.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",G);else if(typeof addEventListener=="function"){const s="onpagehide"in f?"pagehide":"unload";addEventListener(s,G,!1)}}function G(){for(let s in p.requests)p.requests.hasOwnProperty(s)&&p.requests[s].abort()}const H=(()=>typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0))(),R=f.WebSocket||f.MozWebSocket,j=!0,Ue="arraybuffer",Z=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Ie extends M{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=Z?{}:ce(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=j&&!Z?t?new R(e,t):new R(e):new R(e,t,n)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;V(n,this.supportsBinary,r=>{const o={};try{j&&this.ws.send(r)}catch{}i&&H(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=he()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!R}}class Ve extends M{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const t=Ee(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),i=_e();i.readable.pipeTo(e.writable),this.writer=i.writable.getWriter();const r=()=>{n.read().then(({done:h,value:a})=>{h||(this.onPacket(a),r())}).catch(h=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;this.writer.write(n).then(()=>{i&&H(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const Fe={websocket:Ie,webtransport:Ve,polling:De},Me=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,He=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function q(s){if(s.length>2e3)throw"URI too long";const e=s,t=s.indexOf("["),n=s.indexOf("]");t!=-1&&n!=-1&&(s=s.substring(0,t)+s.substring(t,n).replace(/:/g,";")+s.substring(n,s.length));let i=Me.exec(s||""),r={},o=14;for(;o--;)r[He[o]]=i[o]||"";return t!=-1&&n!=-1&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Ke(r,r.path),r.queryKey=We(r,r.query),r}function Ke(s,e){const t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function We(s,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,i,r){i&&(t[i]=r)}),t}let le=class b extends u{constructor(e,t={}){super(),this.binaryType=Ue,this.writeBuffer=[],e&&typeof e=="object"&&(t=e,e=null),e?(e=q(e),t.hostname=e.host,t.secure=e.protocol==="https"||e.protocol==="wss",t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=q(t.host).host),B(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Se(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=oe,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Fe[e](n)}open(){let e;if(this.opts.rememberUpgrade&&b.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",t=>this.onClose("transport close",t))}probe(e){let t=this.createTransport(e),n=!1;b.priorWebsocketSuccess=!1;const i=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",m=>{if(!n)if(m.type==="pong"&&m.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;b.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(y(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=t.name,this.emitReserved("upgradeError",v)}}))};function r(){n||(n=!0,y(),t.close(),t=null)}const o=m=>{const v=new Error("probe error: "+m);v.transport=t.name,r(),this.emitReserved("upgradeError",v)};function h(){o("transport closed")}function a(){o("socket closed")}function g(m){t&&m.name!==t.name&&r()}const y=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",h),this.off("close",a),this.off("upgrading",g)};t.once("open",i),t.once("error",o),t.once("close",h),this.once("close",a),this.once("upgrading",g),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onOpen(){if(this.readyState="open",b.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const i=this.writeBuffer[n].data;if(i&&(t+=Oe(i)),n>0&&t>this.maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,i){if(typeof t=="function"&&(i=t,t=void 0),typeof n=="function"&&(i=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const r={type:e,data:t,options:n};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){b.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const i=e.length;for(;n<i;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};le.protocol=oe;function $e(s,e="",t){let n=s;t=t||typeof location<"u"&&location,s==null&&(s=t.protocol+"//"+t.host),typeof s=="string"&&(s.charAt(0)==="/"&&(s.charAt(1)==="/"?s=t.protocol+s:s=t.host+s),/^(https?|wss?):\/\//.test(s)||(typeof t<"u"?s=t.protocol+"//"+s:s="https://"+s),n=q(s)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const r=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port+e,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n}const Ye=typeof ArrayBuffer=="function",ze=s=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(s):s.buffer instanceof ArrayBuffer,pe=Object.prototype.toString,Je=typeof Blob=="function"||typeof Blob<"u"&&pe.call(Blob)==="[object BlobConstructor]",Xe=typeof File=="function"||typeof File<"u"&&pe.call(File)==="[object FileConstructor]";function K(s){return Ye&&(s instanceof ArrayBuffer||ze(s))||Je&&s instanceof Blob||Xe&&s instanceof File}function C(s,e){if(!s||typeof s!="object")return!1;if(Array.isArray(s)){for(let t=0,n=s.length;t<n;t++)if(C(s[t]))return!0;return!1}if(K(s))return!0;if(s.toJSON&&typeof s.toJSON=="function"&&arguments.length===1)return C(s.toJSON(),!0);for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t)&&C(s[t]))return!0;return!1}function Qe(s){const e=[],t=s.data,n=s;return n.data=D(t,e),n.attachments=e.length,{packet:n,buffers:e}}function D(s,e){if(!s)return s;if(K(s)){const t={_placeholder:!0,num:e.length};return e.push(s),t}else if(Array.isArray(s)){const t=new Array(s.length);for(let n=0;n<s.length;n++)t[n]=D(s[n],e);return t}else if(typeof s=="object"&&!(s instanceof Date)){const t={};for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=D(s[n],e));return t}return s}function Ge(s,e){return s.data=U(s.data,e),delete s.attachments,s}function U(s,e){if(!s)return s;if(s&&s._placeholder===!0){if(typeof s.num=="number"&&s.num>=0&&s.num<e.length)return e[s.num];throw new Error("illegal attachments")}else if(Array.isArray(s))for(let t=0;t<s.length;t++)s[t]=U(s[t],e);else if(typeof s=="object")for(const t in s)Object.prototype.hasOwnProperty.call(s,t)&&(s[t]=U(s[t],e));return s}const je=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Ze=5;var c;(function(s){s[s.CONNECT=0]="CONNECT",s[s.DISCONNECT=1]="DISCONNECT",s[s.EVENT=2]="EVENT",s[s.ACK=3]="ACK",s[s.CONNECT_ERROR=4]="CONNECT_ERROR",s[s.BINARY_EVENT=5]="BINARY_EVENT",s[s.BINARY_ACK=6]="BINARY_ACK"})(c||(c={}));class et{constructor(e){this.replacer=e}encode(e){return(e.type===c.EVENT||e.type===c.ACK)&&C(e)?this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===c.BINARY_EVENT||e.type===c.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Qe(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}}function ee(s){return Object.prototype.toString.call(s)==="[object Object]"}class W extends u{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===c.BINARY_EVENT;n||t.type===c.BINARY_ACK?(t.type=n?c.EVENT:c.ACK,this.reconstructor=new tt(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(K(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(c[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===c.BINARY_EVENT||n.type===c.BINARY_ACK){const r=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(o)}if(e.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(r,t)}else n.nsp="/";const i=e.charAt(t+1);if(i!==""&&Number(i)==i){const r=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(W.isPayloadValid(n.type,r))n.data=r;else throw new Error("invalid payload")}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return ee(t);case c.DISCONNECT:return t===void 0;case c.CONNECT_ERROR:return typeof t=="string"||ee(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&je.indexOf(t[0])===-1);case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class tt{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Ge(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const st=Object.freeze(Object.defineProperty({__proto__:null,Decoder:W,Encoder:et,get PacketType(){return c},protocol:Ze},Symbol.toStringTag,{value:"Module"}));function l(s,e,t){return s.on(e,t),function(){s.off(e,t)}}const nt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class de extends u{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[l(e,"open",this.onopen.bind(this)),l(e,"packet",this.onpacket.bind(this)),l(e,"error",this.onerror.bind(this)),l(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(nt.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:c.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const o=this.ids++,h=t.pop();this._registerAckCallback(o,h),n.id=o}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const i=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);t.call(this,new Error("operation has timed out"))},i);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(r),t.apply(this,[null,...o])}}emitWithAck(e,...t){const n=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((i,r)=>{t.push((o,h)=>n?o?r(o):i(h):i(o)),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...r)=>n!==this._queue[0]?void 0:(i!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:c.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case c.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case c.EVENT:case c.BINARY_EVENT:this.onevent(e);break;case c.ACK:case c.BINARY_ACK:this.onack(e);break;case c.DISCONNECT:this.ondisconnect();break;case c.CONNECT_ERROR:this.destroy();const n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...i){n||(n=!0,t.packet({type:c.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:c.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function w(s){s=s||{},this.ms=s.min||100,this.max=s.max||1e4,this.factor=s.factor||2,this.jitter=s.jitter>0&&s.jitter<=1?s.jitter:0,this.attempts=0}w.prototype.duration=function(){var s=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*s);s=Math.floor(e*10)&1?s+t:s-t}return Math.min(s,this.max)|0};w.prototype.reset=function(){this.attempts=0};w.prototype.setMin=function(s){this.ms=s};w.prototype.setMax=function(s){this.max=s};w.prototype.setJitter=function(s){this.jitter=s};class I extends u{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,B(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new w({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||st;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new le(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=l(t,"open",function(){n.onopen(),e&&e()}),r=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),e?e(h):this.maybeReconnectOnOpen()},o=l(t,"error",r);if(this._timeout!==!1){const h=this._timeout,a=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),t.close()},h);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(l(e,"ping",this.onping.bind(this)),l(e,"data",this.ondata.bind(this)),l(e,"error",this.onerror.bind(this)),l(e,"close",this.onclose.bind(this)),l(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){H(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new de(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const _={};function N(s,e){typeof s=="object"&&(e=s,s=void 0),e=e||{};const t=$e(s,e.path||"/socket.io"),n=t.source,i=t.id,r=t.path,o=_[i]&&r in _[i].nsps,h=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let a;return h?a=new I(n,e):(_[i]||(_[i]=new I(n,e)),a=_[i]),t.query&&!e.query&&(e.query=t.queryKey),a.socket(t.path,e)}Object.assign(N,{Manager:I,Socket:de,io:N,connect:N});export{N as l};
2
+ //# sourceMappingURL=index-e3f35709.js.map