@myrialabs/clopen 0.4.26 → 0.4.28

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 (98) hide show
  1. package/backend/auth/permissions.ts +21 -0
  2. package/backend/bootstrap.ts +18 -1
  3. package/backend/chat/engine-handoff.test.ts +229 -0
  4. package/backend/chat/engine-handoff.ts +439 -0
  5. package/backend/chat/stream-manager.ts +200 -16
  6. package/backend/database/migrations/066_create_memory_graph.ts +369 -0
  7. package/backend/database/migrations/index.ts +7 -0
  8. package/backend/database/queries/audit-log-queries.test.ts +10 -1
  9. package/backend/database/queries/graph-queries.ts +1764 -0
  10. package/backend/database/queries/index.ts +2 -0
  11. package/backend/database/queries/memory-queue-queries.ts +381 -0
  12. package/backend/database/queries/snapshot-queries.ts +20 -0
  13. package/backend/engine/README.md +45 -2
  14. package/backend/engine/adapters/claude/message-converter.ts +5 -24
  15. package/backend/engine/adapters/copilot/stream.ts +37 -1
  16. package/backend/engine/adapters/pi/models.ts +19 -7
  17. package/backend/engine/adapters/pi/stream.ts +2 -1
  18. package/backend/engine/docs/adapter-contract.md +25 -8
  19. package/backend/engine/docs/adding-an-engine.md +40 -4
  20. package/backend/engine/docs/frontend-and-chat.md +66 -1
  21. package/backend/engine/docs/lessons-learned.md +165 -6
  22. package/backend/engine/docs/quick-reference.md +10 -0
  23. package/backend/engine/docs/stack.md +10 -0
  24. package/backend/engine/docs/websocket-routes.md +15 -1
  25. package/backend/engine/engine-setup.ts +1 -1
  26. package/backend/engine/index.test.ts +186 -0
  27. package/backend/engine/index.ts +117 -71
  28. package/backend/engine/install-recipes.test.ts +105 -0
  29. package/backend/engine/install-recipes.ts +4 -1
  30. package/backend/index.ts +9 -0
  31. package/backend/mcp/internal/config.ts +6 -0
  32. package/backend/mcp/internal/servers/index.ts +2 -0
  33. package/backend/mcp/internal/servers/memory-graph/description.ts +33 -0
  34. package/backend/mcp/internal/servers/memory-graph/format.ts +45 -0
  35. package/backend/mcp/internal/servers/memory-graph/index.ts +52 -0
  36. package/backend/mcp/internal/servers/memory-graph/runner.ts +342 -0
  37. package/backend/mcp/internal/servers/memory-graph/schema.ts +140 -0
  38. package/backend/memory/README.md +432 -0
  39. package/backend/memory/bootstrap.ts +101 -0
  40. package/backend/memory/compose.test.ts +198 -0
  41. package/backend/memory/compose.ts +343 -0
  42. package/backend/memory/config.ts +100 -0
  43. package/backend/memory/consolidate.ts +280 -0
  44. package/backend/memory/context.test.ts +321 -0
  45. package/backend/memory/context.ts +451 -0
  46. package/backend/memory/embedding/embedder.test.ts +141 -0
  47. package/backend/memory/embedding/embedder.ts +269 -0
  48. package/backend/memory/embedding/index.ts +17 -0
  49. package/backend/memory/embedding/install.ts +254 -0
  50. package/backend/memory/embedding/paths.ts +101 -0
  51. package/backend/memory/embedding/vector-cache.ts +270 -0
  52. package/backend/memory/extract/episodic.ts +725 -0
  53. package/backend/memory/extract/index.ts +133 -0
  54. package/backend/memory/extract/languages.ts +176 -0
  55. package/backend/memory/extract/scheduler.test.ts +352 -0
  56. package/backend/memory/extract/scheduler.ts +406 -0
  57. package/backend/memory/extract/structural.test.ts +215 -0
  58. package/backend/memory/extract/structural.ts +364 -0
  59. package/backend/memory/index.ts +37 -0
  60. package/backend/memory/indexer.ts +150 -0
  61. package/backend/memory/invalidate.ts +134 -0
  62. package/backend/memory/judge.ts +285 -0
  63. package/backend/memory/maintenance.ts +132 -0
  64. package/backend/memory/model.ts +91 -0
  65. package/backend/memory/notify.ts +102 -0
  66. package/backend/memory/readiness.ts +74 -0
  67. package/backend/memory/redact.test.ts +101 -0
  68. package/backend/memory/redact.ts +133 -0
  69. package/backend/memory/retention.ts +139 -0
  70. package/backend/memory/retrieval.eval.test.ts +301 -0
  71. package/backend/memory/retrieval.test.ts +1023 -0
  72. package/backend/memory/retrieval.ts +707 -0
  73. package/backend/memory/revise.test.ts +693 -0
  74. package/backend/memory/revise.ts +400 -0
  75. package/backend/memory/time.ts +31 -0
  76. package/backend/memory/view.ts +164 -0
  77. package/backend/shipped-runtime-imports.test.ts +228 -0
  78. package/backend/ws/engine/claude/accounts.ts +4 -12
  79. package/backend/ws/engine/codex/accounts.ts +4 -13
  80. package/backend/ws/engine/pty-output.test.ts +37 -0
  81. package/backend/ws/engine/pty-output.ts +43 -0
  82. package/backend/ws/index.ts +5 -1
  83. package/backend/ws/memory/crud.ts +631 -0
  84. package/backend/ws/memory/index.ts +41 -0
  85. package/backend/ws/sessions/crud.ts +10 -0
  86. package/backend/ws/snapshot/restore.ts +38 -4
  87. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js +1 -0
  88. package/dist/assets/{index-DYa-GDsb.js → index-BujQYGBm.js} +1 -1
  89. package/dist/assets/{index-B6QGUN03.js → index-DRMOgS9y.js} +1 -1
  90. package/dist/assets/{main-Dznkfxsd.js → main-BrYtWn-4.js} +832 -423
  91. package/dist/assets/main-BrqMMMRX.css +1 -0
  92. package/dist/index.html +2 -2
  93. package/package.json +8 -2
  94. package/shared/types/database/connection.ts +9 -0
  95. package/shared/types/memory.ts +519 -0
  96. package/shared/utils/logger.ts +1 -0
  97. package/dist/assets/main-Dh-MTGNR.css +0 -1
  98. package/shared/utils/anonymous-user.ts +0 -168
@@ -217,11 +217,41 @@ export const restoreHandler = createRouter()
217
217
  // 5b. Update head_session_id so resume works correctly.
218
218
  // Claude Code: skip cancelled fork session_ids (partial messages from cancelStream).
219
219
  // OpenCode: simple walk — any session_id is valid (sessions created synchronously).
220
+ //
221
+ // Engine is read PER MESSAGE, not from `chat_sessions.engine`: a session can
222
+ // now switch engine mid-conversation, so the session column only names the
223
+ // currently selected engine. Restoring into a region driven by a different
224
+ // engine must apply that region's semantics, and must not adopt an SDK
225
+ // session id belonging to some other engine's store.
220
226
  {
221
227
  let foundSdkSessionId: string | null = null;
222
228
  const msgLookup = new Map(allMessages.map(m => [m.id, m]));
223
- const sessionRecord = sessionQueries.getById(sessionId);
224
- const isClaudeCode = sessionRecord?.engine === 'claude-code';
229
+
230
+ const engineOf = (msg: UnifiedMessage): string | null => msg.engine?.type ?? null;
231
+
232
+ // The engine that owns the restored branch head — the only engine whose
233
+ // session ids are meaningful for a subsequent resume.
234
+ let branchEngine: string | null = null;
235
+ {
236
+ let probeId: string | null = sessionEnd.id;
237
+ while (probeId) {
238
+ const probeMsg = msgLookup.get(probeId);
239
+ if (!probeMsg) break;
240
+ try {
241
+ const msg = JSON.parse(probeMsg.data) as UnifiedMessage;
242
+ if (msg.type !== 'user') {
243
+ const type = engineOf(msg);
244
+ if (type) { branchEngine = type; break; }
245
+ }
246
+ } catch { /* skip */ }
247
+ probeId = probeMsg.parent_message_id || null;
248
+ }
249
+ if (!branchEngine) {
250
+ branchEngine = sessionQueries.getById(sessionId)?.engine ?? null;
251
+ }
252
+ }
253
+
254
+ const isClaudeCode = branchEngine === 'claude-code';
225
255
 
226
256
  // Claude Code only: detect cancelled stream by stopReason on sessionEnd
227
257
  let cancelledSessionId: string | null = null;
@@ -257,8 +287,12 @@ export const restoreHandler = createRouter()
257
287
  continue;
258
288
  }
