@aidapt/caity-chat 3.0.0

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 (62) hide show
  1. package/README.md +73 -0
  2. package/dist/lib/_baseUniq-BVCT-t6P.js +477 -0
  3. package/dist/lib/arc-Kj6ZmwPS.js +83 -0
  4. package/dist/lib/architectureDiagram-Q4EWVU46-DA4kYaz_.js +4690 -0
  5. package/dist/lib/blockDiagram-DXYQGD6D-BWT5yya1.js +2295 -0
  6. package/dist/lib/c4Diagram-AHTNJAMY-BjY6DW3U.js +1577 -0
  7. package/dist/lib/caity-chat.tgz +0 -0
  8. package/dist/lib/channel-BjraetTo.js +5 -0
  9. package/dist/lib/chunk-4BX2VUAB-iSPZGgxQ.js +8 -0
  10. package/dist/lib/chunk-4TB4RGXK-DvnUcLoe.js +1465 -0
  11. package/dist/lib/chunk-55IACEB6-Mw25YX9j.js +8 -0
  12. package/dist/lib/chunk-EDXVE4YY-Dtbxz7df.js +19 -0
  13. package/dist/lib/chunk-FMBD7UC4-OCIy3top.js +19 -0
  14. package/dist/lib/chunk-OYMX7WX6-DFW9El2C.js +1383 -0
  15. package/dist/lib/chunk-QZHKN3VN-BYFTfk7k.js +15 -0
  16. package/dist/lib/chunk-YZCP3GAM-Cs-HTcyJ.js +68 -0
  17. package/dist/lib/classDiagram-6PBFFD2Q-CrDUlIYr.js +16 -0
  18. package/dist/lib/classDiagram-v2-HSJHXN6E-CrDUlIYr.js +16 -0
  19. package/dist/lib/clone-C0qEGPCz.js +8 -0
  20. package/dist/lib/cose-bilkent-S5V4N54A-H1-YbKvI.js +2609 -0
  21. package/dist/lib/cytoscape.esm-D_3MZVO6.js +18707 -0
  22. package/dist/lib/dagre-KV5264BT-DhEnTJ4D.js +443 -0
  23. package/dist/lib/defaultLocale-BgPVtth8.js +171 -0
  24. package/dist/lib/diagram-5BDNPKRD-CK6wgKxI.js +123 -0
  25. package/dist/lib/diagram-G4DWMVQ6-IhA_MJ0t.js +528 -0
  26. package/dist/lib/diagram-MMDJMWI5-DDuA1rYY.js +217 -0
  27. package/dist/lib/diagram-TYMM5635-_VI1en0S.js +142 -0
  28. package/dist/lib/erDiagram-SMLLAGMA-B1REwW7y.js +899 -0
  29. package/dist/lib/flowDiagram-DWJPFMVM-rWzOGDlg.js +1628 -0
  30. package/dist/lib/ganttDiagram-T4ZO3ILL-UhSvbAmM.js +2701 -0
  31. package/dist/lib/gitGraphDiagram-UUTBAWPF-DrsSMMoJ.js +815 -0
  32. package/dist/lib/graph-DMr8NrNW.js +738 -0
  33. package/dist/lib/index.d.ts +665 -0
  34. package/dist/lib/index.js +52 -0
  35. package/dist/lib/infoDiagram-42DDH7IO-CPF3XCNj.js +24 -0
  36. package/dist/lib/init-DjUOC4st.js +16 -0
  37. package/dist/lib/ishikawaDiagram-UXIWVN3A-B4Nt1TdW.js +621 -0
  38. package/dist/lib/journeyDiagram-VCZTEJTY-DW5yRsOM.js +834 -0
  39. package/dist/lib/kanban-definition-6JOO6SKY-5DmJRubo.js +724 -0
  40. package/dist/lib/layout-B00IQLgh.js +1441 -0
  41. package/dist/lib/linear-LLab47WO.js +259 -0
  42. package/dist/lib/main-C9dvh9CT.js +88771 -0
  43. package/dist/lib/mermaid.core-BrBkhL9h.js +15967 -0
  44. package/dist/lib/min-CJFyJhXg.js +38 -0
  45. package/dist/lib/mindmap-definition-QFDTVHPH-doqZCFNi.js +833 -0
  46. package/dist/lib/ordinal-B6-f3MAq.js +61 -0
  47. package/dist/lib/pieDiagram-DEJITSTG-DKi5GKup.js +163 -0
  48. package/dist/lib/quadrantDiagram-34T5L4WZ-COYWmEhy.js +1022 -0
  49. package/dist/lib/requirementDiagram-MS252O5E-D3odK6YH.js +882 -0
  50. package/dist/lib/sankeyDiagram-XADWPNL6-D36eaMCx.js +810 -0
  51. package/dist/lib/sequenceDiagram-FGHM5R23-NpESTwMk.js +2883 -0
  52. package/dist/lib/standalone.js +4 -0
  53. package/dist/lib/stateDiagram-FHFEXIEX-kXZ_Bn-a.js +263 -0
  54. package/dist/lib/stateDiagram-v2-QKLJ7IA2-B5xMdEuE.js +16 -0
  55. package/dist/lib/timeline-definition-GMOUNBTQ-DZDdcJwy.js +1055 -0
  56. package/dist/lib/vennDiagram-DHZGUBPP-Clhb6EGF.js +1557 -0
  57. package/dist/lib/wardley-RL74JXVD-CwSnyVu7.js +18396 -0
  58. package/dist/lib/wardleyDiagram-NUSXRM2D-DnXL4F04.js +594 -0
  59. package/dist/lib/xychartDiagram-5P7HB3ND-CweIkrg3.js +1342 -0
  60. package/package.json +95 -0
  61. package/src/types/caity-chat.d.ts +213 -0
  62. package/src/types/template-slots.d.ts +167 -0
@@ -0,0 +1,738 @@
1
+ import { aR as T, aS as C, aT as z, aU as R, aV as S, aW as k, aX as V, aY as L, aZ as K, a_ as j, a$ as ee, b0 as te, b1 as re, b2 as se, b3 as ne, b4 as ie, aH as ae, b5 as oe, b6 as ue, b7 as he, b8 as y, b9 as $, ba as v } from "./mermaid.core-BrBkhL9h.js";
2
+ import { k as d, g as Y, s as de, e as ce, f as fe, h as ge, j as le, d as be, l as _e, b as pe, m, n as g, r as ye } from "./_baseUniq-BVCT-t6P.js";
3
+ function me(t, e) {
4
+ return t && T(e, d(e), t);
5
+ }
6
+ function je(t, e) {
7
+ return t && T(e, C(e), t);
8
+ }
9
+ function Te(t, e) {
10
+ return T(t, Y(t), e);
11
+ }
12
+ var Oe = Object.getOwnPropertySymbols, H = Oe ? function(t) {
13
+ for (var e = []; t; )
14
+ ce(e, Y(t)), t = z(t);
15
+ return e;
16
+ } : de;
17
+ function Ae(t, e) {
18
+ return T(t, H(t), e);
19
+ }
20
+ function Ee(t) {
21
+ return fe(t, C, H);
22
+ }
23
+ var Ce = Object.prototype, Le = Ce.hasOwnProperty;
24
+ function we(t) {
25
+ var e = t.length, r = new t.constructor(e);
26
+ return e && typeof t[0] == "string" && Le.call(t, "index") && (r.index = t.index, r.input = t.input), r;
27
+ }
28
+ function Ne(t, e) {
29
+ var r = e ? R(t.buffer) : t.buffer;
30
+ return new t.constructor(r, t.byteOffset, t.byteLength);
31
+ }
32
+ var Fe = /\w*$/;
33
+ function Pe(t) {
34
+ var e = new t.constructor(t.source, Fe.exec(t));
35
+ return e.lastIndex = t.lastIndex, e;
36
+ }
37
+ var I = S ? S.prototype : void 0, D = I ? I.valueOf : void 0;
38
+ function Se(t) {
39
+ return D ? Object(D.call(t)) : {};
40
+ }
41
+ var $e = "[object Boolean]", ve = "[object Date]", Ie = "[object Map]", De = "[object Number]", Me = "[object RegExp]", Ue = "[object Set]", Ge = "[object String]", xe = "[object Symbol]", Be = "[object ArrayBuffer]", Re = "[object DataView]", Ve = "[object Float32Array]", Ke = "[object Float64Array]", Ye = "[object Int8Array]", He = "[object Int16Array]", We = "[object Int32Array]", qe = "[object Uint8Array]", Xe = "[object Uint8ClampedArray]", Ze = "[object Uint16Array]", Je = "[object Uint32Array]";
42
+ function Qe(t, e, r) {
43
+ var s = t.constructor;
44
+ switch (e) {
45
+ case Be:
46
+ return R(t);
47
+ case $e:
48
+ case ve:
49
+ return new s(+t);
50
+ case Re:
51
+ return Ne(t, r);
52
+ case Ve:
53
+ case Ke:
54
+ case Ye:
55
+ case He:
56
+ case We:
57
+ case qe:
58
+ case Xe:
59
+ case Ze:
60
+ case Je:
61
+ return k(t, r);
62
+ case Ie:
63
+ return new s();
64
+ case De:
65
+ case Ge:
66
+ return new s(t);
67
+ case Me:
68
+ return Pe(t);
69
+ case Ue:
70
+ return new s();
71
+ case xe:
72
+ return Se(t);
73
+ }
74
+ }
75
+ var ze = "[object Map]";
76
+ function ke(t) {
77
+ return V(t) && L(t) == ze;
78
+ }
79
+ var M = j && j.isMap, et = M ? K(M) : ke, tt = "[object Set]";
80
+ function rt(t) {
81
+ return V(t) && L(t) == tt;
82
+ }
83
+ var U = j && j.isSet, st = U ? K(U) : rt, nt = 1, it = 2, at = 4, W = "[object Arguments]", ot = "[object Array]", ut = "[object Boolean]", ht = "[object Date]", dt = "[object Error]", q = "[object Function]", ct = "[object GeneratorFunction]", ft = "[object Map]", gt = "[object Number]", X = "[object Object]", lt = "[object RegExp]", bt = "[object Set]", _t = "[object String]", pt = "[object Symbol]", yt = "[object WeakMap]", mt = "[object ArrayBuffer]", jt = "[object DataView]", Tt = "[object Float32Array]", Ot = "[object Float64Array]", At = "[object Int8Array]", Et = "[object Int16Array]", Ct = "[object Int32Array]", Lt = "[object Uint8Array]", wt = "[object Uint8ClampedArray]", Nt = "[object Uint16Array]", Ft = "[object Uint32Array]", o = {};
84
+ o[W] = o[ot] = o[mt] = o[jt] = o[ut] = o[ht] = o[Tt] = o[Ot] = o[At] = o[Et] = o[Ct] = o[ft] = o[gt] = o[X] = o[lt] = o[bt] = o[_t] = o[pt] = o[Lt] = o[wt] = o[Nt] = o[Ft] = !0;
85
+ o[dt] = o[q] = o[yt] = !1;
86
+ function O(t, e, r, s, n, a) {
87
+ var i, u = e & nt, h = e & it, J = e & at;
88
+ if (i !== void 0)
89
+ return i;
90
+ if (!ee(t))
91
+ return t;
92
+ var w = ae(t);
93
+ if (w) {
94
+ if (i = we(t), !u)
95
+ return te(t, i);
96
+ } else {
97
+ var b = L(t), N = b == q || b == ct;
98
+ if (re(t))
99
+ return se(t, u);
100
+ if (b == X || b == W || N && !n) {
101
+ if (i = h || N ? {} : ne(t), !u)
102
+ return h ? Ae(t, je(i, t)) : Te(t, me(i, t));
103
+ } else {
104
+ if (!o[b])
105
+ return n ? t : {};
106
+ i = Qe(t, b, u);
107
+ }
108
+ }
109
+ a || (a = new ie());
110
+ var F = a.get(t);
111
+ if (F)
112
+ return F;
113
+ a.set(t, i), st(t) ? t.forEach(function(c) {
114
+ i.add(O(c, e, r, c, t, a));
115
+ }) : et(t) && t.forEach(function(c, f) {
116
+ i.set(f, O(c, e, r, f, t, a));
117
+ });
118
+ var Q = J ? h ? Ee : le : h ? C : d, P = w ? void 0 : Q(t);
119
+ return ge(P || t, function(c, f) {
120
+ P && (f = c, c = t[f]), oe(i, f, O(c, e, r, f, t, a));
121
+ }), i;
122
+ }
123
+ function Pt(t, e) {
124
+ return be(e, function(r) {
125
+ return t[r];
126
+ });
127
+ }
128
+ function A(t) {
129
+ return t == null ? [] : Pt(t, d(t));
130
+ }
131
+ function _(t) {
132
+ return t === void 0;
133
+ }
134
+ var St = ue(function(t) {
135
+ return _e(pe(t, 1, he, !0));
136
+ }), $t = "\0", l = "\0", G = "";
137
+ class Z {
138
+ /**
139
+ * @param {GraphOptions} [opts] - Graph options.
140
+ */
141
+ constructor(e = {}) {
142
+ this._isDirected = Object.prototype.hasOwnProperty.call(e, "directed") ? e.directed : !0, this._isMultigraph = Object.prototype.hasOwnProperty.call(e, "multigraph") ? e.multigraph : !1, this._isCompound = Object.prototype.hasOwnProperty.call(e, "compound") ? e.compound : !1, this._label = void 0, this._defaultNodeLabelFn = y(void 0), this._defaultEdgeLabelFn = y(void 0), this._nodes = {}, this._isCompound && (this._parent = {}, this._children = {}, this._children[l] = {}), this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {};
143
+ }
144
+ /* === Graph functions ========= */
145
+ /**
146
+ *
147
+ * @returns {boolean} `true` if the graph is [directed](https://en.wikipedia.org/wiki/Directed_graph).
148
+ * A directed graph treats the order of nodes in an edge as significant whereas an
149
+ * [undirected](https://en.wikipedia.org/wiki/Graph_(mathematics)#Undirected_graph)
150
+ * graph does not.
151
+ * This example demonstrates the difference:
152
+ *
153
+ * @example
154
+ *
155
+ * ```js
156
+ * var directed = new Graph({ directed: true });
157
+ * directed.setEdge("a", "b", "my-label");
158
+ * directed.edge("a", "b"); // returns "my-label"
159
+ * directed.edge("b", "a"); // returns undefined
160
+ *
161
+ * var undirected = new Graph({ directed: false });
162
+ * undirected.setEdge("a", "b", "my-label");
163
+ * undirected.edge("a", "b"); // returns "my-label"
164
+ * undirected.edge("b", "a"); // returns "my-label"
165
+ * ```
166
+ */
167
+ isDirected() {
168
+ return this._isDirected;
169
+ }
170
+ /**
171
+ * @returns {boolean} `true` if the graph is a multigraph.
172
+ */
173
+ isMultigraph() {
174
+ return this._isMultigraph;
175
+ }
176
+ /**
177
+ * @returns {boolean} `true` if the graph is compound.
178
+ */
179
+ isCompound() {
180
+ return this._isCompound;
181
+ }
182
+ /**
183
+ * Sets the label for the graph to `label`.
184
+ *
185
+ * @param {GraphLabel} label - Label for the graph.
186
+ * @returns {this}
187
+ */
188
+ setGraph(e) {
189
+ return this._label = e, this;
190
+ }
191
+ /**
192
+ * @returns {GraphLabel | undefined} the currently assigned label for the graph.
193
+ * If no label has been assigned, returns `undefined`.
194
+ *
195
+ * @example
196
+ *
197
+ * ```js
198
+ * var g = new Graph();
199
+ * g.graph(); // returns undefined
200
+ * g.setGraph("graph-label");
201
+ * g.graph(); // returns "graph-label"
202
+ * ```
203
+ */
204
+ graph() {
205
+ return this._label;
206
+ }
207
+ /* === Node functions ========== */
208
+ /**
209
+ * Sets a new default value that is assigned to nodes that are created without
210
+ * a label.
211
+ *
212
+ * @param {typeof this._defaultNodeLabelFn | NodeLabel} newDefault - If a function,
213
+ * it is called with the id of the node being created.
214
+ * Otherwise, it is assigned as the label directly.
215
+ * @returns {this}
216
+ */
217
+ setDefaultNodeLabel(e) {
218
+ return $(e) || (e = y(e)), this._defaultNodeLabelFn = e, this;
219
+ }
220
+ /**
221
+ * @returns {number} the number of nodes in the graph.
222
+ */
223
+ nodeCount() {
224
+ return this._nodeCount;
225
+ }
226
+ /**
227
+ * @returns {NodeID[]} the ids of the nodes in the graph.
228
+ *
229
+ * @remarks
230
+ * Use {@link node()} to get the label for each node.
231
+ * Takes `O(|V|)` time.
232
+ */
233
+ nodes() {
234
+ return d(this._nodes);
235
+ }
236
+ /**
237
+ * @returns {NodeID[]} those nodes in the graph that have no in-edges.
238
+ * @remarks Takes `O(|V|)` time.
239
+ */
240
+ sources() {
241
+ var e = this;
242
+ return m(this.nodes(), function(r) {
243
+ return v(e._in[r]);
244
+ });
245
+ }
246
+ /**
247
+ * @returns {NodeID[]} those nodes in the graph that have no out-edges.
248
+ * @remarks Takes `O(|V|)` time.
249
+ */
250
+ sinks() {
251
+ var e = this;
252
+ return m(this.nodes(), function(r) {
253
+ return v(e._out[r]);
254
+ });
255
+ }
256
+ /**
257
+ * Invokes setNode method for each node in `vs` list.
258
+ *
259
+ * @param {Collection<NodeID | number>} vs - List of node IDs to create/set.
260
+ * @param {NodeLabel} [value] - If set, update all nodes with this value.
261
+ * @returns {this}
262
+ * @remarks Complexity: O(|names|).
263
+ */
264
+ setNodes(e, r) {
265
+ var s = arguments, n = this;
266
+ return g(e, function(a) {
267
+ s.length > 1 ? n.setNode(a, r) : n.setNode(a);
268
+ }), this;
269
+ }
270
+ /**
271
+ * Creates or updates the value for the node `v` in the graph.
272
+ *
273
+ * @param {NodeID | number} v - ID of the node to create/set.
274
+ * @param {NodeLabel} [value] - If supplied, it is set as the value for the node.
275
+ * If not supplied and the node was created by this call then
276
+ * {@link setDefaultNodeLabel} will be used to set the node's value.
277
+ * @returns {this} the graph, allowing this to be chained with other functions.
278
+ * @remarks Takes `O(1)` time.
279
+ */
280
+ setNode(e, r) {
281
+ return Object.prototype.hasOwnProperty.call(this._nodes, e) ? (arguments.length > 1 && (this._nodes[e] = r), this) : (this._nodes[e] = arguments.length > 1 ? r : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = l, this._children[e] = {}, this._children[l][e] = !0), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
282
+ }
283
+ /**
284
+ * Gets the label of node with specified name.
285
+ *
286
+ * @param {NodeID | number} v - Node ID.
287
+ * @returns {NodeLabel | undefined} the label assigned to the node with the id `v`
288
+ * if it is in the graph.
289
+ * Otherwise returns `undefined`.
290
+ * @remarks Takes `O(1)` time.
291
+ */
292
+ node(e) {
293
+ return this._nodes[e];
294
+ }
295
+ /**
296
+ * Detects whether graph has a node with specified name or not.
297
+ *
298
+ * @param {NodeID | number} v - Node ID.
299
+ * @returns {boolean} Returns `true` the graph has a node with the id.
300
+ * @remarks Takes `O(1)` time.
301
+ */
302
+ hasNode(e) {
303
+ return Object.prototype.hasOwnProperty.call(this._nodes, e);
304
+ }
305
+ /**
306
+ * Remove the node with the id `v` in the graph or do nothing if the node is
307
+ * not in the graph.
308
+ *
309
+ * If the node was removed this function also removes any incident edges.
310
+ *
311
+ * @param {NodeID | number} v - Node ID to remove.
312
+ * @returns {this} the graph, allowing this to be chained with other functions.
313
+ * @remarks Takes `O(|E|)` time.
314
+ */
315
+ removeNode(e) {
316
+ if (Object.prototype.hasOwnProperty.call(this._nodes, e)) {
317
+ var r = (s) => this.removeEdge(this._edgeObjs[s]);
318
+ delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], g(this.children(e), (s) => {
319
+ this.setParent(s);
320
+ }), delete this._children[e]), g(d(this._in[e]), r), delete this._in[e], delete this._preds[e], g(d(this._out[e]), r), delete this._out[e], delete this._sucs[e], --this._nodeCount;
321
+ }
322
+ return this;
323
+ }
324
+ /**
325
+ * Sets the parent for `v` to `parent` if it is defined or removes the parent
326
+ * for `v` if `parent` is undefined.
327
+ *
328
+ * @param {NodeID | number} v - Node ID to set the parent for.
329
+ * @param {NodeID | number} [parent] - Parent node ID. If not defined, removes the parent.
330
+ * @returns {this} the graph, allowing this to be chained with other functions.
331
+ * @throws if the graph is not compound.
332
+ * @throws if setting the parent would create a cycle.
333
+ * @remarks Takes `O(1)` time.
334
+ */
335
+ setParent(e, r) {
336
+ if (!this._isCompound)
337
+ throw new Error("Cannot set parent in a non-compound graph");
338
+ if (_(r))
339
+ r = l;
340
+ else {
341
+ r += "";
342
+ for (var s = r; !_(s); s = this.parent(s))
343
+ if (s === e)
344
+ throw new Error("Setting " + r + " as parent of " + e + " would create a cycle");
345
+ this.setNode(r);
346
+ }
347
+ return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = r, this._children[r][e] = !0, this;
348
+ }
349
+ /**
350
+ * @private
351
+ * @param {NodeID | number} v - Node ID.
352
+ */
353
+ _removeFromParentsChildList(e) {
354
+ delete this._children[this._parent[e]][e];
355
+ }
356
+ /**
357
+ * Get parent node for node `v`.
358
+ *
359
+ * @param {NodeID | number} v - Node ID.
360
+ * @returns {NodeID | undefined} the node that is a parent of node `v`
361
+ * or `undefined` if node `v` does not have a parent or is not a member of
362
+ * the graph.
363
+ * Always returns `undefined` for graphs that are not compound.
364
+ * @remarks Takes `O(1)` time.
365
+ */
366
+ parent(e) {
367
+ if (this._isCompound) {
368
+ var r = this._parent[e];
369
+ if (r !== l)
370
+ return r;
371
+ }
372
+ }
373
+ /**
374
+ * Gets list of direct children of node v.
375
+ *
376
+ * @param {NodeID | number} [v] - Node ID. If not specified, gets nodes
377
+ * with no parent (top-level nodes).
378
+ * @returns {NodeID[] | undefined} all nodes that are children of node `v` or
379
+ * `undefined` if node `v` is not in the graph.
380
+ * Always returns `[]` for graphs that are not compound.
381
+ * @remarks Takes `O(|V|)` time.
382
+ */
383
+ children(e) {
384
+ if (_(e) && (e = l), this._isCompound) {
385
+ var r = this._children[e];
386
+ if (r)
387
+ return d(r);
388
+ } else {
389
+ if (e === l)
390
+ return this.nodes();
391
+ if (this.hasNode(e))
392
+ return [];
393
+ }
394
+ }
395
+ /**
396
+ * @param {NodeID | number} v - Node ID.
397
+ * @returns {NodeID[] | undefined} all nodes that are predecessors of the
398
+ * specified node or `undefined` if node `v` is not in the graph.
399
+ * @remarks
400
+ * Behavior is undefined for undirected graphs - use {@link neighbors} instead.
401
+ * Takes `O(|V|)` time.
402
+ */
403
+ predecessors(e) {
404
+ var r = this._preds[e];
405
+ if (r)
406
+ return d(r);
407
+ }
408
+ /**
409
+ * @param {NodeID | number} v - Node ID.
410
+ * @returns {NodeID[] | undefined} all nodes that are successors of the
411
+ * specified node or `undefined` if node `v` is not in the graph.
412
+ * @remarks
413
+ * Behavior is undefined for undirected graphs - use {@link neighbors} instead.
414
+ * Takes `O(|V|)` time.
415
+ */
416
+ successors(e) {
417
+ var r = this._sucs[e];
418
+ if (r)
419
+ return d(r);
420
+ }
421
+ /**
422
+ * @param {NodeID | number} v - Node ID.
423
+ * @returns {NodeID[] | undefined} all nodes that are predecessors or
424
+ * successors of the specified node
425
+ * or `undefined` if node `v` is not in the graph.
426
+ * @remarks Takes `O(|V|)` time.
427
+ */
428
+ neighbors(e) {
429
+ var r = this.predecessors(e);
430
+ if (r)
431
+ return St(r, this.successors(e));
432
+ }
433
+ /**
434
+ * @param {NodeID | number} v - Node ID.
435
+ * @returns {boolean} True if the node is a leaf (has no successors), false otherwise.
436
+ */
437
+ isLeaf(e) {
438
+ var r;
439
+ return this.isDirected() ? r = this.successors(e) : r = this.neighbors(e), r.length === 0;
440
+ }
441
+ /**
442
+ * Creates new graph with nodes filtered via `filter`.
443
+ * Edges incident to rejected node
444
+ * are also removed.
445
+ *
446
+ * In case of compound graph, if parent is rejected by `filter`,
447
+ * than all its children are rejected too.
448
+
449
+ * @param {(v: NodeID) => boolean} filter - Function that returns `true` for nodes to keep.
450
+ * @returns {Graph<GraphLabel, NodeLabel, EdgeLabel>} A new graph containing only the nodes for which `filter` returns `true`.
451
+ * @remarks Average-case complexity: O(|E|+|V|).
452
+ */
453
+ filterNodes(e) {
454
+ var r = new this.constructor({
455
+ directed: this._isDirected,
456
+ multigraph: this._isMultigraph,
457
+ compound: this._isCompound
458
+ });
459
+ r.setGraph(this.graph());
460
+ var s = this;
461
+ g(this._nodes, function(i, u) {
462
+ e(u) && r.setNode(u, i);
463
+ }), g(this._edgeObjs, function(i) {
464
+ r.hasNode(i.v) && r.hasNode(i.w) && r.setEdge(i, s.edge(i));
465
+ });
466
+ var n = {};
467
+ function a(i) {
468
+ var u = s.parent(i);
469
+ return u === void 0 || r.hasNode(u) ? (n[i] = u, u) : u in n ? n[u] : a(u);
470
+ }
471
+ return this._isCompound && g(r.nodes(), function(i) {
472
+ r.setParent(i, a(i));
473
+ }), r;
474
+ }
475
+ /* === Edge functions ========== */
476
+ /**
477
+ * Sets a new default value that is assigned to edges that are created without
478
+ * a label.
479
+ *
480
+ * @param {typeof this._defaultEdgeLabelFn | EdgeLabel} newDefault - If a function,
481
+ * it is called with the parameters `(v, w, name)`.
482
+ * Otherwise, it is assigned as the label directly.
483
+ * @returns {this}
484
+ */
485
+ setDefaultEdgeLabel(e) {
486
+ return $(e) || (e = y(e)), this._defaultEdgeLabelFn = e, this;
487
+ }
488
+ /**
489
+ * @returns {number} the number of edges in the graph.
490
+ * @remarks Complexity: O(1).
491
+ */
492
+ edgeCount() {
493
+ return this._edgeCount;
494
+ }
495
+ /**
496
+ * Gets edges of the graph.
497
+ *
498
+ * @returns {EdgeObj[]} the {@link EdgeObj} for each edge in the graph.
499
+ *
500
+ * @remarks
501
+ * In case of compound graph subgraphs are not considered.
502
+ * Use {@link edge()} to get the label for each edge.
503
+ * Takes `O(|E|)` time.
504
+ */
505
+ edges() {
506
+ return A(this._edgeObjs);
507
+ }
508
+ /**
509
+ * Establish an edges path over the nodes in nodes list.
510
+ *
511
+ * If some edge is already exists, it will update its label, otherwise it will
512
+ * create an edge between pair of nodes with label provided or default label
513
+ * if no label provided.
514
+ *
515
+ * @param {Collection<NodeID>} vs - List of node IDs to create edges between.
516
+ * @param {EdgeLabel} [value] - If set, update all edges with this value.
517
+ * @returns {this}
518
+ * @remarks Complexity: O(|nodes|).
519
+ */
520
+ setPath(e, r) {
521
+ var s = this, n = arguments;
522
+ return ye(e, function(a, i) {
523
+ return n.length > 1 ? s.setEdge(a, i, r) : s.setEdge(a, i), i;
524
+ }), this;
525
+ }
526
+ /**
527
+ * Creates or updates the label for the edge (`v`, `w`) with the optionally
528
+ * supplied `name`.
529
+ *
530
+ * @overload
531
+ * @param {EdgeObj} arg0 - Edge object.
532
+ * @param {EdgeLabel} [value] - If supplied, it is set as the label for the edge.
533
+ * If not supplied and the edge was created by this call then
534
+ * {@link setDefaultEdgeLabel} will be used to assign the edge's label.
535
+ * @returns {this} the graph, allowing this to be chained with other functions.
536
+ * @remarks Takes `O(1)` time.
537
+ */
538
+ /**
539
+ * Creates or updates the label for the edge (`v`, `w`) with the optionally
540
+ * supplied `name`.
541
+ *
542
+ * @overload
543
+ * @param {NodeID | number} v - Source node ID. Number values will be coerced to strings.
544
+ * @param {NodeID | number} w - Target node ID. Number values will be coerced to strings.
545
+ * @param {EdgeLabel} [value] - If supplied, it is set as the label for the edge.
546
+ * If not supplied and the edge was created by this call then
547
+ * {@link setDefaultEdgeLabel} will be used to assign the edge's label.
548
+ * @param {string | number} [name] - Edge name. Only useful with multigraphs.
549
+ * @returns {this} the graph, allowing this to be chained with other functions.
550
+ * @remarks Takes `O(1)` time.
551
+ */
552
+ setEdge() {
553
+ var e, r, s, n, a = !1, i = arguments[0];
554
+ typeof i == "object" && i !== null && "v" in i ? (e = i.v, r = i.w, s = i.name, arguments.length === 2 && (n = arguments[1], a = !0)) : (e = i, r = arguments[1], s = arguments[3], arguments.length > 2 && (n = arguments[2], a = !0)), e = "" + e, r = "" + r, _(s) || (s = "" + s);
555
+ var u = p(this._isDirected, e, r, s);
556
+ if (Object.prototype.hasOwnProperty.call(this._edgeLabels, u))
557
+ return a && (this._edgeLabels[u] = n), this;
558
+ if (!_(s) && !this._isMultigraph)
559
+ throw new Error("Cannot set a named edge when isMultigraph = false");
560
+ this.setNode(e), this.setNode(r), this._edgeLabels[u] = a ? n : this._defaultEdgeLabelFn(e, r, s);
561
+ var h = vt(this._isDirected, e, r, s);
562
+ return e = h.v, r = h.w, Object.freeze(h), this._edgeObjs[u] = h, x(this._preds[r], e), x(this._sucs[e], r), this._in[r][u] = h, this._out[e][u] = h, this._edgeCount++, this;
563
+ }
564
+ /**
565
+ * Gets the label for the specified edge.
566
+ *
567
+ * @overload
568
+ * @param {EdgeObj} v - Edge object.
569
+ * @returns {EdgeLabel | undefined} the label for the edge (`v`, `w`) if the
570
+ * graph has an edge between `v` and `w` with the optional `name`.
571
+ * Returned `undefined` if there is no such edge in the graph.
572
+ * @remarks
573
+ * `v` and `w` can be interchanged for undirected graphs.
574
+ * Takes `O(1)` time.
575
+ */
576
+ /**
577
+ * Gets the label for the specified edge.
578
+ *
579
+ * @overload
580
+ * @param {NodeID | number} v - Source node ID.
581
+ * @param {NodeID | number} w - Target node ID.
582
+ * @param {string | number} [name] - Edge name. Only useful with multigraphs.
583
+ * @returns {EdgeLabel | undefined} the label for the edge (`v`, `w`) if the
584
+ * graph has an edge between `v` and `w` with the optional `name`.
585
+ * Returned `undefined` if there is no such edge in the graph.
586
+ * @remarks
587
+ * `v` and `w` can be interchanged for undirected graphs.
588
+ * Takes `O(1)` time.
589
+ */
590
+ edge(e, r, s) {
591
+ var n = arguments.length === 1 ? E(this._isDirected, arguments[0]) : p(this._isDirected, e, r, s);
592
+ return this._edgeLabels[n];
593
+ }
594
+ /**
595
+ * Detects whether the graph contains specified edge or not.
596
+ *
597
+ * @overload
598
+ * @param {EdgeObj} v - Edge object.
599
+ * @returns {boolean} `true` if the graph has an edge between `v` and `w`
600
+ * with the optional `name`.
601
+ * @remarks
602
+ * `v` and `w` can be interchanged for undirected graphs.
603
+ * No subgraphs are considered.
604
+ * Takes `O(1)` time.
605
+ */
606
+ /**
607
+ * Detects whether the graph contains specified edge or not.
608
+ *
609
+ * @overload
610
+ * @param {NodeID | number} v - Source node ID.
611
+ * @param {NodeID | number} w - Target node ID.
612
+ * @param {string | number} [name] - Edge name. Only useful with multigraphs.
613
+ * @returns {boolean} `true` if the graph has an edge between `v` and `w`
614
+ * with the optional `name`.
615
+ * @remarks
616
+ * `v` and `w` can be interchanged for undirected graphs.
617
+ * No subgraphs are considered.
618
+ * Takes `O(1)` time.
619
+ */
620
+ hasEdge(e, r, s) {
621
+ var n = arguments.length === 1 ? E(this._isDirected, arguments[0]) : p(this._isDirected, e, r, s);
622
+ return Object.prototype.hasOwnProperty.call(this._edgeLabels, n);
623
+ }
624
+ /**
625
+ * Removes the edge (`v`, `w`) if the graph has an edge between `v` and `w`
626
+ * with the optional `name`. If not this function does nothing.
627
+ *
628
+ * @overload
629
+ * @param {EdgeObj} v - Edge object.
630
+ * @returns {this}
631
+ * @remarks
632
+ * `v` and `w` can be interchanged for undirected graphs.
633
+ * No subgraphs are considered.
634
+ * Takes `O(1)` time.
635
+ */
636
+ /**
637
+ * Removes the edge (`v`, `w`) if the graph has an edge between `v` and `w`
638
+ * with the optional `name`. If not this function does nothing.
639
+ *
640
+ * @overload
641
+ * @param {NodeID | number} v - Source node ID.
642
+ * @param {NodeID | number} w - Target node ID.
643
+ * @param {string | number} [name] - Edge name. Only useful with multigraphs.
644
+ * @returns {this}
645
+ * @remarks
646
+ * `v` and `w` can be interchanged for undirected graphs.
647
+ * Takes `O(1)` time.
648
+ */
649
+ removeEdge(e, r, s) {
650
+ var n = arguments.length === 1 ? E(this._isDirected, arguments[0]) : p(this._isDirected, e, r, s), a = this._edgeObjs[n];
651
+ return a && (e = a.v, r = a.w, delete this._edgeLabels[n], delete this._edgeObjs[n], B(this._preds[r], e), B(this._sucs[e], r), delete this._in[r][n], delete this._out[e][n], this._edgeCount--), this;
652
+ }
653
+ /**
654
+ * @param {NodeID | number} v - Target node ID.
655
+ * @param {NodeID | number} [u] - Optionally filters edges down to just those
656
+ * coming from node `u`.
657
+ * @returns {EdgeObj[] | undefined} all edges that point to the node `v`.
658
+ * Returns `undefined` if node `v` is not in the graph.
659
+ * @remarks
660
+ * Behavior is undefined for undirected graphs - use {@link nodeEdges} instead.
661
+ * Takes `O(|E|)` time.
662
+ */
663
+ inEdges(e, r) {
664
+ var s = this._in[e];
665
+ if (s) {
666
+ var n = A(s);
667
+ return r ? m(n, function(a) {
668
+ return a.v === r;
669
+ }) : n;
670
+ }
671
+ }
672
+ /**
673
+ * @param {NodeID | number} v - Target node ID.
674
+ * @param {NodeID | number} [w] - Optionally filters edges down to just those
675
+ * that point to `w`.
676
+ * @returns {EdgeObj[] | undefined} all edges that point to the node `v`.
677
+ * Returns `undefined` if node `v` is not in the graph.
678
+ * @remarks
679
+ * Behavior is undefined for undirected graphs - use {@link nodeEdges} instead.
680
+ * Takes `O(|E|)` time.
681
+ */
682
+ outEdges(e, r) {
683
+ var s = this._out[e];
684
+ if (s) {
685
+ var n = A(s);
686
+ return r ? m(n, function(a) {
687
+ return a.w === r;
688
+ }) : n;
689
+ }
690
+ }
691
+ /**
692
+ * @param {NodeID | number} v - Target Node ID.
693
+ * @param {NodeID | number} [w] - If set, filters those edges down to just
694
+ * those between nodes `v` and `w` regardless of direction
695
+ * @returns {EdgeObj[] | undefined} all edges to or from node `v` regardless
696
+ * of direction. Returns `undefined` if node `v` is not in the graph.
697
+ * @remarks Takes `O(|E|)` time.
698
+ */
699
+ nodeEdges(e, r) {
700
+ var s = this.inEdges(e, r);
701
+ if (s)
702
+ return s.concat(this.outEdges(e, r));
703
+ }
704
+ }
705
+ Z.prototype._nodeCount = 0;
706
+ Z.prototype._edgeCount = 0;
707
+ function x(t, e) {
708
+ t[e] ? t[e]++ : t[e] = 1;
709
+ }
710
+ function B(t, e) {
711
+ --t[e] || delete t[e];
712
+ }
713
+ function p(t, e, r, s) {
714
+ var n = "" + e, a = "" + r;
715
+ if (!t && n > a) {
716
+ var i = n;
717
+ n = a, a = i;
718
+ }
719
+ return n + G + a + G + (_(s) ? $t : s);
720
+ }
721
+ function vt(t, e, r, s) {
722
+ var n = "" + e, a = "" + r;
723
+ if (!t && n > a) {
724
+ var i = n;
725
+ n = a, a = i;
726
+ }
727
+ var u = { v: n, w: a };
728
+ return s && (u.name = s), u;
729
+ }
730
+ function E(t, e) {
731
+ return p(t, e.v, e.w, e.name);
732
+ }
733
+ export {
734
+ Z as G,
735
+ O as b,
736
+ _ as i,
737
+ A as v
738
+ };