259
289
 
260
- // Any engine: message with sessionId
261
- if (msg.sessionId) {
290
+ // Any engine: message with sessionId, but only from the branch's own
291
+ // engine. Crossing that line would store a foreign store's id.
292
+ // A message with no engine block is pre-migration: it cannot be
293
+ // proven foreign, so keep the old behaviour and accept it.
294
+ const msgEngine = engineOf(msg);
295
+ if (msg.sessionId && (!branchEngine || !msgEngine || msgEngine === branchEngine)) {
262
296
  foundSdkSessionId = msg.sessionId;
263
297
  break;
264
298
  }
@@ -0,0 +1 @@
1
+ (function(){"use strict";function yt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Ee={exports:{}},qe;function wt(){if(qe)return Ee.exports;qe=1;var i=typeof Reflect=="object"?Reflect:null,e=i&&typeof i.apply=="function"?i.apply:function(g,E,_){return Function.prototype.apply.call(g,E,_)},t;i&&typeof i.ownKeys=="function"?t=i.ownKeys:Object.getOwnPropertySymbols?t=function(g){return Object.getOwnPropertyNames(g).concat(Object.getOwnPropertySymbols(g))}:t=function(g){return Object.getOwnPropertyNames(g)};function n(w){console&&console.warn&&console.warn(w)}var r=Number.isNaN||function(g){return g!==g};function o(){o.init.call(this)}Ee.exports=o,Ee.exports.once=j,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function u(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(w){if(typeof w!="number"||w<0||r(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");s=w}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(g){if(typeof g!="number"||g<0||r(g))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+g+".");return this._maxListeners=g,this};function h(w){return w._maxListeners===void 0?o.defaultMaxListeners:w._maxListeners}o.prototype.getMaxListeners=function(){return h(this)},o.prototype.emit=function(g){for(var E=[],_=1;_<arguments.length;_++)E.push(arguments[_]);var L=g==="error",S=this._events;if(S!==void 0)L=L&&S.error===void 0;else if(!L)return!1;if(L){var I;if(E.length>0&&(I=E[0]),I instanceof Error)throw I;var Z=new Error("Unhandled error."+(I?" ("+I.message+")":""));throw Z.context=I,Z}var z=S[g];if(z===void 0)return!1;if(typeof z=="function")e(z,this,E);else for(var d=z.length,ce=U(z,d),_=0;_<d;++_)e(ce[_],this,E);return!0};function a(w,g,E,_){var L,S,I;if(u(E),S=w._events,S===void 0?(S=w._events=Object.create(null),w._eventsCount=0):(S.newListener!==void 0&&(w.emit("newListener",g,E.listener?E.listener:E),S=w._events),I=S[g]),I===void 0)I=S[g]=E,++w._eventsCount;else if(typeof I=="function"?I=S[g]=_?[E,I]:[I,E]:_?I.unshift(E):I.push(E),L=h(w),L>0&&I.length>L&&!I.warned){I.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(g)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=w,Z.type=g,Z.count=I.length,n(Z)}return w}o.prototype.addListener=function(g,E){return a(this,g,E,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(g,E){return a(this,g,E,!0)};function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(w,g,E){var _={fired:!1,wrapFn:void 0,target:w,type:g,listener:E},L=c.bind(_);return L.listener=E,_.wrapFn=L,L}o.prototype.once=function(g,E){return u(E),this.on(g,l(this,g,E)),this},o.prototype.prependOnceListener=function(g,E){return u(E),this.prependListener(g,l(this,g,E)),this},o.prototype.removeListener=function(g,E){var _,L,S,I,Z;if(u(E),L=this._events,L===void 0)return this;if(_=L[g],_===void 0)return this;if(_===E||_.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete L[g],L.removeListener&&this.emit("removeListener",g,_.listener||E));else if(typeof _!="function"){for(S=-1,I=_.length-1;I>=0;I--)if(_[I]===E||_[I].listener===E){Z=_[I].listener,S=I;break}if(S<0)return this;S===0?_.shift():O(_,S),_.length===1&&(L[g]=_[0]),L.removeListener!==void 0&&this.emit("removeListener",g,Z||E)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(g){var E,_,L;if(_=this._events,_===void 0)return this;if(_.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):_[g]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete _[g]),this;if(arguments.length===0){var S=Object.keys(_),I;for(L=0;L<S.length;++L)I=S[L],I!=="removeListener"&&this.removeAllListeners(I);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(E=_[g],typeof E=="function")this.removeListener(g,E);else if(E!==void 0)for(L=E.length-1;L>=0;L--)this.removeListener(g,E[L]);return this};function y(w,g,E){var _=w._events;if(_===void 0)return[];var L=_[g];return L===void 0?[]:typeof L=="function"?E?[L.listener||L]:[L]:E?R(L):U(L,L.length)}o.prototype.listeners=function(g){return y(this,g,!0)},o.prototype.rawListeners=function(g){return y(this,g,!1)},o.listenerCount=function(w,g){return typeof w.listenerCount=="function"?w.listenerCount(g):v.call(w,g)},o.prototype.listenerCount=v;function v(w){var g=this._events;if(g!==void 0){var E=g[w];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function U(w,g){for(var E=new Array(g),_=0;_<g;++_)E[_]=w[_];return E}function O(w,g){for(;g+1<w.length;g++)w[g]=w[g+1];w.pop()}function R(w){for(var g=new Array(w.length),E=0;E<g.length;++E)g[E]=w[E].listener||w[E];return g}function j(w,g){return new Promise(function(E,_){function L(I){w.removeListener(g,S),_(I)}function S(){typeof w.removeListener=="function"&&w.removeListener("error",L),E([].slice.call(arguments))}x(w,g,S,{once:!0}),g!=="error"&&C(w,L,{once:!0})})}function C(w,g,E){typeof w.on=="function"&&x(w,"error",g,E)}function x(w,g,E,_){if(typeof w.on=="function")_.once?w.once(g,E):w.on(g,E);else if(typeof w.addEventListener=="function")w.addEventListener(g,function L(S){_.once&&w.removeEventListener(g,L),E(S)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return Ee.exports}var bt=wt();function mt(){const i=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])i[n]=arguments[e][n];return i}let B=mt;typeof Object.assign=="function"&&(B=Object.assign);function V(i,e,t,n){const r=i._nodes.get(e);let o=null;return r&&(n==="mixed"?o=r.out&&r.out[t]||r.undirected&&r.undirected[t]:n==="directed"?o=r.out&&r.out[t]:o=r.undirected&&r.undirected[t]),o}function q(i){return typeof i=="object"&&i!==null}function Ne(i){let e;for(e in i)return!1;return!0}function Y(i,e,t){Object.defineProperty(i,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function Q(i,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(i,e,n)}function Ve(i){return!(!q(i)||i.attributes&&!Array.isArray(i.attributes))}function vt(){let i=Math.floor(Math.random()*256)&255;return()=>i++}function M(){const i=arguments;let e=null,t=-1;return{[Symbol.iterator](){return this},next(){let n=null;do{if(e===null){if(t++,t>=i.length)return{done:!0};e=i[t][Symbol.iterator]()}if(n=e.next(),n.done){e=null;continue}break}while(!0);return n}}}function ue(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Oe extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class G extends Oe{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,G.prototype.constructor)}}class b extends Oe{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,b.prototype.constructor)}}class $ extends Oe{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,$.prototype.constructor)}}function Ye(i,e){this.key=i,this.attributes=e,this.clear()}Ye.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Ze(i,e){this.key=i,this.attributes=e,this.clear()}Ze.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Je(i,e){this.key=i,this.attributes=e,this.clear()}Je.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ae(i,e,t,n,r){this.key=e,this.attributes=r,this.undirected=i,this.source=t,this.target=n}ae.prototype.attach=function(){let i="out",e="in";this.undirected&&(i=e="undirected");const t=this.source.key,n=this.target.key;this.source[i][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)},ae.prototype.attachMulti=function(){let i="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(i=e="undirected");const r=this.source[i],o=r[n];if(typeof o>"u"){r[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}o.previous=this,this.next=o,r[n]=this,this.target[e][t]=this},ae.prototype.detach=function(){const i=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][i]},ae.prototype.detachMulti=function(){const i=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][i]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][i]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Qe=0,Xe=1,Et=2,Me=3;function ee(i,e,t,n,r,o,s){let u,h,a,c;if(n=""+n,t===Qe){if(u=i._nodes.get(n),!u)throw new b(`Graph.${e}: could not find the "${n}" node in the graph.`);a=r,c=o}else if(t===Me){if(r=""+r,h=i._edges.get(r),!h)throw new b(`Graph.${e}: could not find the "${r}" edge in the graph.`);const l=h.source.key,y=h.target.key;if(n===l)u=h.target;else if(n===y)u=h.source;else throw new b(`Graph.${e}: the "${n}" node is not attached to the "${r}" edge (${l}, ${y}).`);a=o,c=s}else{if(h=i._edges.get(n),!h)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===Xe?u=h.source:u=h.target,a=r,c=o}return[u,a,c]}function Gt(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);return s.attributes[u]}}function _t(i,e,t){i.prototype[e]=function(n,r){const[o]=ee(this,e,t,n,r);return o.attributes}}function $t(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);return s.attributes.hasOwnProperty(u)}}function Dt(i,e,t){i.prototype[e]=function(n,r,o,s){const[u,h,a]=ee(this,e,t,n,r,o,s);return u.attributes[h]=a,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:h}),this}}function kt(i,e,t){i.prototype[e]=function(n,r,o,s){const[u,h,a]=ee(this,e,t,n,r,o,s);if(typeof a!="function")throw new G(`Graph.${e}: updater should be a function.`);const c=u.attributes,l=a(c[h]);return c[h]=l,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:h}),this}}function At(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);return delete s.attributes[u],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:u}),this}}function Lt(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);if(!q(u))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function St(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);if(!q(u))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return B(s.attributes,u),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:u}),this}}function Ut(i,e,t){i.prototype[e]=function(n,r,o){const[s,u]=ee(this,e,t,n,r,o);if(typeof u!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return s.attributes=u(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Ot=[{name:i=>`get${i}Attribute`,attacher:Gt},{name:i=>`get${i}Attributes`,attacher:_t},{name:i=>`has${i}Attribute`,attacher:$t},{name:i=>`set${i}Attribute`,attacher:Dt},{name:i=>`update${i}Attribute`,attacher:kt},{name:i=>`remove${i}Attribute`,attacher:At},{name:i=>`replace${i}Attributes`,attacher:Lt},{name:i=>`merge${i}Attributes`,attacher:St},{name:i=>`update${i}Attributes`,attacher:Ut}];function It(i){Ot.forEach(function({name:e,attacher:t}){t(i,e("Node"),Qe),t(i,e("Source"),Xe),t(i,e("Target"),Et),t(i,e("Opposite"),Me)})}function Ct(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[r]}}function Rt(i,e,t){i.prototype[e]=function(n){let r;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,s=""+arguments[1];if(r=V(this,o,s,t),!r)throw new b(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,r=this._edges.get(n),!r)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return r.attributes}}function jt(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes.hasOwnProperty(r)}}function zt(i,e,t){i.prototype[e]=function(n,r,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+n,h=""+r;if(r=arguments[2],o=arguments[3],s=V(this,u,h,t),!s)throw new b(`Graph.${e}: could not find an edge for the given path ("${u}" - "${h}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function Tt(i,e,t){i.prototype[e]=function(n,r,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+n,h=""+r;if(r=arguments[2],o=arguments[3],s=V(this,u,h,t),!s)throw new b(`Graph.${e}: could not find an edge for the given path ("${u}" - "${h}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof o!="function")throw new G(`Graph.${e}: updater should be a function.`);return s.attributes[r]=o(s.attributes[r]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function Wt(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}function Pt(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function xt(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return B(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function Kt(i,e,t){i.prototype[e]=function(n,r){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+r;if(r=arguments[2],o=V(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof r!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Ft=[{name:i=>`get${i}Attribute`,attacher:Ct},{name:i=>`get${i}Attributes`,attacher:Rt},{name:i=>`has${i}Attribute`,attacher:jt},{name:i=>`set${i}Attribute`,attacher:zt},{name:i=>`update${i}Attribute`,attacher:Tt},{name:i=>`remove${i}Attribute`,attacher:Wt},{name:i=>`replace${i}Attributes`,attacher:Pt},{name:i=>`merge${i}Attributes`,attacher:xt},{name:i=>`update${i}Attributes`,attacher:Kt}];function Ht(i){Ft.forEach(function({name:e,attacher:t}){t(i,e("Edge"),"mixed"),t(i,e("DirectedEdge"),"directed"),t(i,e("UndirectedEdge"),"undirected")})}const Bt=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function qt(i,e,t,n){let r=!1;for(const o in e){if(o===n)continue;const s=e[o];if(r=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),i&&r)return s.key}}function Nt(i,e,t,n){let r,o,s,u=!1;for(const h in e)if(h!==n){r=e[h];do{if(o=r.source,s=r.target,u=t(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected),i&&u)return r.key;r=r.next}while(r!==void 0)}}function Ie(i,e){const t=Object.keys(i),n=t.length;let r,o=0;return{[Symbol.iterator](){return this},next(){do if(r)r=r.next;else{if(o>=n)return{done:!0};const s=t[o++];if(s===e){r=void 0;continue}r=i[s]}while(!r);return{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}}}}}function Vt(i,e,t,n){const r=e[t];if(!r)return;const o=r.source,s=r.target;if(n(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected)&&i)return r.key}function Yt(i,e,t,n){let r=e[t];if(!r)return;let o=!1;do{if(o=n(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),i&&o)return r.key;r=r.next}while(r!==void 0)}function Ce(i,e){let t=i[e];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const r={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:r}}};let n=!1;return{[Symbol.iterator](){return this},next(){return n===!0?{done:!0}:(n=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function Zt(i,e){if(i.size===0)return[];if(e==="mixed"||e===i.type)return Array.from(i._edges.keys());const t=e==="undirected"?i.undirectedSize:i.directedSize,n=new Array(t),r=e==="undirected",o=i._edges.values();let s=0,u,h;for(;u=o.next(),u.done!==!0;)h=u.value,h.undirected===r&&(n[s++]=h.key);return n}function et(i,e,t,n){if(e.size===0)return;const r=t!=="mixed"&&t!==e.type,o=t==="undirected";let s,u,h=!1;const a=e._edges.values();for(;s=a.next(),s.done!==!0;){if(u=s.value,r&&u.undirected!==o)continue;const{key:c,attributes:l,source:y,target:v}=u;if(h=n(c,l,y.key,v.key,y.attributes,v.attributes,u.undirected),i&&h)return c}}function Jt(i,e){if(i.size===0)return ue();const t=e!=="mixed"&&e!==i.type,n=e==="undirected",r=i._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=r.next(),o.done)return o;if(s=o.value,!(t&&s.undirected!==n))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Re(i,e,t,n,r,o){const s=e?Nt:qt;let u;if(t!=="undirected"&&(n!=="out"&&(u=s(i,r.in,o),i&&u)||n!=="in"&&(u=s(i,r.out,o,n?void 0:r.key),i&&u))||t!=="directed"&&(u=s(i,r.undirected,o),i&&u))return u}function Qt(i,e,t,n){const r=[];return Re(!1,i,e,t,n,function(o){r.push(o)}),r}function Xt(i,e,t){let n=ue();return i!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=M(n,Ie(t.in))),e!=="in"&&typeof t.out<"u"&&(n=M(n,Ie(t.out,e?void 0:t.key)))),i!=="directed"&&typeof t.undirected<"u"&&(n=M(n,Ie(t.undirected))),n}function je(i,e,t,n,r,o,s){const u=t?Yt:Vt;let h;if(e!=="undirected"&&(typeof r.in<"u"&&n!=="out"&&(h=u(i,r.in,o,s),i&&h)||typeof r.out<"u"&&n!=="in"&&(n||r.key!==o)&&(h=u(i,r.out,o,s),i&&h))||e!=="directed"&&typeof r.undirected<"u"&&(h=u(i,r.undirected,o,s),i&&h))return h}function Mt(i,e,t,n,r){const o=[];return je(!1,i,e,t,n,r,function(s){o.push(s)}),o}function en(i,e,t,n){let r=ue();return i!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(r=M(r,Ce(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(r=M(r,Ce(t.out,n)))),i!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(r=M(r,Ce(t.undirected,n))),r}function tn(i,e){const{name:t,type:n,direction:r}=e;i.prototype[t]=function(o,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return Zt(this,n);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(typeof u>"u")throw new b(`Graph.${t}: could not find the "${o}" node in the graph.`);return Qt(this.multi,n==="mixed"?this.type:n,r,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new b(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new b(`Graph.${t}: could not find the "${s}" target node in the graph.`);return Mt(n,this.multi,r,u,s)}throw new G(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function nn(i,e){const{name:t,type:n,direction:r}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);i.prototype[o]=function(a,c,l){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return l=a,et(!1,this,n,l);if(arguments.length===2){a=""+a,l=c;const y=this._nodes.get(a);if(typeof y>"u")throw new b(`Graph.${o}: could not find the "${a}" node in the graph.`);return Re(!1,this.multi,n==="mixed"?this.type:n,r,y,l)}if(arguments.length===3){a=""+a,c=""+c;const y=this._nodes.get(a);if(!y)throw new b(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(c))throw new b(`Graph.${o}: could not find the "${c}" target node in the graph.`);return je(!1,n,this.multi,r,y,c,l)}throw new G(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+t[0].toUpperCase()+t.slice(1);i.prototype[s]=function(){const a=Array.prototype.slice.call(arguments),c=a.pop();let l;if(a.length===0){let y=0;n!=="directed"&&(y+=this.undirectedSize),n!=="undirected"&&(y+=this.directedSize),l=new Array(y);let v=0;a.push((U,O,R,j,C,x,w)=>{l[v++]=c(U,O,R,j,C,x,w)})}else l=[],a.push((y,v,U,O,R,j,C)=>{l.push(c(y,v,U,O,R,j,C))});return this[o].apply(this,a),l};const u="filter"+t[0].toUpperCase()+t.slice(1);i.prototype[u]=function(){const a=Array.prototype.slice.call(arguments),c=a.pop(),l=[];return a.push((y,v,U,O,R,j,C)=>{c(y,v,U,O,R,j,C)&&l.push(y)}),this[o].apply(this,a),l};const h="reduce"+t[0].toUpperCase()+t.slice(1);i.prototype[h]=function(){let a=Array.prototype.slice.call(arguments);if(a.length<2||a.length>4)throw new G(`Graph.${h}: invalid number of arguments (expecting 2, 3 or 4 and got ${a.length}).`);if(typeof a[a.length-1]=="function"&&typeof a[a.length-2]!="function")throw new G(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c,l;a.length===2?(c=a[0],l=a[1],a=[]):a.length===3?(c=a[1],l=a[2],a=[a[0]]):a.length===4&&(c=a[2],l=a[3],a=[a[0],a[1]]);let y=l;return a.push((v,U,O,R,j,C,x)=>{y=c(y,v,U,O,R,j,C,x)}),this[o].apply(this,a),y}}function rn(i,e){const{name:t,type:n,direction:r}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);i.prototype[o]=function(h,a,c){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return c=h,et(!0,this,n,c);if(arguments.length===2){h=""+h,c=a;const l=this._nodes.get(h);if(typeof l>"u")throw new b(`Graph.${o}: could not find the "${h}" node in the graph.`);return Re(!0,this.multi,n==="mixed"?this.type:n,r,l,c)}if(arguments.length===3){h=""+h,a=""+a;const l=this._nodes.get(h);if(!l)throw new b(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(a))throw new b(`Graph.${o}: could not find the "${a}" target node in the graph.`);return je(!0,n,this.multi,r,l,a,c)}throw new G(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+t[0].toUpperCase()+t.slice(1,-1);i.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((l,y,v,U,O,R,j)=>a(l,y,v,U,O,R,j)),!!this[o].apply(this,h)};const u="every"+t[0].toUpperCase()+t.slice(1,-1);i.prototype[u]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((l,y,v,U,O,R,j)=>!a(l,y,v,U,O,R,j)),!this[o].apply(this,h)}}function on(i,e){const{name:t,type:n,direction:r}=e,o=t.slice(0,-1)+"Entries";i.prototype[o]=function(s,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ue();if(!arguments.length)return Jt(this,n);if(arguments.length===1){s=""+s;const h=this._nodes.get(s);if(!h)throw new b(`Graph.${o}: could not find the "${s}" node in the graph.`);return Xt(n,r,h)}if(arguments.length===2){s=""+s,u=""+u;const h=this._nodes.get(s);if(!h)throw new b(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(u))throw new b(`Graph.${o}: could not find the "${u}" target node in the graph.`);return en(n,r,h,u)}throw new G(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function sn(i){Bt.forEach(e=>{tn(i,e),nn(i,e),rn(i,e),on(i,e)})}const un=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Ge(){this.A=null,this.B=null}Ge.prototype.wrap=function(i){this.A===null?this.A=i:this.B===null&&(this.B=i)},Ge.prototype.has=function(i){return this.A!==null&&i in this.A||this.B!==null&&i in this.B};function ye(i,e,t,n,r){for(const o in n){const s=n[o],u=s.source,h=s.target,a=u===t?h:u;if(e&&e.has(a.key))continue;const c=r(a.key,a.attributes);if(i&&c)return a.key}}function ze(i,e,t,n,r){if(e!=="mixed"){if(e==="undirected")return ye(i,null,n,n.undirected,r);if(typeof t=="string")return ye(i,null,n,n[t],r)}const o=new Ge;let s;if(e!=="undirected"){if(t!=="out"){if(s=ye(i,null,n,n.in,r),i&&s)return s;o.wrap(n.in)}if(t!=="in"){if(s=ye(i,o,n,n.out,r),i&&s)return s;o.wrap(n.out)}}if(e!=="directed"&&(s=ye(i,o,n,n.undirected,r),i&&s))return s}function an(i,e,t){if(i!=="mixed"){if(i==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return ze(!1,i,e,t,function(r){n.push(r)}),n}function we(i,e,t){const n=Object.keys(t),r=n.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=r)return i&&i.wrap(t),{done:!0};const u=t[n[o++]],h=u.source,a=u.target;if(s=h===e?a:h,i&&i.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function hn(i,e,t){if(i!=="mixed"){if(i==="undirected")return we(null,t,t.undirected);if(typeof e=="string")return we(null,t,t[e])}let n=ue();const r=new Ge;return i!=="undirected"&&(e!=="out"&&(n=M(n,we(r,t,t.in))),e!=="in"&&(n=M(n,we(r,t,t.out)))),i!=="directed"&&(n=M(n,we(r,t,t.undirected))),n}function dn(i,e){const{name:t,type:n,direction:r}=e;i.prototype[t]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new b(`Graph.${t}: could not find the "${o}" node in the graph.`);return an(n==="mixed"?this.type:n,r,s)}}function cn(i,e){const{name:t,type:n,direction:r}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);i.prototype[o]=function(a,c){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new b(`Graph.${o}: could not find the "${a}" node in the graph.`);ze(!1,n==="mixed"?this.type:n,r,l,c)};const s="map"+t[0].toUpperCase()+t.slice(1);i.prototype[s]=function(a,c){const l=[];return this[o](a,(y,v)=>{l.push(c(y,v))}),l};const u="filter"+t[0].toUpperCase()+t.slice(1);i.prototype[u]=function(a,c){const l=[];return this[o](a,(y,v)=>{c(y,v)&&l.push(y)}),l};const h="reduce"+t[0].toUpperCase()+t.slice(1);i.prototype[h]=function(a,c,l){if(arguments.length<3)throw new G(`Graph.${h}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let y=l;return this[o](a,(v,U)=>{y=c(y,v,U)}),y}}function fn(i,e){const{name:t,type:n,direction:r}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;i.prototype[s]=function(a,c){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new b(`Graph.${s}: could not find the "${a}" node in the graph.`);return ze(!0,n==="mixed"?this.type:n,r,l,c)};const u="some"+o;i.prototype[u]=function(a,c){return!!this[s](a,c)};const h="every"+o;i.prototype[h]=function(a,c){return!this[s](a,(y,v)=>!c(y,v))}}function ln(i,e){const{name:t,type:n,direction:r}=e,o=t.slice(0,-1)+"Entries";i.prototype[o]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ue();s=""+s;const u=this._nodes.get(s);if(typeof u>"u")throw new b(`Graph.${o}: could not find the "${s}" node in the graph.`);return hn(n==="mixed"?this.type:n,r,u)}}function pn(i){un.forEach(e=>{dn(i,e),cn(i,e),fn(i,e),ln(i,e)})}function _e(i,e,t,n,r){const o=n._nodes.values(),s=n.type;let u,h,a,c,l,y;for(;u=o.next(),u.done!==!0;){let v=!1;if(h=u.value,s!=="undirected"){c=h.out;for(a in c){l=c[a];do y=l.target,v=!0,r(h.key,y.key,h.attributes,y.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(s!=="directed"){c=h.undirected;for(a in c)if(!(e&&h.key>a)){l=c[a];do y=l.target,y.key!==a&&(y=l.source),v=!0,r(h.key,y.key,h.attributes,y.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}t&&!v&&r(h.key,null,h.attributes,null,null,null,null)}}function gn(i,e){const t={key:i};return Ne(e.attributes)||(t.attributes=B({},e.attributes)),t}function yn(i,e,t){const n={key:e,source:t.source.key,target:t.target.key};return Ne(t.attributes)||(n.attributes=B({},t.attributes)),i==="mixed"&&t.undirected&&(n.undirected=!0),n}function wn(i){if(!q(i))throw new G('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in i))throw new G("Graph.import: serialized node is missing its key.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function bn(i){if(!q(i))throw new G('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in i))throw new G("Graph.import: serialized edge is missing its source.");if(!("target"in i))throw new G("Graph.import: serialized edge is missing its target.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in i&&typeof i.undirected!="boolean")throw new G("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const mn=vt(),vn=new Set(["directed","undirected","mixed"]),tt=new Set(["domain","_events","_eventsCount","_maxListeners"]),En=[{name:i=>`${i}Edge`,generateKey:!0},{name:i=>`${i}DirectedEdge`,generateKey:!0,type:"directed"},{name:i=>`${i}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:i=>`${i}EdgeWithKey`},{name:i=>`${i}DirectedEdgeWithKey`,type:"directed"},{name:i=>`${i}UndirectedEdgeWithKey`,type:"undirected"}],Gn={allowSelfLoops:!0,multi:!1,type:"mixed"};function _n(i,e,t){if(t&&!q(t))throw new G(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},i._nodes.has(e))throw new $(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new i.NodeDataClass(e,t);return i._nodes.set(e,n),i.emit("nodeAdded",{key:e,attributes:t}),n}function nt(i,e,t){const n=new i.NodeDataClass(e,t);return i._nodes.set(e,n),i.emit("nodeAdded",{key:e,attributes:t}),n}function it(i,e,t,n,r,o,s,u){if(!n&&i.type==="undirected")throw new $(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&i.type==="directed")throw new $(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(u&&!q(u))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${u}"`);if(o=""+o,s=""+s,u=u||{},!i.allowSelfLoops&&o===s)throw new $(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const h=i._nodes.get(o),a=i._nodes.get(s);if(!h)throw new b(`Graph.${e}: source node "${o}" not found.`);if(!a)throw new b(`Graph.${e}: target node "${s}" not found.`);const c={key:null,undirected:n,source:o,target:s,attributes:u};if(t)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new $(`Graph.${e}: the "${r}" edge already exists in the graph.`);if(!i.multi&&(n?typeof h.undirected[s]<"u":typeof h.out[s]<"u"))throw new $(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const l=new ae(n,r,h,a,u);i._edges.set(r,l);const y=o===s;return n?(h.undirectedDegree++,a.undirectedDegree++,y&&(h.undirectedLoops++,i._undirectedSelfLoopCount++)):(h.outDegree++,a.inDegree++,y&&(h.directedLoops++,i._directedSelfLoopCount++)),i.multi?l.attachMulti():l.attach(),n?i._undirectedSize++:i._directedSize++,c.key=r,i.emit("edgeAdded",c),r}function $n(i,e,t,n,r,o,s,u,h){if(!n&&i.type==="undirected")throw new $(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&i.type==="directed")throw new $(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(u){if(h){if(typeof u!="function")throw new G(`Graph.${e}: invalid updater function. Expecting a function but got "${u}"`)}else if(!q(u))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${u}"`)}o=""+o,s=""+s;let a;if(h&&(a=u,u=void 0),!i.allowSelfLoops&&o===s)throw new $(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let c=i._nodes.get(o),l=i._nodes.get(s),y,v;if(!t&&(y=i._edges.get(r),y)){if((y.source.key!==o||y.target.key!==s)&&(!n||y.source.key!==s||y.target.key!==o))throw new $(`Graph.${e}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${s}" target vs. ("${y.source.key}", "${y.target.key}").`);v=y}if(!v&&!i.multi&&c&&(v=n?c.undirected[s]:c.out[s]),v){const C=[v.key,!1,!1,!1];if(h?!a:!u)return C;if(h){const x=v.attributes;v.attributes=a(x),i.emit("edgeAttributesUpdated",{type:"replace",key:v.key,attributes:v.attributes})}else B(v.attributes,u),i.emit("edgeAttributesUpdated",{type:"merge",key:v.key,attributes:v.attributes,data:u});return C}u=u||{},h&&a&&(u=a(u));const U={key:null,undirected:n,source:o,target:s,attributes:u};if(t)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new $(`Graph.${e}: the "${r}" edge already exists in the graph.`);let O=!1,R=!1;c||(c=nt(i,o,{}),O=!0,o===s&&(l=c,R=!0)),l||(l=nt(i,s,{}),R=!0),y=new ae(n,r,c,l,u),i._edges.set(r,y);const j=o===s;return n?(c.undirectedDegree++,l.undirectedDegree++,j&&(c.undirectedLoops++,i._undirectedSelfLoopCount++)):(c.outDegree++,l.inDegree++,j&&(c.directedLoops++,i._directedSelfLoopCount++)),i.multi?y.attachMulti():y.attach(),n?i._undirectedSize++:i._directedSize++,U.key=r,i.emit("edgeAdded",U),[r,!0,O,R]}function he(i,e){i._edges.delete(e.key);const{source:t,target:n,attributes:r}=e,o=e.undirected,s=t===n;o?(t.undirectedDegree--,n.undirectedDegree--,s&&(t.undirectedLoops--,i._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,s&&(t.directedLoops--,i._directedSelfLoopCount--)),i.multi?e.detachMulti():e.detach(),o?i._undirectedSize--:i._directedSize--,i.emit("edgeDropped",{key:e.key,attributes:r,source:t.key,target:n.key,undirected:o})}class P extends bt.EventEmitter{constructor(e){if(super(),e=B({},Gn,e),typeof e.multi!="boolean")throw new G(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!vn.has(e.type))throw new G(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new G(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?Ye:e.type==="directed"?Ze:Je;Y(this,"NodeDataClass",t);const n="geid_"+mn()+"_";let r=0;const o=()=>{let s;do s=n+r++;while(this._edges.has(s));return s};Y(this,"_attributes",{}),Y(this,"_nodes",new Map),Y(this,"_edges",new Map),Y(this,"_directedSize",0),Y(this,"_undirectedSize",0),Y(this,"_directedSelfLoopCount",0),Y(this,"_undirectedSelfLoopCount",0),Y(this,"_edgeKeyGenerator",o),Y(this,"_options",e),tt.forEach(s=>Y(this,s,this[s])),Q(this,"order",()=>this._nodes.size),Q(this,"size",()=>this._edges.size),Q(this,"directedSize",()=>this._directedSize),Q(this,"undirectedSize",()=>this._undirectedSize),Q(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Q(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Q(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Q(this,"multi",this._options.multi),Q(this,"type",this._options.type),Q(this,"allowSelfLoops",this._options.allowSelfLoops),Q(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,r=this._edges.get(n);return!!r&&!r.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new G(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,r=this._edges.get(n);return!!r&&r.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new G(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new G(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new b(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new b(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new $("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.edge: could not find the "${t}" target node in the graph.`);const r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!=="directed"&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!=="directed"&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!=="directed"&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new b(`Graph.opposite: could not find the "${t}" edge in the graph.`);const r=n.source.key,o=n.target.key;if(e===r)return o;if(e===o)return r;throw new b(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new b(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return _n(this,e,t).key}mergeNode(e,t){if(t&&!q(t))throw new G(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(B(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new G(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const o=n.attributes;n.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:r}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const r in t.out){n=t.out[r];do he(this,n),n=n.next;while(n)}for(const r in t.in){n=t.in[r];do he(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const r in t.undirected){n=t.undirected[r];do he(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],r=""+arguments[1];if(t=V(this,n,r,this.type),!t)throw new b(`Graph.dropEdge: could not find the "${n}" -> "${r}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new b(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return he(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,t=""+t;const n=V(this,e,t,"directed");if(!n)throw new b(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return he(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new $("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new $("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=V(this,e,t,"undirected");if(!n)throw new b(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return he(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new G("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!q(e))throw new G("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!q(e))throw new G("Graph.mergeAttributes: provided attributes are not a plain object.");return B(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new G("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!="function")throw new G("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Ve(t))throw new G("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let r,o;for(;r=n.next(),r.done!==!0;)o=r.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new G("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Ve(t))throw new G("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let r,o,s,u;for(;r=n.next(),r.done!==!0;)o=r.value,s=o.source,u=o.target,o.attributes=e(o.key,o.attributes,s.key,u.key,s.attributes,u.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntry: expecting a callback.");_e(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");_e(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");_e(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");_e(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new G("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!="function")throw new G("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!="function")throw new G("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,r;const o=new Array(this.order);let s=0;for(;n=t.next(),n.done!==!0;)r=n.value,o[s++]=e(r.key,r.attributes);return o}someNode(e){if(typeof e!="function")throw new G("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new G("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new G("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,r;const o=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&o.push(r.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new G("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new G("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const r=this._nodes.values();let o,s;for(;o=r.next(),o.done!==!0;)s=o.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((r,o)=>{e[t++]=gn(o,r)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((r,o)=>{n[t++]=yn(this.type,o,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof P)return e.forEachNode((h,a)=>{t?this.mergeNode(h,a):this.addNode(h,a)}),e.forEachEdge((h,a,c,l,y,v,U)=>{t?U?this.mergeUndirectedEdgeWithKey(h,c,l,a):this.mergeDirectedEdgeWithKey(h,c,l,a):U?this.addUndirectedEdgeWithKey(h,c,l,a):this.addDirectedEdgeWithKey(h,c,l,a)}),this;if(!q(e))throw new G("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!q(e.attributes))throw new G("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,r,o,s,u;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new G("Graph.import: invalid nodes. Expecting an array.");for(n=0,r=o.length;n<r;n++){s=o[n],wn(s);const{key:h,attributes:a}=s;t?this.mergeNode(h,a):this.addNode(h,a)}}if(e.edges){let h=!1;if(this.type==="undirected"&&(h=!0),o=e.edges,!Array.isArray(o))throw new G("Graph.import: invalid edges. Expecting an array.");for(n=0,r=o.length;n<r;n++){u=o[n],bn(u);const{source:a,target:c,attributes:l,undirected:y=h}=u;let v;"key"in u?(v=t?y?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:y?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,v.call(this,u.key,a,c,l)):(v=t?y?this.mergeUndirectedEdge:this.mergeDirectedEdge:y?this.addUndirectedEdge:this.addDirectedEdge,v.call(this,a,c,l))}}return this}nullCopy(e){const t=new P(B({},this._options,e));return t.replaceAttributes(B({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,r)=>{const o=B({},n.attributes);n=new t.NodeDataClass(r,o),t._nodes.set(r,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new $(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new $("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new $("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let r,o;for(;r=n.next(),r.done!==!0;)o=r.value,it(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,B({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});const t={},n={};this._edges.forEach((o,s)=>{const u=o.undirected?"--":"->";let h="",a=o.source.key,c=o.target.key,l;o.undirected&&a>c&&(l=a,a=c,c=l);const y=`(${a})${u}(${c})`;s.startsWith("geid_")?this.multi&&(typeof n[y]>"u"?n[y]=0:n[y]++,h+=`${n[y]}. `):h+=`[${s}]: `,h+=y,t[h]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!tt.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,Y(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(P.prototype[Symbol.for("nodejs.util.inspect.custom")]=P.prototype.inspect),En.forEach(i=>{["add","merge","update"].forEach(e=>{const t=i.name(e),n=e==="add"?it:$n;i.generateKey?P.prototype[t]=function(r,o,s){return n(this,t,!0,(i.type||this.type)==="undirected",null,r,o,s,e==="update")}:P.prototype[t]=function(r,o,s,u){return n(this,t,!1,(i.type||this.type)==="undirected",r,o,s,u,e==="update")}})}),It(P),Ht(P),sn(P),pn(P);class rt extends P{constructor(e){const t=B({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new G("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new G('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ot extends P{constructor(e){const t=B({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new G("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new G('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class st extends P{constructor(e){const t=B({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new G("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ut extends P{constructor(e){const t=B({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new G("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new G('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class at extends P{constructor(e){const t=B({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new G("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new G('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function de(i){i.from=function(e,t){const n=B({},e.options,t),r=new i(n);return r.import(e),r}}de(P),de(rt),de(ot),de(st),de(ut),de(at),P.Graph=P,P.DirectedGraph=rt,P.UndirectedGraph=ot,P.MultiGraph=st,P.MultiDirectedGraph=ut,P.MultiUndirectedGraph=at,P.InvalidArgumentsGraphError=G,P.NotFoundGraphError=b,P.UsageGraphError=$;var Te,ht;function Dn(){return ht||(ht=1,Te=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),Te}var be={},dt;function kn(){if(dt)return be;dt=1;function i(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,r){var o={},s=function(a){return typeof a>"u"?r:a};typeof r=="function"&&(s=r);var u=function(a){return s(a[n])},h=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=u,o.fromGraph=function(a,c){return u(a.getNodeAttributes(c))},o.fromEntry=function(a,c){return u(c)}):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(a,c){return s(n(c,a.getNodeAttributes(c)))},o.fromEntry=function(a,c){return s(n(a,c))}):(o.fromAttributes=h,o.fromGraph=h,o.fromEntry=h),o}function t(n,r){var o={},s=function(a){return typeof a>"u"?r:a};typeof r=="function"&&(s=r);var u=function(a){return s(a[n])},h=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=u,o.fromGraph=function(a,c){return u(a.getEdgeAttributes(c))},o.fromEntry=function(a,c){return u(c)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(a,c){var l=a.extremities(c);return s(n(c,a.getEdgeAttributes(c),l[0],l[1],a.getNodeAttributes(l[0]),a.getNodeAttributes(l[1]),a.isUndirected(c)))},o.fromEntry=function(a,c,l,y,v,U,O){return s(n(a,c,l,y,v,U,O))},o.fromPartialEntry=function(a,c,l,y){return s(n(a,c,l,y))},o.fromMinimalEntry=function(a,c){return s(n(a,c))}):(o.fromAttributes=h,o.fromGraph=h,o.fromEntry=h,o.fromMinimalEntry=h),o}return be.createNodeValueGetter=e,be.createEdgeValueGetter=t,be.createEdgeWeightGetter=function(n){return t(n,i)},be}var We,ct;function An(){if(ct)return We;ct=1;var i=0,e=1,t=2,n=3,r=4,o=5,s=6,u=7,h=8,a=9,c=0,l=1,y=2,v=0,U=1,O=2,R=3,j=4,C=5,x=6,w=7,g=8,E=3,_=10,L=3,S=9,I=10;return We=function(z,d,ce){var Fe,m,f,K,H,ie,fe,N,A,He,X=d.length,Rn=ce.length,me=z.adjustSizes,jn=z.barnesHutTheta*z.barnesHutTheta,$e,F,T,W,ne,k,D,p=[];for(f=0;f<X;f+=_)d[f+r]=d[f+t],d[f+o]=d[f+n],d[f+t]=0,d[f+n]=0;if(z.outboundAttractionDistribution){for($e=0,f=0;f<X;f+=_)$e+=d[f+s];$e/=X/_}if(z.barnesHutOptimize){var re=1/0,le=-1/0,oe=1/0,pe=-1/0,J,ge,Be;for(f=0;f<X;f+=_)re=Math.min(re,d[f+i]),le=Math.max(le,d[f+i]),oe=Math.min(oe,d[f+e]),pe=Math.max(pe,d[f+e]);var De=le-re,ke=pe-oe;for(De>ke?(oe-=(De-ke)/2,pe=oe+De):(re-=(ke-De)/2,le=re+ke),p[0+v]=-1,p[0+U]=(re+le)/2,p[0+O]=(oe+pe)/2,p[0+R]=Math.max(le-re,pe-oe),p[0+j]=-1,p[0+C]=-1,p[0+x]=0,p[0+w]=0,p[0+g]=0,Fe=1,f=0;f<X;f+=_)for(m=0,Be=E;;)if(p[m+C]>=0){d[f+i]<p[m+U]?d[f+e]<p[m+O]?J=p[m+C]:J=p[m+C]+S:d[f+e]<p[m+O]?J=p[m+C]+S*2:J=p[m+C]+S*3,p[m+w]=(p[m+w]*p[m+x]+d[f+i]*d[f+s])/(p[m+x]+d[f+s]),p[m+g]=(p[m+g]*p[m+x]+d[f+e]*d[f+s])/(p[m+x]+d[f+s]),p[m+x]+=d[f+s],m=J;continue}else if(p[m+v]<0){p[m+v]=f;break}else{if(p[m+C]=Fe*S,N=p[m+R]/2,A=p[m+C],p[A+v]=-1,p[A+U]=p[m+U]-N,p[A+O]=p[m+O]-N,p[A+R]=N,p[A+j]=A+S,p[A+C]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]-N,p[A+O]=p[m+O]+N,p[A+R]=N,p[A+j]=A+S,p[A+C]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]+N,p[A+O]=p[m+O]-N,p[A+R]=N,p[A+j]=A+S,p[A+C]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]+N,p[A+O]=p[m+O]+N,p[A+R]=N,p[A+j]=p[m+j],p[A+C]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,Fe+=4,d[p[m+v]+i]<p[m+U]?d[p[m+v]+e]<p[m+O]?J=p[m+C]:J=p[m+C]+S:d[p[m+v]+e]<p[m+O]?J=p[m+C]+S*2:J=p[m+C]+S*3,p[m+x]=d[p[m+v]+s],p[m+w]=d[p[m+v]+i],p[m+g]=d[p[m+v]+e],p[J+v]=p[m+v],p[m+v]=-1,d[f+i]<p[m+U]?d[f+e]<p[m+O]?ge=p[m+C]:ge=p[m+C]+S:d[f+e]<p[m+O]?ge=p[m+C]+S*2:ge=p[m+C]+S*3,J===ge)if(Be--){m=J;continue}else{Be=E;break}p[ge+v]=f;break}}if(z.barnesHutOptimize)for(F=z.scalingRatio,f=0;f<X;f+=_)for(m=0;;)if(p[m+C]>=0)if(k=Math.pow(d[f+i]-p[m+w],2)+Math.pow(d[f+e]-p[m+g],2),He=p[m+R],4*He*He/k<jn){if(T=d[f+i]-p[m+w],W=d[f+e]-p[m+g],me===!0?k>0?(D=F*d[f+s]*p[m+x]/k,d[f+t]+=T*D,d[f+n]+=W*D):k<0&&(D=-F*d[f+s]*p[m+x]/Math.sqrt(k),d[f+t]+=T*D,d[f+n]+=W*D):k>0&&(D=F*d[f+s]*p[m+x]/k,d[f+t]+=T*D,d[f+n]+=W*D),m=p[m+j],m<0)break;continue}else{m=p[m+C];continue}else{if(ie=p[m+v],ie>=0&&ie!==f&&(T=d[f+i]-d[ie+i],W=d[f+e]-d[ie+e],k=T*T+W*W,me===!0?k>0?(D=F*d[f+s]*d[ie+s]/k,d[f+t]+=T*D,d[f+n]+=W*D):k<0&&(D=-F*d[f+s]*d[ie+s]/Math.sqrt(k),d[f+t]+=T*D,d[f+n]+=W*D):k>0&&(D=F*d[f+s]*d[ie+s]/k,d[f+t]+=T*D,d[f+n]+=W*D)),m=p[m+j],m<0)break;continue}else for(F=z.scalingRatio,K=0;K<X;K+=_)for(H=0;H<K;H+=_)T=d[K+i]-d[H+i],W=d[K+e]-d[H+e],me===!0?(k=Math.sqrt(T*T+W*W)-d[K+h]-d[H+h],k>0?(D=F*d[K+s]*d[H+s]/k/k,d[K+t]+=T*D,d[K+n]+=W*D,d[H+t]-=T*D,d[H+n]-=W*D):k<0&&(D=100*F*d[K+s]*d[H+s],d[K+t]+=T*D,d[K+n]+=W*D,d[H+t]-=T*D,d[H+n]-=W*D)):(k=Math.sqrt(T*T+W*W),k>0&&(D=F*d[K+s]*d[H+s]/k/k,d[K+t]+=T*D,d[K+n]+=W*D,d[H+t]-=T*D,d[H+n]-=W*D));for(A=z.gravity/z.scalingRatio,F=z.scalingRatio,f=0;f<X;f+=_)D=0,T=d[f+i],W=d[f+e],k=Math.sqrt(Math.pow(T,2)+Math.pow(W,2)),z.strongGravityMode?k>0&&(D=F*d[f+s]*A):k>0&&(D=F*d[f+s]*A/k),d[f+t]-=T*D,d[f+n]-=W*D;for(F=1*(z.outboundAttractionDistribution?$e:1),fe=0;fe<Rn;fe+=L)K=ce[fe+c],H=ce[fe+l],N=ce[fe+y],ne=Math.pow(N,z.edgeWeightInfluence),T=d[K+i]-d[H+i],W=d[K+e]-d[H+e],me===!0?(k=Math.sqrt(T*T+W*W)-d[K+h]-d[H+h],z.linLogMode?z.outboundAttractionDistribution?k>0&&(D=-F*ne*Math.log(1+k)/k/d[K+s]):k>0&&(D=-F*ne*Math.log(1+k)/k):z.outboundAttractionDistribution?k>0&&(D=-F*ne/d[K+s]):k>0&&(D=-F*ne)):(k=Math.sqrt(Math.pow(T,2)+Math.pow(W,2)),z.linLogMode?z.outboundAttractionDistribution?k>0&&(D=-F*ne*Math.log(1+k)/k/d[K+s]):k>0&&(D=-F*ne*Math.log(1+k)/k):z.outboundAttractionDistribution?(k=1,D=-F*ne/d[K+s]):(k=1,D=-F*ne)),k>0&&(d[K+t]+=T*D,d[K+n]+=W*D,d[H+t]-=T*D,d[H+n]-=W*D);var Ae,ve,Le,se,Se,Ue;if(me===!0)for(f=0;f<X;f+=_)d[f+a]!==1&&(Ae=Math.sqrt(Math.pow(d[f+t],2)+Math.pow(d[f+n],2)),Ae>I&&(d[f+t]=d[f+t]*I/Ae,d[f+n]=d[f+n]*I/Ae),ve=d[f+s]*Math.sqrt((d[f+r]-d[f+t])*(d[f+r]-d[f+t])+(d[f+o]-d[f+n])*(d[f+o]-d[f+n])),Le=Math.sqrt((d[f+r]+d[f+t])*(d[f+r]+d[f+t])+(d[f+o]+d[f+n])*(d[f+o]+d[f+n]))/2,se=.1*Math.log(1+Le)/(1+Math.sqrt(ve)),Se=d[f+i]+d[f+t]*(se/z.slowDown),d[f+i]=Se,Ue=d[f+e]+d[f+n]*(se/z.slowDown),d[f+e]=Ue);else for(f=0;f<X;f+=_)d[f+a]!==1&&(ve=d[f+s]*Math.sqrt((d[f+r]-d[f+t])*(d[f+r]-d[f+t])+(d[f+o]-d[f+n])*(d[f+o]-d[f+n])),Le=Math.sqrt((d[f+r]+d[f+t])*(d[f+r]+d[f+t])+(d[f+o]+d[f+n])*(d[f+o]+d[f+n]))/2,se=d[f+u]*Math.log(1+Le)/(1+Math.sqrt(ve)),d[f+u]=Math.min(1,Math.sqrt(se*(Math.pow(d[f+t],2)+Math.pow(d[f+n],2))/(1+Math.sqrt(ve)))),Se=d[f+i]+d[f+t]*(se/z.slowDown),d[f+i]=Se,Ue=d[f+e]+d[f+n]*(se/z.slowDown),d[f+e]=Ue);return{}},We}var te={},ft;function Ln(){if(ft)return te;ft=1;var i=10,e=3;return te.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),r,o,s;for(r=0,s=n.length;r<s;r++)if(n[r])for(o in n[r])t[o]=n[r][o];return t},te.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},te.graphToByteArrays=function(t,n){var r=t.order,o=t.size,s={},u,h=new Float32Array(r*i),a=new Float32Array(o*e);return u=0,t.forEachNode(function(c,l){s[c]=u,h[u]=l.x,h[u+1]=l.y,h[u+2]=0,h[u+3]=0,h[u+4]=0,h[u+5]=0,h[u+6]=1,h[u+7]=1,h[u+8]=l.size||1,h[u+9]=l.fixed?1:0,u+=i}),u=0,t.forEachEdge(function(c,l,y,v,U,O,R){var j=s[y],C=s[v],x=n(c,l,y,v,U,O,R);h[j+6]+=x,h[C+6]+=x,a[u]=j,a[u+1]=C,a[u+2]=x,u+=e}),{nodes:h,edges:a}},te.assignLayoutChanges=function(t,n,r){var o=0;t.updateEachNodeAttributes(function(s,u){return u.x=n[o],u.y=n[o+1],o+=i,r?r(s,u):u})},te.readGraphPositions=function(t,n){var r=0;t.forEachNode(function(o,s){n[r]=s.x,n[r+1]=s.y,r+=i})},te.collectLayoutChanges=function(t,n,r){for(var o=t.nodes(),s={},u=0,h=0,a=n.length;u<a;u+=i){if(r){var c=Object.assign({},t.getNodeAttributes(o[h]));c.x=n[u],c.y=n[u+1],c=r(o[h],c),s[o[h]]={x:c.x,y:c.y}}else s[o[h]]={x:n[u],y:n[u+1]};h++}return s},te.createWorker=function(n){var r=window.URL||window.webkitURL,o=n.toString(),s=r.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),u=new Worker(s);return r.revokeObjectURL(s),u},te}var Pe,lt;function Sn(){return lt||(lt=1,Pe={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),Pe}var xe,pt;function Un(){if(pt)return xe;pt=1;var i=Dn(),e=kn().createEdgeWeightGetter,t=An(),n=Ln(),r=Sn();function o(h,a,c){if(!i(a))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof c=="number"&&(c={iterations:c});var l=c.iterations;if(typeof l!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var y=e("getEdgeWeight"in c?c.getEdgeWeight:"weight").fromEntry,v=typeof c.outputReducer=="function"?c.outputReducer:null,U=n.assign({},r,c.settings),O=n.validateSettings(U);if(O)throw new Error("graphology-layout-forceatlas2: "+O.message);var R=n.graphToByteArrays(a,y),j;for(j=0;j<l;j++)t(U,R.nodes,R.edges);if(h){n.assignLayoutChanges(a,R.nodes,v);return}return n.collectLayoutChanges(a,R.nodes)}function s(h){var a=typeof h=="number"?h:h.order;return{barnesHutOptimize:a>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(a)}}var u=o.bind(null,!1);return u.assign=o.bind(null,!0),u.inferSettings=s,xe=u,xe}var On=Un(),gt=yt(On);const In=12;let Ke=!1;self.onmessage=i=>{const e=i.data;if(e.type==="stop"){Ke=!0;return}e.type==="start"&&(Ke=!1,Cn(e))};function Cn(i){const e=new P({type:"undirected",multi:!1});for(const h of i.nodes)e.addNode(h.id,{x:h.x,y:h.y,size:1+Math.sqrt(h.degree)});for(const h of i.edges)!e.hasNode(h.source)||!e.hasNode(h.target)||h.source!==h.target&&(e.hasEdge(h.source,h.target)||e.addUndirectedEdge(h.source,h.target,{weight:h.weight}));const t=e.order;if(t===0){self.postMessage({type:"done"});return}const r={...gt.inferSettings(e),outboundAttractionDistribution:!0,gravity:.12,scalingRatio:50,adjustSizes:!1,edgeWeightInfluence:1,barnesHutOptimize:t>500},o=e.nodes();self.postMessage({type:"order",ids:o});let s=0;const u=()=>{if(Ke)return;const h=Math.min(In,i.iterations-s);gt.assign(e,{iterations:h,settings:r}),s+=h;const a=new Float32Array(o.length*2);for(let c=0;c<o.length;c++){const l=e.getNodeAttributes(o[c]);a[c*2]=l.x,a[c*2+1]=l.y}if(self.postMessage({type:"positions",coords:a},[a.buffer]),s>=i.iterations){self.postMessage({type:"done"});return}setTimeout(u,0)};u()}})();
@@ -1 +1 @@
1
- import{_ as ce}from"./main-Dznkfxsd.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
1
+ import{_ as ce}from"./main-BrYtWn-4.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
@@ -1 +1 @@
1
- import{s as _,_ as d,r as s,a as u}from"./main-Dznkfxsd.js";import{C as T,P as y,W as E,d as L,b as g,c as v,h as P,l as b,m as k,e as D,n as O,f as R,g as S,t as V}from"./main-Dznkfxsd.js";async function h(o,e={}){const i=e.loading===!1?void 0:_(o,e.loadingText??"Loading…"),[{Terminal:l},{FitAddon:c}]=await Promise.all([d(()=>import("./xterm-B-qIQCd3.js"),[]),d(()=>import("./addon-fit-DX4qG4td.js"),[])]).catch(r=>{throw i?.(),r}),a=new l({scrollback:e.scrollback??5e3,fontSize:e.fontSize??13,fontFamily:e.fontFamily??"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:e.lineHeight??1,cursorBlink:e.cursorBlink??!1,cursorStyle:e.cursorStyle??"block",disableStdin:e.stdin!==!0,allowProposedApi:!0,convertEol:!0,theme:s(e.theme),...e.cols?{cols:e.cols}:{},...e.rows?{rows:e.rows}:{},...e.terminalOptions??{}}),t=e.fit===!1?void 0:new c;if(t&&a.loadAddon(t),e.clipboard)try{const{ClipboardAddon:r}=await d(()=>import("./addon-clipboard-wHJhZAA4.js"),[]);a.loadAddon(new r)}catch{}if(e.webLinks)try{const{WebLinksAddon:r}=await d(()=>import("./addon-web-links-DIbG5aQx.js"),[]);a.loadAddon(new r)}catch{}if(e.unicode11)try{const{Unicode11Addon:r}=await d(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]);a.loadAddon(new r),a.unicode.activeVersion="11"}catch{}for(const r of e.addons??[])a.loadAddon(r);if(a.open(o),e.ligatures)try{const{LigaturesAddon:r}=await d(()=>import("./addon-ligatures-DpDY8N_X.js"),[]);a.loadAddon(new r)}catch{}const m=t?u({resize:async()=>{}},a,t,{debounceMs:e.fitDebounceMs??100}):void 0;e.onReady?.(a),i?.();let n=!1;return{terminal:a,fitAddon:t,write:r=>a.write(r),clear:()=>{a.clear(),a.reset()},fit:()=>t?.fit(),setTheme:r=>{a.options.theme=s(r)},dispose(){n||(n=!0,m?.(),a.dispose())}}}export{T as ClientSession,y as PtyKitClient,E as WsCore,u as attachFit,L as darkTheme,g as defaultPersistence,v as draculaTheme,P as hostSocket,b as lightTheme,k as matrixTheme,D as mountTerminal,h as mountViewer,O as nordTheme,s as resolveTheme,_ as showLoadingOverlay,R as solarizedDarkTheme,S as solarizedLightTheme,V as themes};
1
+ import{s as _,_ as d,r as s,a as u}from"./main-BrYtWn-4.js";import{C as T,P as y,W as E,d as L,b as g,c as v,h as P,l as b,m as k,e as D,n as O,f as R,g as S,t as V}from"./main-BrYtWn-4.js";async function h(o,e={}){const i=e.loading===!1?void 0:_(o,e.loadingText??"Loading…"),[{Terminal:l},{FitAddon:c}]=await Promise.all([d(()=>import("./xterm-B-qIQCd3.js"),[]),d(()=>import("./addon-fit-DX4qG4td.js"),[])]).catch(r=>{throw i?.(),r}),a=new l({scrollback:e.scrollback??5e3,fontSize:e.fontSize??13,fontFamily:e.fontFamily??"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:e.lineHeight??1,cursorBlink:e.cursorBlink??!1,cursorStyle:e.cursorStyle??"block",disableStdin:e.stdin!==!0,allowProposedApi:!0,convertEol:!0,theme:s(e.theme),...e.cols?{cols:e.cols}:{},...e.rows?{rows:e.rows}:{},...e.terminalOptions??{}}),t=e.fit===!1?void 0:new c;if(t&&a.loadAddon(t),e.clipboard)try{const{ClipboardAddon:r}=await d(()=>import("./addon-clipboard-wHJhZAA4.js"),[]);a.loadAddon(new r)}catch{}if(e.webLinks)try{const{WebLinksAddon:r}=await d(()=>import("./addon-web-links-DIbG5aQx.js"),[]);a.loadAddon(new r)}catch{}if(e.unicode11)try{const{Unicode11Addon:r}=await d(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]);a.loadAddon(new r),a.unicode.activeVersion="11"}catch{}for(const r of e.addons??[])a.loadAddon(r);if(a.open(o),e.ligatures)try{const{LigaturesAddon:r}=await d(()=>import("./addon-ligatures-DpDY8N_X.js"),[]);a.loadAddon(new r)}catch{}const m=t?u({resize:async()=>{}},a,t,{debounceMs:e.fitDebounceMs??100}):void 0;e.onReady?.(a),i?.();let n=!1;return{terminal:a,fitAddon:t,write:r=>a.write(r),clear:()=>{a.clear(),a.reset()},fit:()=>t?.fit(),setTheme:r=>{a.options.theme=s(r)},dispose(){n||(n=!0,m?.(),a.dispose())}}}export{T as ClientSession,y as PtyKitClient,E as WsCore,u as attachFit,L as darkTheme,g as defaultPersistence,v as draculaTheme,P as hostSocket,b as lightTheme,k as matrixTheme,D as mountTerminal,h as mountViewer,O as nordTheme,s as resolveTheme,_ as showLoadingOverlay,R as solarizedDarkTheme,S as solarizedLightTheme,V as themes};